示例#1
0
        // Whenever we take damage
        public virtual void TakeDamage(GameObject Attacker, float dmgAmount)
        {
            if (isInvincible || IsDead)
            {
                return;
            }

            // Apply damage
            currentHealth = currentHealth - dmgAmount;

            // Notify our parent that we took damage
            if (OnTakeDamage != null)
            {
                OnTakeDamage.Invoke(Attacker, dmgAmount);
            }

            // No health left?
            if (currentHealth <= 0.0f)
            {
                // Notify our parent that we're dead!
                if (OnNoHealth != null)
                {
                    OnTakeDamage.Invoke(Attacker, dmgAmount);
                    OnNoHealth.Invoke();
                }
            }

            // Start a timer to timeout our invincibility
            isInvincible = true;
            Invoke("OnInvincibilityEnd", invincibleTime);
        }
示例#2
0
        public void TakeDamage(GameObject instigator, float damage)
        {
            //print(gameObject.name + " took damage: " + damage);

            healthPoints.value = Mathf.Max(healthPoints.value - damage, 0);

            takeDamage.Invoke(damage);

            if (healthPoints.value == 0)
            {
                onDie.Invoke();
                Die();

                //only load End Screen if the player dies

                if (this.tag == "Player")
                {
                    StartCoroutine(LoadEndScreen(2));
                }
                else
                {
                    //Get XP from Basestats
                    AwardExperience(instigator);
                }
            }
        }
        public bool TakeDamage(float damage, bool isCrit = false, bool isBlockable = true)
        {
            if (isInvulnerable)
            {
                return(false);
            }

            if (checkForBlock && guard != null)
            {
                // check if player is blocking
                if (IsBlocking(isBlockable) && isBlockable)
                {
                    // reduce damage, GuardController displays guard message and reflect damage
                    float damageReduction = baseStats.GetStat(Stat.BlockAmount);
                    damage = Mathf.Max(damage - damageReduction, 0);
                }
            }
            healthPoints.value = Mathf.Max(healthPoints.value - damage, 0);

            if (damage > 0)
            {
                takeDamage.Invoke(damage, isCrit);
            }

            if (healthPoints.value == 0)
            {
                Die();
            }

            return(damage > 0);
        }
        public void TakeDamage(float damage)
        {
            _currentHealth -= damage;

            // Health is empty
            if (_currentHealth <= 0)
            {
                DeathEvent?.Invoke(Mathf.Abs(_currentHealth));
                deathEvent.Invoke();
            }

            _currentHealth = Mathf.Clamp(_currentHealth, 0f, _health);

            TakeDamageEvent?.Invoke(damage);

            if (_currentHealth <= 0)
            {
                switch (_onDeath)
                {
                case DeathType.Disable:
                    _rootObject.SetActive(false);
                    break;

                case DeathType.Destroy:
                    Destroy(_rootObject);
                    break;
                }
            }
        }
 public void TakeDamage(int damage)
 {
     TakeDamageEvent?.Invoke(damage); // delegate invokation
     m_currentHealth -= damage;
     if (m_currentHealth <= 0)
     {
         Die();
     }
 }
 public virtual void TakeDamage(GameObject instigator, float damage)
 {
     health = Mathf.Max(health - damage, 0);
     if (health > 0)
     {
         onDamage.Invoke(damage);
     }
     CheckHealthPoint(instigator);
 }
示例#7
0
 public void TakeDamage(int amount)
 {
     health = Mathf.Clamp(health - (amount - (amount * Controller.instance.equpimentXar.totalArmor * 2) / 100), 0, healthMax);
     TakeDamageEvent?.Invoke(this, EventArgs.Empty);
     OnHealthChanged?.Invoke(this, EventArgs.Empty);
     if (health <= 0)
     {
         HealthDownToZero?.Invoke(this, EventArgs.Empty);
     }
 }
示例#8
0
 public void TakeDamage(int damage)
 {
     TakeDamageEvent?.Invoke(damage);
     // Reduce the health of the island;
     m_CurrentHealth -= damage;
     if (m_CurrentHealth <= 0)
     {
         Die();
     }
 }
