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 SpawningRoutine()
{
yield return new WaitForSeconds(3);
while (!UIgame.scoreAchived)
{
GameObject enemy = null;
//FIRST STAGE OF SPAWNING
//CHOOSE ENEMY FOR SPAWN
int r = rand.Randomization_1(0, 10, 80, 99);
if (r == 0)
{
enemy = pools.GetPoolableObject("enemy_01");
}
else if (r == 1)
{
enemy = pools.GetPoolableObject("enemy_02");
}
else
{
enemy = pools.GetPoolableObject("enemy_03");
}
//SECOND STAGE OF SPAWNING
//SPAWN CHOSEN ENEMY IN RANDOM POINT ON TOP SCREEN SIDE
r = Random.Range(0, pointsPositions.Length);
if (enemy != null)
{
enemy.SetActive(true);
enemy.GetComponent().Activation(new Vector3(pointsPositions[r], 2, strtSpawn.position.z),
new Vector3(0,0,-1));
}
int spawnDelay;
if (SystemScr.difficultyIsHard)
spawnDelay = 1;
else
spawnDelay = Random.Range(3,5);
yield return new WaitForSeconds(spawnDelay);
}
//BOSS ACTIVATION
pools.DeleteEnemiesAndBullets();
CameraMotor.speedScreen = 0;
Camera.main.GetComponent().city_1.gameObject.SetActive(false);//remove city1
Camera.main.GetComponent().city_2.gameObject.SetActive(false);//remove city2
Camera.main.backgroundColor = Color.black;
GameObject.FindObjectOfType().BossMusicOn();
yield return new WaitForSeconds(6);
pools.AcivateBoss();
}
{
yield return new WaitForSeconds(3);
while (!UIgame.scoreAchived)
{
GameObject enemy = null;
//FIRST STAGE OF SPAWNING
//CHOOSE ENEMY FOR SPAWN
int r = rand.Randomization_1(0, 10, 80, 99);
if (r == 0)
{
enemy = pools.GetPoolableObject("enemy_01");
}
else if (r == 1)
{
enemy = pools.GetPoolableObject("enemy_02");
}
else
{
enemy = pools.GetPoolableObject("enemy_03");
}
//SECOND STAGE OF SPAWNING
//SPAWN CHOSEN ENEMY IN RANDOM POINT ON TOP SCREEN SIDE
r = Random.Range(0, pointsPositions.Length);
if (enemy != null)
{
enemy.SetActive(true);
enemy.GetComponent
new Vector3(0,0,-1));
}
int spawnDelay;
if (SystemScr.difficultyIsHard)
spawnDelay = 1;
else
spawnDelay = Random.Range(3,5);
yield return new WaitForSeconds(spawnDelay);
}
//BOSS ACTIVATION
pools.DeleteEnemiesAndBullets();
CameraMotor.speedScreen = 0;
Camera.main.GetComponent
Camera.main.GetComponent
Camera.main.backgroundColor = Color.black;
GameObject.FindObjectOfType
yield return new WaitForSeconds(6);
pools.AcivateBoss();
}