private void Start() { torchesCollected = hitPoints; playerTorch = GetComponentInChildren <Light2D>(); shadowCaster = GetComponent <ShadowCaster2D>(); torchFX = GetComponentInChildren <TorchFX>(); action = GetComponent <PlayerAction>(); torchCounter = FindObjectOfType <TorchCounter>(); gameController = FindObjectOfType <GameController>(); audioSource = GetComponent <AudioSource>(); torchCounter.SetText(hitPoints, torchesCollected); }
public void Hit(int damage) { if (action.isBlocking) { audioSource.PlayOneShot(blockSounds[Random.Range(0, blockSounds.Length)]); } else { if (hitPoints - damage <= 0) { audioSource.PlayOneShot(deathSound); torchCounter.SetText(0, torchesCollected); isDead = true; PlayerDeath(); } else { audioSource.PlayOneShot(hurtSound); hitPoints -= damage; IncrementTorchNegative(); torchCounter.SetText(hitPoints, torchesCollected); } } }