Ejemplo n.º 1
0
    public override void OnTriggerEnter2D(Collider2D other)
    {
        BonusItem bonusItem = other.GetComponent <BonusItem>();

        if (bonusItem)
        {
            GameManager.Instance.PickBonus(bonusItem.GetSettings());
        }
        else
        {
            CollectableItem collectable = other.GetComponent <CollectableItem>();
            if (collectable)
            {
                GameManager.Instance.AddScore(collectable.Score * _scoreMulty);
                if (_itemCollectedAction != null)
                {
                    _itemCollectedAction();
                }
            }
            else if (other.GetComponent <DeadlyItem>() && !_isInsensitive)
            {
                if (_heards <= 0)
                {
                    GameManager.Instance.GameOver();
                }
                if (_heards > 0)
                {
                    _heards--;
                }
            }
        }
        Destroy(other.gameObject);
    }