Exemple #1
0
    private void OnTriggerExit2D(Collider2D other)
    {
        playerMovement player = other.GetComponent <playerMovement>();

        if (player != null)
        {
            locker.CheckLock();
        }
    }
Exemple #2
0
    /// <summary>
    /// Destroys the object if health is smaller or equel to 0
    /// </summary>
    void Die()
    {
        EnemyMovement enemy = GetComponent <EnemyMovement>();

        if (!isPLayer)
        {
            FindObjectOfType <AudioManager>().Play("Enemy Death");

            isPLayer = false;

            if (enemy != null)
            {
                RoomLocker locker = GetComponentInParent <RoomLocker>();

                locker.enemies.Remove(enemy.gameObject);
                locker.CheckLock();
            }

            GameObject randomDrop = DropOnDeath[(int)Random.Range(0, DropOnDeath.Length)];
            Instantiate(randomDrop, transform.position, Quaternion.identity);

            GameObject.FindObjectOfType <GameManager>().enemies += 1;

            Destroy(gameObject);
        }
        else
        {
            FindObjectOfType <AudioManager>().Play("Player Death");

            isPLayer = true;

            cameraDrop.SetActive(true);

            GetComponentInChildren <PlayerCombat>().OnDeath();

            currentHealth = 200;
            gameObject.SetActive(false);
        }
    }