Exemple #1
0
    public void ReciveDamage(int damage, bool isPlayerCollision)
    {
        if (livesCurr <= 0)
        {
            return;
        }

        livesCurr -= damage;
        StartCoroutine(HelperFunctions.BlinkOfDamage(_spRen));

        if (this is BossBase)
        {
            EventData data = new EventData("OnBossGetDamage");
            data["livesMax"]  = livesMax;
            data["livesCurr"] = livesCurr;
            GameManager.Instance.EventManager.CallOnBossGetDamage(data);
        }

        if (livesCurr <= 0)
        {
            if (!isPlayerCollision)
            {
                GameManager.Instance.Player.Score += livesMax / 10;
                if (this is BossBase)
                {
                    GetComponent <CoinsDropper>().Drop();
                }
            }

            if (this is BossBase)
            {
                GameManager.Instance.EventManager.CallOnBossKilled();
            }

            CreateDieEffect();

            Destroy(this.gameObject);
        }
    }