Copying and Pasting cs Code

In cs, like in almost any computer programming language, reading data from a file can be tricky. You add extra lines of code to tell the computer what to do. Sometimes you can copy and paste these lines from other peoples’ code.

For example, you can follow the pattern in this listing:

         public void AnimalcollisionWithBullet(GameObject animalObject, GameObject bulletObject)
         {
             if (animalObject.GetComponent().isStanding) return;
             SkillType type = bulletObject.GetComponent().skillType;
             int animalIndex = animalObject.GetComponent().animalIndex;
             switch (type)
             {
                 case SkillType.LUA:
                     {
                         GameObject effectObject = (GameObject)Instantiate(Resources.Load("Effects/LUA"));
                         effectObject.transform.parent = effectLayer.transform;
                         effectObject.GetComponent().mapObjectTransform = animalObject.transform;
                         Destroy(bulletObject);
                         animalObject.GetComponent().setStand(true, 2, Animal.STATE_FIRE);
                         animalObject.GetComponent().AddForce(new Vector2(0, -300));
                         if (animalIndex == 0)
                         {
                             showRevivalTask(2, EmotionType.CUOIDEU);
                         }
                     }
                     break;
                 case SkillType.DONGBANG:
                     {
                         GameObject effectObject = (GameObject)Instantiate(Resources.Load("Effects/DONGBANG"));
                         effectObject.transform.parent = effectLayer.transform;
                         effectObject.GetComponent().mapObjectTransform = animalObject.transform;
                         Destroy(bulletObject);
                         animalObject.GetComponent().setStand(true,2, Animal.STATE_RUN);
                         animalObject.GetComponent().AddForce(new Vector2(0, -300));
                         if (animalIndex == 0)
                         {
                             showRevivalTask(2, EmotionType.HOAMAT);
                         }
                     }
                     break;
                 case SkillType.THIENTHACH:
                     {
                         {
                             GameObject effectObject = (GameObject)Instantiate(Resources.Load("Effects/THIENTHACH"));
                             effectObject.transform.parent = effectLayer.transform;
                             effectObject.GetComponent().mapObjectTransform = animalObject.transform;
                         }
                         {
                             GameObject effectObject = (GameObject)Instantiate(Resources.Load("Effects/CHOANG"));
                             effectObject.transform.parent = effectLayer.transform;
                             effectObject.GetComponent().mapObjectTransform = animalObject.transform;
                         }
                         Destroy(bulletObject);
                         animalObject.GetComponent().setStand(true, 2, Animal.STATE_SHOCK);
                         animalObject.GetComponent().AddForce(new Vector2(0, -300));
                         if (animalIndex == 0)
                         {
                             showRevivalTask(2, EmotionType.HOAMAT);
                         }
                     }
                     break;
                 case SkillType.SET:
                     {
                         GameObject effectObject = (GameObject)Instantiate(Resources.Load("Effects/SET"));
                         effectObject.transform.parent = effectLayer.transform;
                         effectObject.GetComponent().mapObjectTransform = animalObject.transform;
                         animalObject.GetComponent().setStand(true, 2, Animal.STATE_FIRE);
                         animalObject.GetComponent().AddForce(new Vector2(0, -300));
                         if (animalIndex == 0)
                         {
                             showRevivalTask(2, EmotionType.HOAMAT);
                         }
                     }
                     break;
                 case SkillType.BOM:
                     {
                         GameObject effectObject = (GameObject)Instantiate(Resources.Load("Effects/LUA"));
                         effectObject.transform.parent = effectLayer.transform;
                         effectObject.GetComponent().mapObjectTransform = animalObject.transform;
                         Destroy(bulletObject);
                         animalObject.GetComponent().setStand(true, 2, Animal.STATE_FIRE);
                         animalObject.GetComponent().AddForce(new Vector2(0, -300));
                     }
                     break;
                 case SkillType.DOICHO:
                     {
                         GameObject effectObject = (GameObject)Instantiate(Resources.Load("Effects/KHOI"));
                         effectObject.transform.parent = effectLayer.transform;
                         effectObject.GetComponent().mapObjectTransform = animalObject.transform;
                         int animalIndexb = bulletObject.GetComponent().animalIndex;
                         Destroy(bulletObject);
                         GameObject animal2 = animals.getAnimal(animalIndexb);
                         GameObject effectObject2 = (GameObject)Instantiate(Resources.Load("Effects/KHOI"));
                         effectObject.transform.parent = effectLayer.transform;
                         effectObject2.GetComponent().mapObjectTransform = animal2.transform;
                         Vector3 p1 = animalObject.transform.localPosition;
                         Vector3 p2 = animal2.transform.localPosition;
                         animal2.transform.localPosition = new Vector3(p1.x, p1.y, p2.z);
                         animalObject.transform.localPosition = new Vector3(p2.x, p2.y, p1.z);
                     }
                     break;
             }
         }