/// <summary>
        /// 角色受到伤害
        /// </summary>
        /// <param name="damage"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public bool GetDamage(int damage, int index)
        {
            MyDraw.DrawDamageAnimation(this, index);
            int tempDamage = 0;

            if (Hp >= damage)
            {
                tempDamage = damage;
                Hp        -= damage;
            }
            else
            {
                tempDamage = Hp;
                Hp         = 0;
            }
            string text = string.Format("{0}受到了{1}点伤害", name, tempDamage);

            MyDraw.DrawCharacterInfo(this, index);
            MyDraw.DrawBattleMessageDelay(text);
            if (!IsAlive())
            {
                if (!IsRevive())
                {
                    MyDraw.DrawBattleMessageDelay(name + "死亡了");
                    ResetState();
                }
                MyDraw.DrawCharacterInfo(this, index);
            }
            return(IsAlive());
        }
Пример #2
0
 public void DrawBattleField()
 {
     for (int i = 0; i < heros.Count; i++)
     {
         MyDraw.DrawCharacterInfo(heros[i], i);
     }
     for (int j = 0; j < enemy.Count; j++)
     {
         MyDraw.DrawCharacterInfo(enemy[j], j);
     }
 }
        /// <summary>
        /// 角色受到的恢复量
        /// </summary>
        /// <param name="recover"></param>
        /// <param name="index"></param>
        public void GetRecover(int recover, int index)
        {
            MyDraw.DrawEffectAnimation(this, index);
            int tempRecover = 0;

            if (maxHp <= recover + Hp)
            {
                tempRecover = maxHp - Hp;
                Hp          = maxHp;
            }
            else
            {
                tempRecover = recover;
                Hp         += tempRecover;
            }
            string text = string.Format("{0}恢复了{1}点生命值", name, tempRecover);

            MyDraw.DrawCharacterInfo(this, index);
            MyDraw.DrawBattleMessageDelay(text);
        }
Пример #4
0
        /// <summary>
        /// 创建角色艾露露,治疗
        /// </summary>
        /// <returns></returns>
        public static BaseCharacter CreateCharEruruu()
        {
            BaseCharacter eruruu = new BaseCharacter();

            eruruu.name  = "艾露露";
            eruruu.maxHp = 288;
            eruruu.maxMp = 321;
            eruruu.Hp    = 288;
            eruruu.Mp    = 321;
            eruruu.atk   = 0;
            eruruu.def   = 17;
            eruruu.mat   = 23;
            eruruu.men   = 27;
            eruruu.hit   = 95;
            eruruu.crt   = 10;
            eruruu.level = 5;
            eruruu.type  = CharacterType.Hero;

            Skill herb = CreateHealSkill("草药", 0, 15, 1, 10, TargetType.PartySingle);

            herb.description = "艾露露自制的草药,恢复己方单体生命值。(MP:15)";
            herb.skillDamage = (BaseCharacter attacker, BaseCharacter target) =>
            {
                return(attacker.men * 2);
            };
            eruruu.skill.Add(herb);

            Skill rest = CreateStateSkill("摩洛洛粥", 0, 0, TargetType.Self);

            rest.description = "艾露露为自己准备的家乡的小食,恢复自身的MP值。";
            rest.skillEffect = (BaseCharacter attacker, BaseCharacter target) =>
            {
                int temp = Convert.ToInt32(attacker.men * 1.34);
                if (attacker.Mp + temp > attacker.maxMp)
                {
                    temp = attacker.maxMp - attacker.Mp;
                }
                attacker.Mp += temp;
                MyDraw.DrawCharacterInfo(eruruu, 1);
                MyDraw.DrawBattleMessageDelay(string.Format("艾露露恢复了{0}点魔法值", temp));
            };
            eruruu.skill.Add(rest);

            Skill lilac = CreateHealSkill("花语", 0, 40, 1, 0, TargetType.PartyMulti);

            lilac.description = "艾露露利用山野中的鲜花特质的线香,为己方全体施加生命恢复效果。(MP:40)";
            lilac.skillEffect = (BaseCharacter attacker, BaseCharacter target) =>
            {
                int   tempRecover = Convert.ToInt32(attacker.men * 3.0 / 2);
                State lilacState  = CreateHOTState("花语", 0, 3, tempRecover);
                lilacState.skillName = lilac.name;
                target.AddState(lilacState);
            };
            eruruu.skill.Add(lilac);

            Skill mandara = CreateDamageSkill("毒雾", 0, 30, 1, 0, TargetType.EnemyMulti, DamageType.Magic);

            mandara.description = "艾露露利用山中的毒草制成的迷雾攻击敌方全体,一定概率使得敌方中毒。(MP:30)";
            mandara.skillEffect = (BaseCharacter attacker, BaseCharacter target) =>
            {
                int tempRecover = Convert.ToInt32(target.maxHp * 0.07);
                if (Program.random.Next(0, 100) > 70)
                {
                    State mandaraState = CreateDOTState("中毒", 0, 3, tempRecover);
                    mandaraState.skillName = mandara.name;
                    target.AddState(mandaraState);
                }
            };
            eruruu.skill.Add(mandara);

            Skill callBack = CreateHealSkill("复活", 0, 50, 1, 10, TargetType.PartySingle);

            callBack.description = "艾露露利用流传下来的秘药,复活一名已经阵亡的队友。(MP:50)";
            callBack.canDeath    = true;
            callBack.skillDamage = (BaseCharacter attacker, BaseCharacter target) =>
            {
                return(Convert.ToInt32(target.maxHp * 0.3));
            };
            eruruu.skill.Add(callBack);

            Skill lifeLoop = CreateHealSkill("子守歌", 0, 60, 1, 20, TargetType.PartyMulti);

            lifeLoop.description = "艾露露唱起小时候听过的子守歌,恢复己方全体的生命值。(MP:60)";
            lifeLoop.skillDamage = (BaseCharacter attacker, BaseCharacter target) =>
            {
                return(Convert.ToInt32(attacker.mat * 2.3 + 16));
            };
            eruruu.skill.Add(lifeLoop);

            return(eruruu);
        }
