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 Update()
         {
             if (isRunning)
             {
                 if (isStanding)
                 {
                     standTime -= Time.deltaTime;
                     if (standTime <= 0)
                     {
                         isStanding = false;
                         setStand(false, 0, STATE_RUN);
                     }
                 }
                 else if (IsSpeedUp)
                 {
                     SpeedUpTime -= Time.deltaTime;
                     if (!IsSpeedUpStart)
                     {
                         if (transform.localPosition.y <= 1f)
                             animalBody.velocity = new Vector2(4, 5);
                         else
                             IsSpeedUpStart = true;
                     }
                     else
                         animalBody.velocity = new Vector2(12, 0);

                     if (SpeedUpTime <= 0)
                     {
                         IsSpeedUp = false;
                     }
                 }
                 else
                 {
                     UpdateAnimal();
                 }

                 if (IsProtected)
                 {
                     ProtectedTime -= Time.deltaTime;
                     if (ProtectedTime <= 0)
                         IsProtected = false;
                 }

             }
         }