示例#1
0
        public virtual void ReceiveDamage(Vector3 Direction, GameObject Damager, StatModifier modifier, bool isCritical, bool react, bool damageeMult)
        {
            Stat st = stats.Stat_Get(modifier.ID);

            if (st != null && !st.IsInmune)
            {
                SetDamageable(Direction, Damager);
                Root?.SetDamageable(Direction, Damager);                                 //Send the Direction and Damager to the Root

                if (isCritical)
                {
                    events.OnCriticalDamage.Invoke();
                    Root?.events.OnCriticalDamage.Invoke();
                }

                if (!damageeMult)
                {
                    modifier.Value *= multiplier;                                                         //Apply to the Stat modifier a new Modification
                }
                events.OnReceivingDamage.Invoke(modifier.Value);
                Root?.events.OnReceivingDamage.Invoke(modifier.Value);

                LastDamage = new DamageData(Damager, modifier);
                if (Root)
                {
                    Root.LastDamage = LastDamage;
                }

                modifier.ModifyStat(st);

                if (react)
                {
                    reaction?.React(character);            //Let the Damagee to apply a reaction
                }
                //Debug.Log("DamageReceived" + modifier.Value.Value);
                //Debug.Log("Damager" + Damager);
            }
        }