Пример #5
0
        /// <summary>
        /// 释放一个技能
        /// </summary>
        /// <param name="attacker"></param>
        /// <param name="att_index"></param>
        /// <param name="target"></param>
        /// <param name="tar_index"></param>
        private void UseSkill(BaseCharacter attacker, int att_index, BaseCharacter target, int tar_index)
        {
            //过程中生存游戏提示信息的文本
            string text       = "";
            int    tempdamage = 0;

            MyDraw.DrawCharacterInfo(attacker, att_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.Hero)
                {
                    MyDraw.DrawAttackAnimation(attacker, att_index, target, tar_index);
                }
                else
                {
                    MyDraw.DrawAttackAnimationEnemy(attacker, att_index, target, tar_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.Hero)
                            {
                                MyDraw.DrawAttackAnimation(target, tar_index, attacker, att_index);
                            }
                            else
                            {
                                MyDraw.DrawAttackAnimationEnemy(target, tar_index, attacker, att_index);
                            }
                            if (attacker.IsInvincible())
                            {
                                return;
                            }
                            else
                            {
                                //获取攻击者和目标身上的物理伤害加深BUFF并且计算他们的效果
                                tempdamage = attacker.GetIncreaseDamage(tempdamage, StateType.PhysicalDamageIncrease);
                                tempdamage = attacker.GetIncreaseDamage(tempdamage, StateType.PhysicalBeDamageIncrease);
                                attacker.GetDamage(tempdamage, att_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);
                        tempdamage = target.GetIncreaseDamage(tempdamage, StateType.PhysicalBeDamageIncrease);
                    }
                    else if (damageType == DamageType.Magic)
                    {
                        if (target.IsMagicReflect())
                        {
                            if (target.type == CharacterType.Hero)
                            {
                                MyDraw.DrawAttackAnimation(target, tar_index, attacker, att_index);
                            }
                            else
                            {
                                MyDraw.DrawAttackAnimationEnemy(target, tar_index, attacker, att_index);
                            }
                            if (attacker.IsInvincible())
                            {
                                return;
                            }
                            else
                            {
                                //获取攻击者和目标身上的魔法伤害加深BUFF并且计算他们的效果
                                tempdamage = attacker.GetIncreaseDamage(tempdamage, StateType.MagicDamageIncrease);
                                tempdamage = attacker.GetIncreaseDamage(tempdamage, StateType.MagicBeDamageIncrease);
                                attacker.GetDamage(tempdamage, att_index);
                                return;
                            }
                        }
                        else
                        {
                            //获取攻击者和目标身上的魔法伤害加深BUFF并且计算他们的效果
                            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, tar_index))
                        {
                            break;
                        }
                    }
                }
                //如果技能有特殊效果,执行特殊效果
                if (skillEffect != null)
                {
                    MyDraw.DrawEffectAnimation(target, tar_index);
                    skillEffect.Invoke(attacker, target);
                    MyDraw.DrawState(target, tar_index);
                }
                return;
            }

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

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