public void ChangeHealth(int points) { if (!isImmune) { if (points < 0 || lives[PlayerIndex] < MaxLives) { lives[PlayerIndex] += points; if (lives[PlayerIndex] < 0) { lives[PlayerIndex] = 0; } uIManager.UpdateLives(lives[PlayerIndex], PlayerIndex); isImmune = true; StartCoroutine(ImmuneTimer()); } } else { isImmune = false; Shields.SetActive(false); } switch (lives[PlayerIndex]) { case 0: animator.SetTrigger("DeathTrigger"); audioSource.PlayOneShot(ExplosionClip); Thrusters.SetActive(false); RightEngineFire.SetActive(false); LeftEngineFire.SetActive(false); Destroy(GetComponent <Collider2D>()); Destroy(this.gameObject, 2.65f); break; case 1: RightEngineFire.SetActive(true); break; case 2: LeftEngineFire.SetActive(true); RightEngineFire.SetActive(false); break; case 3: LeftEngineFire.SetActive(false); break; default: Debug.LogError("Error in Player" + PlayerIndex + 1 + "Lives"); break; } }
public void ActivateShield() { audioSource.PlayOneShot(PowerUpClip); isImmune = true; Shields.SetActive(true); }