예제 #1
0
    public void TakeDamage(float Dmg, bool isHero, DamageType type)
    {
        if (_Order == Boss_Order.Back || _Order == Boss_Order.Waiting)
        {
            return;
        }
        if (_IsDead)
        {
            return;
        }
        health -= Dmg;
        StartCoroutine(characterSound.BasicSound(1));
        popUp.GetComponent <TextMesh>().text = Dmg.ToString();

        switch (type)
        {
        case DamageType.Normal:
            popUp.GetComponent <TextMesh>().color = new Color(1.0f, 0.0f, 0.0f);
            GameObject hit = Instantiate(hitEffect, transform.position, Quaternion.identity) as GameObject;
            break;

        case DamageType.Poison:
            popUp.GetComponent <TextMesh>().color = new Color(0.0f, 1.0f, 0.0f);
            break;

        case DamageType.Ultimate:
            popUp.GetComponent <TextMesh>().color = new Color(0.0f, 0.0f, 1.0f);
            break;

        case DamageType.Fire:
            popUp.GetComponent <TextMesh>().color = new Color(1.0f, 0.0f, 0.0f);
            break;
        }
        Instantiate(popUp, transform.position, Camera.main.transform.rotation, transform);

        healthBar.fillAmount = health / MaxHealth;


        if (health <= 0.0f)
        {
            if (gameObject.activeInHierarchy)
            {
                StartCoroutine(DeathAnimation());
            }
            if (!_IsDead)
            {
                player.GetComponent <Player>().IncrementUltCharge();
            }

            _IsDead     = true;
            _isPoisoned = false;
            _IsAttacked = false;
            stunParticle.Stop();
        }
    }
예제 #2
0
 private void OnTriggerEnter(Collider item)
 {
     if (item.gameObject.CompareTag("PickUp"))
     {
         UIManager  uiManager = ServiceLocator.Get <UIManager>();
         GameObject tower     = ServiceLocator.Get <LevelManager>().towerInstance;
         item.gameObject.SetActive(false);
         tower.GetComponent <Tower>().fullHealth += healedByItem;
         StartCoroutine(characterSound.BasicSound(5));
         if (tower.GetComponent <Tower>().fullHealth > 100.0f)
         {
             tower.GetComponent <Tower>().fullHealth = 100.0f;
         }
         health += healedByItem;
         if (_maxHealth > 100.0f)
         {
             _maxHealth = 100.0f;
         }
         uiManager.UpdateTowerHealth(tower.GetComponent <Tower>().fullHealth);
         uiManager.UpdatePlayerHealth(health, _maxHealth);
     }
 }
예제 #3
0
    public void TakeDamage(float Dmg, bool isHero, DamageType type)
    {
        if (_IsDead)
        {
            if (animator)
            {
                animator.speed = 1.0f;
                animator.SetBool("Dead", true);
            }
            return;
        }
        if (Dmg < health)
        {
            enemyAbilities.PlayDead();
        }
        health -= Dmg;
        StartCoroutine(characterSound.BasicSound(1));
        popUp.GetComponent <TextMesh>().text = Dmg.ToString();

        switch (type)
        {
        case DamageType.Normal:
            popUp.GetComponent <TextMesh>().color = new Color(1.0f, 0.0f, 0.0f);
            GameObject hit = Instantiate(hitEffect, transform.position, Quaternion.identity) as GameObject;
            break;

        case DamageType.Poison:
            popUp.GetComponent <TextMesh>().color = new Color(0.0f, 1.0f, 0.0f);
            break;

        case DamageType.Ultimate:
            popUp.GetComponent <TextMesh>().color = new Color(0.0f, 0.0f, 1.0f);
            break;

        case DamageType.Fire:
            popUp.GetComponent <TextMesh>().color = new Color(1.0f, 0.0f, 0.0f);
            break;
        }
        Instantiate(popUp, transform.position, Camera.main.transform.rotation, transform);

        healthBar.fillAmount = health / MaxHealth;

        if (isHero)
        {
            enemyAbilities.GroupAttack();

            GameObject[] list = GameObject.FindGameObjectsWithTag("Enemy");
            foreach (GameObject enemy in list)
            {
                Order order = enemy.GetComponent <Enemy>()._Order;
                if (order == Order.Fight)
                {
                    _isDetected = false;
                    break;
                }
                else
                {
                    _isDetected = true;
                }
            }
            if (_isDetected && _Order != Order.Stunned)
            {
                _Order = Order.Fight;
            }
        }

        if (health <= 0.0f)
        {
            if (animator)
            {
                animator.speed = 1.0f;
                animator.SetBool("Dead", true);
            }
            if (_IsStolen)
            {
                float randomNumber = UnityEngine.Random.Range(0.0f, 1.0f);
                if (randomNumber == _DropRate)
                {
                    for (int i = 0; i < _AmountofTrash; i++)
                    {
                        Instantiate(pickUp, transform.position, Quaternion.identity);
                    }
                }
                _IsStolen = false;
            }
            if (gameObject.activeInHierarchy)
            {
                StartCoroutine(DeathAnimation());
            }
            if (!_IsDead)
            {
                player.GetComponent <Player>().IncrementUltCharge();
            }

            _IsDead     = true;
            _isPoisoned = false;
            _IsAttacked = false;
            stunParticle.Stop();
        }
    }