// Use this for initialization void Awake() { playerMovement = GetComponent <PlayerMovement>(); playerAnimController = GetComponent <PlayerAnimController>(); playerSound = GetComponent <PlayerSound>(); gc = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>(); health = maxHealth; ammo = startingAmmo; playerMovement.AllowControl(true); gc.SetPlayerHealthMax(maxHealth); UpdateUI(); GunReload(); }
public void AttackPlayer(float dmg) { if (!_meleeCooldown) { if (health > 0) { health -= dmg; UpdateUI(); if (health <= 0) { playerSound.PlayAudioDie(); playerMovement.AllowControl(false); gc.Gameover(); } else { playerSound.PlayAudioHurt(); } } } }