예제 #1
0
    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();
        }
    }
예제 #2
0
    protected void SpottedPlayer()
    {
        GlobalAudioSource.PlaySoundEffect(spottedClip);

        // TODO: pool
        Destroy(Instantiate(playerSpotted, transform.position, Quaternion.identity), 1f);
    }
예제 #3
0
    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);
    }
예제 #4
0
 public void OnPointerEnter(PointerEventData eventData)
 {
     outline.enabled = true;
     GlobalAudioSource.PlaySoundEffect(hoverSound);
 }
예제 #5
0
 public void Click()
 {
     GlobalAudioSource.PlaySoundEffect(clickSound);
     outline.enabled = false;
 }