예제 #1
0
        public void GetMaxDamageNoExceptions(GameObject hitter)
        {
            Vector3 damagePosition    = transform.position;
            float   _damage           = m_baseArmor + m_currentHealth;
            float   _armorMinusDamage = _damage;

            if (m_currentArmor > 0)
            {
                if (m_currentArmor < _armorMinusDamage)
                {
                    _armorMinusDamage -= m_currentArmor;
                    m_currentArmor     = 0;
                }
                else
                {
                    m_currentArmor   -= _armorMinusDamage;
                    _armorMinusDamage = 0;
                }
            }
            m_currentHealth -= _armorMinusDamage;

            DamageController damageTextController = Instantiate(damageTextObject, damagePosition, Quaternion.Euler(0, 0, 0)).GetComponent <DamageController>();

            damageTextController.DamageUpdate(_damage);
            if (gameObject.tag == "Player")
            {
                damageTextController.damageText.color      = new Color(1, 69f / 255f, 69f / 255f, 1);
                damageTextController.transform.localScale += new Vector3(0.2f, 0.2f);
            }

            if (m_currentHealth <= 0)
            {
                m_currentHealth = 0;
                isDamageable    = false;
                SendMessage("Death", SendMessageOptions.DontRequireReceiver);
            }
        }
예제 #2
0
        public void GetDamage(float _damage, Vector3 damagePosition, GameObject hitter)
        {
            if (!isDamageable)
            {
                return;
            }

            Debug.Log(this.name + " Get " + _damage + " Damage!");
            if (tag == "Player")
            {
                _damage = PlayerDamageModify(_damage);
            }


            if (tag == "Player")
            {
                playerBeforeGetDamageListeners.Invoke(_damage);
            }

            float _armorMinusDamage = _damage;

            if (m_currentArmor > 0)
            {
                if (m_currentArmor < _armorMinusDamage)
                {
                    _armorMinusDamage -= m_currentArmor;
                    m_currentArmor     = 0;
                }
                else
                {
                    m_currentArmor   -= _armorMinusDamage;
                    _armorMinusDamage = 0;
                }
            }
            m_currentHealth -= _armorMinusDamage;
            if (tag == "Player")
            {
                playerAfterGetDamageListeners.Invoke(_damage);
                playerHitterListeners.Invoke(hitter);
            }


            DamageController damageTextController = Instantiate(damageTextObject, damagePosition, Quaternion.Euler(0, 0, 0)).GetComponent <DamageController>();

            damageTextController.DamageUpdate(_damage);
            if (gameObject.tag == "Player")
            {
                damageTextController.damageText.color      = new Color(1, 69f / 255f, 69f / 255f, 1);
                damageTextController.transform.localScale += new Vector3(0.2f, 0.2f);
            }

            if (m_currentHealth <= 0)
            {
                m_currentHealth = 0;
                isDamageable    = false;
                SendMessage("Death", SendMessageOptions.DontRequireReceiver);
            }
            else
            {
                getDamageListeners.Invoke(_damage);
            }
        }