public void Restart() { //reload scene to restart the game SceneManager.LoadScene(SceneManager.GetActiveScene().name); ScoreManager.ResetScore(); LevelManager.ResetLevel(); WeaponCounter.ResetCount(); Enemy.ResetAllFreq(); }
public void Fire() { Projectile p; Vector3 velocity = Vector3.up * _def.velocity; if (transform.up.y < 0) { velocity.y = -velocity.y; } //fire based on which kind of weapon switch (_type) { case WeaponType.simple: if (WeaponCounter.simpleCount == 0) { ; } else { p = makeProjectile(); p.rigid.velocity = velocity; WeaponCounter.DecrementSimple(); } break; case WeaponType.blaster: if (WeaponCounter.blasterCount == 0) { ; } else { p = makeProjectile(); //middle bullet p.rigid.velocity = velocity; p = makeProjectile(); //right bullet p.transform.rotation = Quaternion.AngleAxis(30, Vector3.back); p.rigid.velocity = p.rigid.rotation * velocity; p = makeProjectile(); //left bullet p.transform.rotation = Quaternion.AngleAxis(-30, Vector3.back); p.rigid.velocity = p.rigid.rotation * velocity; WeaponCounter.DecrementBlaster(); } break; case WeaponType.enemy: p = makeProjectile(); p.rigid.velocity = Vector3.down * _def.velocity; //Enemy weapon type shots straight down, not based on enemy orientation break; case WeaponType.surround: //surround weapon shoots out one bullet every 45 degrees, 8 bullets total if (WeaponCounter.surroundCount == 0) { ; } else { for (int i = 0; i < 360; i += 45) { p = makeProjectile(); p.transform.rotation = Quaternion.AngleAxis(i, Vector3.back); p.rigid.velocity = p.rigid.rotation * velocity; } WeaponCounter.DecrementSurround(); } break; case WeaponType.swivel: //aims to nearest enemy, shoots 3 bullets in that direction if (WeaponCounter.swivelCount == 0) { ; } else if (_swivelBullet == null) //only one swivel bullet exists at a time { p = makeProjectile(); _swivelBullet = p.gameObject; WeaponCounter.DecrementSwivel(); } break; case WeaponType.annihilate: //annihilates all enemies on screen by sending out one weapon every 2 degrees, 180 bullets total if (WeaponCounter.annihilateCount == 0) { ; } else { for (int i = 0; i < 360; i += 2) { p = makeProjectile(); p.transform.rotation = Quaternion.AngleAxis(i, Vector3.back); p.rigid.velocity = p.rigid.rotation * velocity; } WeaponCounter.DecrementAnnihilate(); } break; } SoundManager.soundManager.ShotSound(); //Whenever weapon fires call the shotSound function }