/// <summary> /// Spawns rocket /// </summary> void SpawnRocket() { if (rocketTimer > 0) { return; // if the rocket timer is not below 0, doesn't run } rocketTimer = maxTimeForRocket; // sets timer for it to count down SoundEffectBoard.RocketMissileSound(); // plays the rocket soundeffect // Spawns the rocket RocketMechanic rocket = Instantiate(rocketPrefab, muzzle.transform.position, transform.rotation); }
/// <summary> /// Cause the missiles to fire /// </summary> void Missles() { if (missile1) // if missile1 is true { missile1.timeToLaunch = true; // fires the missile } if (missile2) // if missile 2 is true { missile2.timeToLaunch = true; // fires the missile } SoundEffectBoard.RocketMissileSound(); // missile sound }
/// <summary> /// Spawns new missiles to be fired when ready /// </summary> private void MissleSpawning() { if (missleRespawnTime > 0 && !misslesSpawned) // if timer is greater than 0 and missilesSpawned is false { missleRespawnTime -= Time.deltaTime; } if (missleRespawnTime <= 0) // if timer is less than or equal to 0 { missile1 = Instantiate(prefabMissile, missilePos1.position, missilePos1.rotation); // spawns missile 1 missile1.transform.parent = missilePos1; // make missilePos1 a parent of the missile prefab missile2 = Instantiate(prefabMissile, missilePos2.position, missilePos2.rotation); // spawns missile 2 missile2.transform.parent = missilePos2; // make missilePos2 a parent of the missile prefab missleRespawnTime = 10; // time to respawn again misslesSpawned = true; // missiles spawned SoundEffectBoard.RocketMissileSound(); // plays the rocket/missile sound } }