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:

     IEnumerator ShootingRoutine_04()
     {
         yield return new WaitForSeconds(1f);
         int bulletSpeed = 4;

         GameObject bullet = pools.GetPoolableObject("e_bullet");

         Vector3 direction = new Vector3(0,0,0);
         int rCount = 1;

         while (true)
         {
             if (rCount == 1)
             {
                 StartCoroutine("ShootingRoutine_01");
                 rCount = 0;
             }
             else
                 rCount++;

             yield return new WaitForSeconds(0.3f);
             for (int i = 0; i < 64; i++)
             {
                 bullet = pools.GetPoolableObject("e_bullet");

                 if (bullet == null)
                 {
                     continue;
                 }

                 yield return new WaitForSeconds(0.1f);

                 direction = new Vector3(Random.Range(-1f, 1f), 0, Random.Range(-1f, 1f));

                 bullet.SetActive(true);
                 bullet.GetComponent().ShootMe(transform.position, direction.normalized, bulletSpeed);

             }
         }
     }