//The following code is found within TankScript.cs, which both the player and enemy tanks inherit from. SpinWheel() and currentSpecialAttack() are called by different means by players and AI enemies. protected delegate void SpecialAttackMethod(); protected SpecialAttackMethod currentSpecialAttack; protected SpecialAttackMethod[] specialAttackMethods; protected virtual void Start() { specialAttackMethods = new SpecialAttackMethod[] { FireMissile, SpawnShield, SpeedBoost, Heal, SuperHeal, DeployMine, SuperShots }; currentSpecialAttack = Nothing; } protected IEnumerator SpinWheel() { if (!alive) StopCoroutine("SpinWheel"); spinning = true; if (this is PlayerScript) { UIManager.Instance.SpinWheel(); } yield return new WaitForSeconds(spinTime); spinning = false; specialAttackIndex = forceSpecialAttack ? forcedSpecialIndex : Random.Range(0, specialAttackMethods.Length); StartCoroutine("SpecialAttackTimer"); currentSpecialAttack = specialAttackMethods[specialAttackIndex]; if (this is PlayerScript) { UIManager.Instance.SpecialAttack(true, specialAttackTimer, specialAttackIndex); } } protected IEnumerator SpecialAttackTimer() { ultStartedTime = Time.time; yield return new WaitForSeconds(specialAttackTimer); currentSpecialAttack = Nothing; } protected IEnumerator Shield() { foreach (ParticleSystem p in shieldParticles) { p.Play(); } AudioSource shieldSound = AudioManager.Instance.SpawnSound("ShieldSound", transform, false, true, false, 1f); shielded = true; yield return new WaitForSeconds(shieldTime); shielded = false; foreach (ParticleSystem p in shieldParticles) { p.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear); } AudioManager.Instance.ReturnSource(shieldSound); } protected virtual IEnumerator SpeedBoosted() { float originalSpeed = maxSpeed; float originalTurnSpeed = turnSpeed; AudioManager.Instance.SpawnSound("SpeedBoostSound", transform, false, false, false, 1f); turnSpeed *= 2; maxSpeed *= 2; yield return new WaitForSeconds(10); turnSpeed = originalTurnSpeed; maxSpeed = originalSpeed; } protected IEnumerator SuperShotTimer() { foreach (ParticleSystem p in superShotParticles) p.Play(); AudioSource superShotSound = AudioManager.Instance.SpawnSound("SuperShotSound", transform, false, true, false, 1f); int originalDamage = shotDamage; shotDamage *= 3; yield return new WaitForSeconds(10); shotDamage = originalDamage; AudioManager.Instance.ReturnSource(superShotSound); foreach (ParticleSystem p in superShotParticles) p.Stop(); } protected IEnumerator SuperHealing() { for (int i = 0; i < 20; i++) { yield return new WaitForSeconds(1f); health = Mathf.Clamp(health + (maxHealth / 20), 0, maxHealth); healthSlider.value = health; if (this is PlayerScript) UIManager.Instance.ShowDamage(health, maxHealth); } } protected void DeployMine() { GameManager.Instance.MinePool.GetObject(transform.position, Quaternion.identity); } protected void FireMissile() { CameraShaker.Instance.ShakeCamera(2 * cameraShakeShoot, 2f); AudioManager.Instance.SpawnSound("MissileLaunchSound", missileStart.transform, false, false, false, this is PlayerScript ? 0.7f : 0.6f); GameObject missileGO = GameManager.Instance.MissilePool.GetObject(missileStart.position, tower.transform.rotation); MissileScript missile = missileGO.GetComponent(); if (this is PlayerScript) { if (WaveSpawner.Instance.CurrentWaveTanks.Count > 0) { missile.Init(WaveSpawner.Instance.CurrentWaveTanks[Random.Range(0, WaveSpawner.Instance.CurrentWaveTanks.Count)].GetComponent(), this); } else missile.Init(null, this); } else { missile.Init(FindObjectOfType(), this); } } protected void SpawnShield() { StartCoroutine("Shield"); } protected void Nothing() { return; } protected void SpeedBoost() { StartCoroutine("SpeedBoosted"); } protected void Heal() { AudioSource healingSound = AudioManager.Instance.SpawnSound("HealingSound", transform, false, false, false, 1f); foreach (ParticleSystem p in healingParticles) { p.Play(); } health += (maxHealth / 100) * 30; if (health > maxHealth) health = maxHealth; healthSlider.value = health; if (this is PlayerScript) UIManager.Instance.ShowDamage(health, maxHealth); } protected void SuperHeal() { AudioSource healingSound = AudioManager.Instance.SpawnSound("SuperHealingSound", transform, false, false, false, 1f); foreach (ParticleSystem p in healingParticles) { p.Play(); } StartCoroutine("SuperHealing"); } protected void SuperShots() { StartCoroutine("SuperShotTimer"); }