Beispiel #1
0
 /// <summary>
 /// 释放单体技能
 /// </summary>
 /// <param name="attacker"></param>
 /// <param name="attack_index"></param>
 /// <param name="target"></param>
 public void UseSkillSingle(BaseCharacter attacker, int att_index, BaseCharacter target, int tar_index)
 {
     attacker.Hp -= hpCost;
     attacker.Mp -= mpCost;
     UseSkill(attacker, att_index, target, tar_index);
     if (type == SkillType.Damage)
     {
         if (skillDamage != null)
         {
             if (damageType == DamageType.Magic)
             {
                 attacker.IncreaseStateDec(StateType.MagicDamageIncrease);
                 target.IncreaseStateDec(StateType.MagicBeDamageIncrease);
             }
             else if (damageType == DamageType.Physical)
             {
                 attacker.IncreaseStateDec(StateType.PhysicalDamageIncrease);
                 target.IncreaseStateDec(StateType.PhysicalBeDamageIncrease);
             }
         }
     }
     MyDraw.DrawState(attacker, att_index);
     MyDraw.DrawState(target, tar_index);
 }
Beispiel #2
0
        /// <summary>
        /// 使用技能的最底层实现方法,用于其他方法调用
        /// </summary>
        /// <param name="attacker"></param>
        /// <param name="attack_index"></param>
        /// <param name="target"></param>
        /// <param name="target_index"></param>
        private void UseSkill(BaseCharacter attacker,
                              int attack_index,
                              BaseCharacter target,
                              int target_index)
        {
            //过程中生存游戏提示信息的文本
            string text       = "";
            int    tempdamage = 0;

            MyDraw.DrawCharacterInfo(attacker, attack_index);
            text = string.Format("{0}对{1}施放了{2}", attacker.Name, target.Name, name);
            MyDraw.DrawBattleMessageDelay(text);
            if (targetType == TargetType.EnemyMulti || targetType == TargetType.EnemySingle)
            {
                if (attacker.type == CharacterType.Player)
                {
                    MyDraw.DrawAttackAnimation(attacker, attack_index, target, target_index);
                }
                else
                {
                    MyDraw.DrawAttackAnimationEnemy(attacker, attack_index, target, target_index);
                }
            }
            //对即时伤害的技能的处理
            if (type == SkillType.Damage || type == SkillType.NormalAttack)
            {
                //获取技能的基础伤害值
                if (skillDamage != null)
                {
                    tempdamage = skillDamage.Invoke(attacker, target);
                    //判断目标是否无敌
                    if (target.IsInvincible())
                    {
                        return;
                    }
                    //判断目标是否具有技能伤害类型对应的反射状态
                    if (damageType == DamageType.Physical)
                    {
                        if (target.IsPhysicalReflect())
                        {
                            if (target.type == CharacterType.Player)
                            {
                                MyDraw.DrawAttackAnimation(target, attack_index, attacker, target_index);
                            }
                            else
                            {
                                MyDraw.DrawAttackAnimationEnemy(target, attack_index, attacker, target_index);
                            }
                            if (attacker.IsInvincible())
                            {
                                return;
                            }
                            else
                            {
                                //获取攻击方的物理攻击加深BUFF并且计算他们的效果
                                tempdamage = attacker.GetIncreaseDamage(tempdamage, StateType.PhysicalDamageIncrease);
                                //因为目标由有物理反射,所以也要计算攻击方自身是否有 受物理攻击加深BUFF
                                tempdamage = attacker.GetIncreaseDamage(tempdamage, StateType.PhysicalBeDamageIncrease);

                                attacker.GetDamage(tempdamage, attack_index);
                                return;
                            }
                        }
                        if (!IsHit(attacker) && noMiss == false)
                        {
                            text = string.Format("{0}未能击中目标!", attacker.Name);
                            MyDraw.DrawBattleMessageDelay(text);
                            return;
                        }
                        if (IsCrit(attacker) || mustCrit == true)
                        {
                            text = string.Format("{0}触发了会心一击!", attacker.Name);
                            MyDraw.DrawBattleMessageDelay(text);
                            tempdamage = tempdamage * 15 / 10;
                        }
                        //获取攻击方的物理攻击加深BUFF并且计算他们的效果
                        tempdamage = attacker.GetIncreaseDamage(tempdamage, StateType.PhysicalDamageIncrease);
                        //计算目标自身是否有 受物理攻击加深BUFF
                        tempdamage = target.GetIncreaseDamage(tempdamage, StateType.PhysicalBeDamageIncrease);
                    }
                    else if (damageType == DamageType.Magic)
                    {
                        if (target.IsMagicReflect())
                        {
                            if (target.type == CharacterType.Player)
                            {
                                MyDraw.DrawAttackAnimation(target, target_index, attacker, attack_index);
                            }
                            else
                            {
                                MyDraw.DrawAttackAnimationEnemy(target, target_index, attacker, attack_index);
                            }
                            if (attacker.IsInvincible())
                            {
                                return;
                            }
                            else
                            {
                                tempdamage = attacker.GetIncreaseDamage(tempdamage, StateType.MagicDamageIncrease);
                                tempdamage = attacker.GetIncreaseDamage(tempdamage, StateType.MagicBeDamageIncrease);
                                attacker.GetDamage(tempdamage, attack_index);
                                return;
                            }
                        }
                        else
                        {
                            tempdamage = attacker.GetIncreaseDamage(tempdamage, StateType.MagicDamageIncrease);
                            tempdamage = target.GetIncreaseDamage(tempdamage, StateType.MagicBeDamageIncrease);
                        }
                    }

                    //进行即时伤害并且生成对应的文字信息
                    for (int t = 0; t < hitTimes; t++)
                    {
                        int realdamage = Convert.ToInt32(tempdamage + tempdamage * Program.random.Next(-dispersion, dispersion) * 0.01);
                        //处理即死效果
                        if (isDeathNow)
                        {
                            if (Program.random.Next(0, 100) < deathRatio)
                            {
                                MyDraw.DrawBattleMessageDelay("触发了即死效果。");
                                realdamage = target.MaxHp;
                            }
                        }
                        if (!target.GetDamage(realdamage, target_index))
                        {
                            break;
                        }
                    }
                }
                //如果技能有特殊效果,执行特殊效果
                if (skillEffect != null)
                {
                    MyDraw.DrawEffectAnimation(target, target_index);
                    skillEffect.Invoke(attacker, target);
                    MyDraw.DrawState(target, target_index);
                }
                return;
            }

            //对即时回复类技能的处理
            if (type == SkillType.Heal)
            {
                if (skillDamage != null)
                {
                    tempdamage = skillDamage.Invoke(attacker, target);
                    if (!target.IsForbidHeal())
                    {
                        target.GetRecover(tempdamage, target_index);
                    }
                }
                if (skillEffect != null)
                {
                    MyDraw.DrawEffectAnimation(target, target_index);
                    skillEffect.Invoke(attacker, target);

                    MyDraw.DrawState(target, target_index);
                }
                return;
            }

            //对状态类技能的处理,主要是Buff,Debuff等
            if (type == SkillType.State)
            {
                if (skillEffect != null)
                {
                    MyDraw.DrawEffectAnimation(target, target_index);
                    skillEffect.Invoke(attacker, target);
                    MyDraw.DrawState(target, target_index);
                }
            }
            return;
        }