public void ChangeHealth(int change) { if (currentHealth <= 0) { return; } if (change < 0) { // Can't take any damage because the character is invisible. if (invinsible || totalyInvisible) { return; } else { StartCoroutine(OnHitRoutine()); } } currentHealth += change; if (ChangedHealth != null) { GlobalAudioSource.PlaySoundEffect(hitSound); ChangedHealth.Invoke(currentHealth); } if (currentHealth <= 0 && GotKilled != null) { GlobalAudioSource.PlaySoundEffect(killSound); GotKilled.Invoke(); } }
protected void SpottedPlayer() { GlobalAudioSource.PlaySoundEffect(spottedClip); // TODO: pool Destroy(Instantiate(playerSpotted, transform.position, Quaternion.identity), 1f); }
public void Shoot(Vector3 target, float force) { if (currentCooldown < gunCooldown) { return; } GlobalAudioSource.PlaySoundEffect(shootingSound); currentCooldown = 0; Vector3 direction = target - shootingPosition.position; GameObject newBullet = Instantiate(bulletPrefab, shootingPosition.position, Quaternion.identity); newBullet.GetComponent <Rigidbody2D>().AddForce(direction.normalized * force, ForceMode2D.Impulse); }
public void OnPointerEnter(PointerEventData eventData) { outline.enabled = true; GlobalAudioSource.PlaySoundEffect(hoverSound); }
public void Click() { GlobalAudioSource.PlaySoundEffect(clickSound); outline.enabled = false; }