Exemple #1
0
 protected override void OnDamage(NDamageInfo damage, Creature source)
 {
     if (this.AI != null)
     {
         this.AI.OnDamage(damage, source);
     }
 }
Exemple #2
0
        private NDamageInfo CalcSkillDamage(Creature caster, Creature target)
        {
            float ad = this.Define.AD + caster.Attributes.AD * this.Define.ADFactor;
            float ap = this.Define.AP + caster.Attributes.AP * this.Define.APFactor;

            float addmg = ad * (1 - target.Attributes.DEF / (target.Attributes.DEF + 100));
            float apdmg = ad * (1 - target.Attributes.MDEF / (target.Attributes.MDEF + 100));

            float final  = addmg + apdmg;
            bool  isCrit = IsCrit(caster.Attributes.CRI);

            if (isCrit)
            {
                final = final * 2f;//暴击2被伤害
            }
            //随机浮动
            final = final * (float)MathUtil.Random.NextDouble() * 0.1f - 0.05f;
            // final = final * 100;
            NDamageInfo damage = new NDamageInfo();

            damage.entityId = target.entityId;
            damage.Damage   = Math.Max(1, (int)final);
            damage.Crit     = isCrit;
            return(damage);
        }
Exemple #3
0
 internal void OnDamage(NDamageInfo damage, Creature source)
 {
     if (this.ai != null)
     {
         this.ai.OnDamage(damage, source);
     }
 }
Exemple #4
0
 internal void DoDamage(NDamageInfo damage, Creature source)
 {
     this.BattleState    = BattleState.InBattle;
     this.Attributes.HP -= damage.Damage;
     if (this.Attributes.HP <= 0)
     {
         this.IsDeath    = true;
         damage.WillDead = true;
     }
     this.OnDamage(damage, source);
 }
Exemple #5
0
 public void DoDamage(NDamageInfo damage, bool playHurt)
 {
     Debug.LogFormat("DoDamage:{0} DMG:{1}  CRIT:{2}", this.Name, damage.Damage, damage.Crit);
     this.Attributes.HP -= damage.Damage;
     if (playHurt)
     {
         this.PlayAnim("Hurt");
     }
     if (this.Controller != null)
     {
         UIWorldElementManager.Instance.ShowPopupText(PopupType.Damage, this.Controller.GetTransform().position + this.GetPopupOffset(), -damage.Damage, damage.Crit);
     }
 }
Exemple #6
0
        private NDamageInfo CalcBuffDamage(Creature caster)
        {
            float ad = this.Define.AD + caster.Attributes.AD * this.Define.ADFactor;
            float ap = this.Define.AP + caster.Attributes.AP * this.Define.APFactor;

            float addmg = ad * (1 - this.Owner.Attributes.DEF / (this.Owner.Attributes.DEF + 100));
            float apdmg = ap * (1 - this.Owner.Attributes.MDEF / (this.Owner.Attributes.MDEF + 100));

            float       final  = addmg + apdmg;
            NDamageInfo damage = new NDamageInfo();

            damage.entityId = this.Owner.entityId;
            damage.Damage   = Math.Max(1, (int)final);
            return(damage);
        }
Exemple #7
0
        void HitTarget(Creature target, NSkillHitInfo hit)
        {
            if (this.Define.CastTarget == Common.Battle.TargetType.Self && (target != Context.Caster))
            {
                return;
            }
            else if (target == Context.Caster)
            {
                return;
            }
            NDamageInfo damage = this.CalcSkillDamage(Context.Caster, target);

            Log.InfoFormat("Skill{0}.HitTarget[{1}] Damage;{2} Crit:[3]", this.Define.Name, target.Name, damage.Damage, damage.Crit);
            target.DoDamage(damage, Context.Caster);
            hit.Damages.Add(damage);
            this.AddBuff(TriggerType.SkillHit, target);
        }
Exemple #8
0
        private void DeBuffDamage()
        {
            this.hit++;
            NDamageInfo damage = this.CalcBuffDamage(Context.Caster);

            Log.InfoFormat("Buff[{0}].DoBuffDamage[{1}] Damage:{2} Crit:{3}", this.Define.Name, this.Owner.Name, damage.Damage, damage.Crit);
            this.Owner.DoDamage(damage, Context.Caster);
            NBuffInfo buff = new NBuffInfo()
            {
                buffId   = this.BuffId,
                buffType = this.Define.ID,
                casterId = this.Context.Caster.entityId,
                ownerId  = this.Owner.entityId,
                Action   = BuffACTION.Hit,
            };

            Context.Battle.AddBuffAction(buff);
        }
Exemple #9
0
 internal void OnDamage(NDamageInfo damage, Creature source)
 {
     this.target = source;
 }
Exemple #10
0
 protected virtual void OnDamage(NDamageInfo damage, Creature source)
 {
 }