示例#9
0
 public void TakeDamage(GameObject instigator, float damage)
 {
     healthPoints.value = Mathf.Max(healthPoints.value - damage, 0);
     takeDamageUnityEvent.Invoke(damage);
     if (healthPoints.value == 0 && !isDead)
     {
         Die();
         AwardExperience(instigator);
     }
 }
示例#10
0
 public void TakeDamage(GameObject instigator, float damage)
 {
     healthPoints.value = Mathf.Max(healthPoints.value - damage, 0);
     takeDamage.Invoke(damage);
     if (healthPoints.value == 0)
     {
         onDie.Invoke();
         AwardExperience(instigator);
         Die();
     }
 }
示例#11
0
 public void TakeDamage(GameObject instigator, float damage)
 {
     print(gameObject.name + " got hit by " + damage + "hp.");
     healthPoints.value = Mathf.Max(healthPoints.value - damage, 0);
     GetComponent <Animator>().SetTrigger("hit");
     takeDamage.Invoke(Mathf.Ceil(damage));
     if (healthPoints.value == 0)
     {
         GetComponent <Animator>().ResetTrigger("hit");
         Die();
         AwardExperience(instigator);
     }
 }
示例#12
0
        public void TakeDamange(GameObject instigator, float damage_taken)
        {
            points_of_health.value = Mathf.Max(points_of_health.value - damage_taken, 0);

            takeDamage.Invoke(damage_taken);

            if (!is_dead && points_of_health.value <= 0)
            {
                onDie.Invoke();
                Die();
                AwardExperience(instigator);
            }
        }
示例#13
0
    public void Damage(float damage)
    {
        health = Mathf.Max(health - damage, 0);
        takeDamage.Invoke(damage);

        print(health);

        if (health == 0 && !dead)
        {
            //die.Invoke();
            Die();
        }
    }
示例#14
0
 public void TakeDamage(GameObject instigator, float damage)
 {
     healthPoints.value = Mathf.Max(healthPoints.value - damage, 0); //returns whichever is greatest of these nums
     if (healthPoints.value == 0)
     {
         onDie.Invoke(); // invokes the onDie unity event that we declared
         Die();
         AwardExperience(instigator);
     }
     else
     {
         takeDamage.Invoke(damage); //triggers all functions specified in unity inspector
     }
 }
示例#15
0
 public void TakeDamage(GameObject instigator, float damage)
 {
     if (!IsDead)
     {
         takeDamage.Invoke(damage);
         healthPoints   -= damage;
         this.instigator = instigator;
         if (CheckIfDead())
         {
             AwardExperience();
             onDie.Invoke();
         }
     }
 }
示例#16
0
 public void TakeDamage(GameObject instigator, float damage)
 {
     healthPoints.value = Mathf.Max(healthPoints.value - damage, 0);
     if (healthPoints.value == 0 && isDead == false)
     {
         Death.Invoke();
         Die();
         AwardExperience(instigator);
     }
     else
     {
         takeDamage.Invoke(damage);
     }
 }
示例#17
0
        //TakeDamage method'u Figther Component icinde Hit Animation method'u icinde cagiriliyor
        public void TakeDamage(GameObject instigator, float damage)
        {
            _healthPoints.Value = Mathf.Max(_healthPoints.Value - damage, 0);
            Debug.Log("Health:" + _healthPoints.Value + " Owns: " + transform.name);

            takeDamage.Invoke(damage);

            if (_healthPoints.Value <= 0 && !_isDeath)
            {
                onDie.Invoke();
                TriggerDeathAndAnimation();
                RewardExperience(instigator);
            }
        }
示例#18
0
 public void TakeDamage(GameObject instigator, float damage)
 {
     healthPoints.value = Mathf.Max(healthPoints.value - damage, 0);
     if (IsDead())
     {
         onDie.Invoke();
         AwardExperience(instigator);
     }
     else
     {
         takeDamage.Invoke(damage);
     }
     UpdateState();
 }
示例#19
0
        public void TakeDamage(GameObject instigator, float damage)
        {
            print(gameObject.name + "took damage: " + damage);

            healthPoints.value = Mathf.Max(healthPoints.value - damage, 0);
            takeDamage.Invoke(damage);

            if (healthPoints.value <= 0)
            {
                Die();
                AwardExperience(instigator);
                onDeath.Invoke();
            }
        }
