Пример #1
0
 static void additems()
 {
     BeforeAttack.additem("Youmuu", (int)ItemId.Youmuus_Ghostblade, Orbwalking.GetRealAutoAttackRange(Player));
     AfterAttack.additem("Tiamat", (int)ItemId.Tiamat_Melee_Only, 250f);
     AfterAttack.additem("Hydra", (int)ItemId.Ravenous_Hydra_Melee_Only, 250f);
     AfterAttack.additem("Bilgewater", (int)ItemId.Bilgewater_Cutlass, 450f, true);
     AfterAttack.additem("BoTRK", (int)ItemId.Blade_of_the_Ruined_King, 450f, true);
 }
Пример #2
0
        protected static bool ProcessBeforeAttack(IAttackable target)
        {
            var args = new BeforeAttackEventArgs(target);

            BeforeAttack.SafeInvoke(args);

            return(!args.IsBlocked);
        }
Пример #3
0
 private void Attack(Character character, Damage damage)
 {
     BeforeAttack?.Invoke(character, damage);
     character.ReceiveDamage(damage);
     AfterAttack?.Invoke(character, damage);
     if (!character.IsAlive)
     {
         OnKill?.Invoke();
     }
 }
Пример #4
0
 public void Attack(Character character, Damage damage)        //, AttackType attackType, int atkPoints)
 {
     BeforeAttack?.Invoke(character, damage);
     character.ReceiveDamage(damage);
     AfterAttack?.Invoke(character, damage);
     if (!character.IsAlive)
     {
         OnEnemyKill?.Invoke();
     }
 }
Пример #5
0
        // 模拟攻击行为的伤害数值,但并不执行攻击行为
        public void SimulateAttackingDamage(Warrior attacker, Warrior target, Warrior[] addtionalTargets, Skill skill, Action <int> onDamage, params string[] flags)
        {
            target.GetPosInMap(out int tx, out int ty); // 检查攻击范围限制
            if (!attacker.InAttackRange(tx, ty))
            {
                return;
            }

            // 整理攻击标记
            var attackFlags = new HashSet <string>();

            attackFlags.UnionWith(flags);
            attackFlags.Add(attacker.AttackingType);

            var addTars = new List <Warrior>();

            if (addtionalTargets != null)
            {
                addTars.AddRange(addtionalTargets);
            }

            // 额外伤害系数
            var multi    = new List <int>();
            var addMulti = new List <int>();

            BeforeAttack?.Invoke(attacker, target, addTars, skill, attackFlags, multi, addMulti);

            if (attackFlags.Contains("CancelAttack")) // 取消攻击
            {
                return;
            }

            // 计算实际伤害
            var damage = CalculateDamage(attacker, target, skill, attackFlags, multi);

            onDamage(damage);
        }
Пример #6
0
        public void Attack(Warrior attacker, Warrior target, Warrior[] addtionalTargets, Skill skill = null, params string[] flags)
        {
            // 在连续指令的情况下,可能条件已经不满足
            if (attacker == null || target == null)
            {
                return;
            }

            // 整理攻击标记
            var attackFlags = new HashSet <string>();

            attackFlags.UnionWith(flags);
            attackFlags.Add(attacker.AttackingType);

            // 额外攻击目标
            var addTars = new List <Warrior>();

            if (addtionalTargets != null)
            {
                addTars.AddRange(addtionalTargets);
            }

            PrepareAttack?.Invoke(attacker, target, addTars, skill, attackFlags);

            if (!attackFlags.Contains("IgnoreAttackRange")) // 可能是无视攻击距离限制的
            {
                target.GetPosInMap(out int tx, out int ty); // 检查攻击范围限制
                if (!attacker.InAttackRange(tx, ty))
                {
                    return;
                }
            }

            // 额外伤害系数
            var multi    = new List <int>();
            var addMulti = new List <int>();

            BeforeAttack?.Invoke(attacker, target, addTars, skill, attackFlags, multi, addMulti);

            // 可能需要取消攻击 或者因为 PatternSkill 导致已经行动过了
            if (attacker.ActionDone || attackFlags.Contains("CancelAttack"))
            {
                return;
            }

            var tars = new List <Warrior>();

            tars.Add(target);
            tars.AddRange(addTars);

            // 计算实际伤害
            var damages = new Dictionary <Warrior, int>();

            foreach (var tar in tars)
            {
                damages[tar] = CalculateDamage(attacker, tar, skill, attackFlags, tar == target ? multi : addMulti);
            }

            // ExtraAttack 不影响行动标记
            if (!attackFlags.Contains("ExtraAttack"))
            {
                Debug.Assert(!attacker.ActionDone, "attacker has already attacted in this round");
                SetActionFlag(attacker, true, true, true);
            }

            // 混乱攻击不计算护盾,其它类型攻击需要先消耗护盾
            var dhps = new Dictionary <Warrior, int>();
            var dess = new Dictionary <Warrior, int>();

            foreach (var tar in tars)
            {
                var damage = damages[tar];
                var dhp    = -damage;
                var des    = 0;
                if (!attackFlags.Contains("chaos") && target.ES > 0)
                {
                    dhp = damage > target.ES ? target.ES - damage : 0;
                    des = damage > target.ES ? 0 : -damage;
                }

                dhps[tar] = dhp;
                dess[tar] = des;
            }

            OnWarriorAttack?.Invoke(attacker, target, addTars, dhps, dess, skill, attackFlags);

            foreach (var tar in tars)
            {
                var dhp = dhps[tar];
                var des = dess[tar];

                if (des != 0)
                {
                    AddES(tar, des);
                }
                if (dhp != 0)
                {
                    AddHP(tar, dhp);
                }
            }

            AfterAttack?.Invoke(attacker, target, addTars, skill, attackFlags);

            return;
        }
Пример #7
0
 public static void OnBeforeAttack(object sender, BeforeAttackEventArgs args)
 {
     BeforeAttack?.Invoke(sender, args);
 }