示例#20
0
 public void TakeDamage(float damageValue)
 {
     if (!isDead)
     {
         healthPoints.value = Mathf.Max(healthPoints.value - damageValue, 0);
         takeDamage.Invoke(damageValue);
         if (healthPoints.value == 0)
         {
             onDie?.Invoke();
             ExperienceReward();
             Death();
         }
     }
 }
示例#21
0
 public void TakeDamage(GameObject instigator, float damage)
 {
     SetHealthPoints(Mathf.Max(healthPoints.value - damage, 0));
     if (healthPoints.value == 0)
     {
         Die();
         OnDie.Invoke();
         AwardExperience(instigator);
     }
     else
     {
         takeDamage.Invoke(damage);
     }
 }
示例#22
0
 public void TakeDmg(float dmg, GameObject instigator)
 {
     currentHealth = currentHealth - dmg;
     if (currentHealth <= 0 && !isDead)
     {
         myAnim.ResetTrigger("resurrect");
         Die();
         GiveEXP(instigator);
     }
     else
     {
         takeDamage.Invoke(dmg);
     }
 }
示例#23
0
    public void TakeDamage(GameObject initiator, float damage)
    {
        health = Mathf.Max(health - damage, 0);

        if (health == 0)
        {
            deathEvent.Invoke();
            Death();
            AwardXP(initiator);
        }
        else
        {
            takeDamage.Invoke(damage);
        }
    }
示例#24
0
        public void TakeDamage(GameObject instigator, float damage)
        {
            healthPoints.value = Mathf.Max(healthPoints.value - damage, 0); // Health cannot get below zero.

            if (healthPoints.value == 0)
            {
                onDie.Invoke();
                Die();
                AwardExperience(instigator);
            }
            else
            {
                takeDamage.Invoke(damage);
            }
        }
示例#25
0
        public void TakeDamage(GameObject instigator, float amount)
        {
            _health.value = Mathf.Max(_health.value - amount, 0);

            if (_health.value == 0)
            {
                onDie?.Invoke();
                Die();
                AwardExperience(instigator);
            }
            else
            {
                takeDamage?.Invoke(amount);
            }
        }
        public void TakeDamage(float damage)
        {
            m_Hp -= damage;

            if (m_Hp <= 0)
            {
                //사망
                m_OnDie.Invoke();
            }
            else
            {
                //데미지 처리
                m_OnTakeDamage.Invoke(damage);
            }
        }
示例#27
0
 public void TakeDamage(GameObject instigator, float damage)
 {
     if (IsAlive)
     {
         HealthPoints = Mathf.Max(HealthPoints - damage, 0);
         //Debug.Log(name + " TakeDamage Form " + instigator.name);
         takeDamageEvent.Invoke(damage);
         if (IsDead)
         {
             onDie.Invoke();
         }
         //takeDamageDelegate();
         DeathCheack(instigator);
     }
 }
示例#28
0
        public void  TakeDamage(GameObject instigator, float damage)
        {
            print(gameObject.name + " took damage " + damage);
            hitPoint.value = Mathf.Max(hitPoint.value - damage, 0);

            if (hitPoint.value == 0 && !alreadyDead)
            {
                Die();
                AwardExperience(instigator);
            }
            else
            {
                takeDamage.Invoke(damage);
            }
        }
示例#29
0
        public void TakeDamage(GameObject instigator, float damage)
        {
            bool isDead = false;

            Debug.Log(gameObject.name + " took damage of " + damage);

            health.value = Mathf.Max(health.value - damage, 0);
            takeDamage.Invoke(damage);
            if (health.value == 0 && _isDead == false)
            {
                onDie.Invoke();
                Die();
                AwardExperience(instigator);
            }
        }
示例#30
0
        public void TakeDamage(GameObject instigator, float damage)
        {
            _healthPoints.value = Mathf.Max(CurrentHealth - damage, 0);

            if (Mathf.Abs(CurrentHealth) < Mathf.Epsilon)
            {
                onDie.Invoke();
                Die();
                AwardExperience(instigator);
            }
            else
            {
                takeDamage.Invoke(damage);
            }
        }