Esempio n. 1
0
 /// <summary>
 /// 执行DOT效果
 /// </summary>
 /// <param name="index"></param>
 public void ExeCountEndState(int index)
 {
     foreach (State s in state)
     {
         if (s.type != StateType.DamageOverTime && s.type != StateType.HealOverTime)
         {
             continue;
         }
         string text = string.Format("因为{0}的效果!", s.name);
         if (s.type == StateType.DamageOverTime)
         {
             if (s.times == 0 && s.counts == 0)
             {
                 continue;
             }
             if (s.times > 0)
             {
                 s.times--;
             }
             MyDraw.DrawBattleMessage(text);
             if (!IsInvincible())
             {
                 GetDamage(s.damage, index);
             }
         }
     }
 }
Esempio n. 2
0
 private void DrawParty()
 {
     for (int i = 0; i < players.Count; i++)
     {
         MyDraw.DrawChoiceText(i, players[i].Name, textPos[i]);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// 绘制玩家的所有技能名
 /// </summary>
 private void DrawPlayerSkills()
 {
     for (int i = 0; i < players[actionIndex].skill.Count; i++)
     {
         MyDraw.DrawChoiceText(i, players[actionIndex].skill[i].name, textPos[i]);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// 执行HOT效果
 /// </summary>
 /// <param name="index"></param>
 public void ExeCountStartState(int index)
 {
     foreach (State s in state)
     {
         if (s.type != StateType.DamageOverTime && s.type != StateType.HealOverTime)
         {
             continue;
         }
         string text = string.Format("因为{0}的效果!", s.name);
         if (s.type == StateType.HealOverTime)
         {
             if (s.times == 0 && s.counts == 0)
             {
                 continue;
             }
             if (s.times > 0)
             {
                 s.times--;
             }
             MyDraw.DrawBattleMessage(text);
             if (!IsForbidHeal())
             {
                 GetRecover(s.hprecover, index);
             }
         }
     }
 }
Esempio n. 5
0
        /// <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());
        }
Esempio n. 6
0
 /// <summary>
 /// 绘制怪物的名字
 /// </summary>
 private void DrawEnemy()
 {
     for (int i = 0; i < enemys.Count; i++)
     {
         MyDraw.DrawChoiceText(i, enemys[i].Name, textPos[i]);
     }
 }
Esempio n. 7
0
 private void EnemyAction()
 {
     for (int i = 0; i < enemys.Count; i++)
     {
         if (enemys[i].Hp == 0 || enemys[i].IsDizzy())
         {
             continue;
         }
         Skill temp = enemys[i].GetRandomSkill(enemys[i], enemys, gameCounts);
         if (temp.targetType == TargetType.Self)
         {
             temp.UseSkillSingle(enemys[i], i, enemys[i], i);
         }
         if (temp.targetType == TargetType.EnemySingle)
         {
             int target = GetRandomAttackerTarget(enemys[i], temp, players);
             //处理嘲讽状态
             for (int j = 0; j < players.Count; j++)
             {
                 double tauntRatio = players[j].IsTaunt();
                 if (players[j].Hp > 0 && tauntRatio != -1.0)
                 {
                     if (tauntRatio > Program.random.NextDouble())
                     {
                         target = j;
                         MyDraw.DrawBattleMessageDelay(string.Format("{0}处于嘲讽状态下,敌人的攻击转了过去。", players[j].Name));
                     }
                     break;
                 }
             }
             temp.UseSkillSingle(enemys[i], i, players[target], target);
         }
         if (temp.targetType == TargetType.EnemyMulti)
         {
             temp.UseSkillMulti(enemys[i], i, players);
         }
         if (temp.targetType == TargetType.PartySingle)
         {
             int target = 0;
             if (temp.type == SkillType.Heal)
             {
                 target = GetHealTarget(temp, enemys);
             }
             else
             {
                 target = GetRandomAttackerTarget(enemys[i], temp, enemys);
             }
             temp.UseSkillSingle(enemys[i], i, enemys[target], target);
         }
         if (temp.targetType == TargetType.PartyMulti)
         {
             temp.UseSkillMulti(enemys[i], i, enemys);
         }
     }
 }
Esempio n. 8
0
 /// <summary>
 /// 绘制游戏场景、人物
 /// </summary>
 public void DrawBattleField()
 {
     for (int i = 0; i < players.Count; i++)
     {
         MyDraw.DrawCharacterInfo(players[i], i);
     }
     for (int j = 0; j < enemys.Count; j++)
     {
         MyDraw.DrawCharacterInfo(enemys[j], j);
     }
 }
Esempio n. 9
0
        /// <summary>
        /// 设置当前玩家拥有的所有skill的名称长度形成的数组,后续用于计算显示技能的位置
        /// </summary>
        private void SetSkillPos()
        {
            textPos.Clear();
            int len = 0;

            for (int i = 0; i < players[actionIndex].skill.Count; i++)
            {
                textPos.Add(len);
                len += MyDraw.GetLength((1 + i) + "." + players[actionIndex].skill[i].name + "  ");
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 为了一行显示所有怪物的名字,这里先计算好每个名字的长度
        /// </summary>
        private void SetEnemyPos()
        {
            textPos.Clear();
            int len = 0;

            for (int i = 0; i < enemys.Count; i++)
            {
                textPos.Add(len);
                len += MyDraw.GetLength((1 + i) + "." + enemys[i].Name + "  ");
            }
        }
Esempio n. 11
0
        private void SetPartyPos()
        {
            textPos.Clear();
            int len = 0;

            for (int i = 0; i < players.Count; i++)
            {
                textPos.Add(len);
                len += MyDraw.GetLength((1 + i) + "." + players[i].Name + "  ");
            }
        }
Esempio n. 12
0
        /// <summary>
        /// 等待用户选择技能,选择不同的技能,会显示对应的技能介绍
        /// </summary>
        /// <param name="b"></param>
        /// <returns></returns>
        public int GetSkillChoice(BaseCharacter b)
        {
            int temp = 0;

            //默认显示第一个技能
            MyDraw.DrawChoiced(temp, b.skill[temp].name, textPos[temp]);
            MyDraw.DrawChoiceInfo(b.skill[temp]);
            bool enter = false;

            while (!enter)
            {
                ConsoleKeyInfo key = Console.ReadKey(true);
                //选择←
                if (key.Key == ConsoleKey.LeftArrow)
                {
                    if (temp > 0)
                    {
                        //清空技能介绍
                        MyDraw.ClearLine(21);
                        //显示对应技能选中的颜色效果
                        MyDraw.DrawChoiceText(temp, b.skill[temp].name, textPos[temp]);
                        temp = temp - 1;
                        //显示左边的技能和对应介绍
                        MyDraw.DrawChoiced(temp, b.skill[temp].name, textPos[temp]);
                        MyDraw.DrawChoiceInfo(b.skill[temp]);
                    }
                }
                else if (key.Key == ConsoleKey.RightArrow)
                {
                    if (temp < textPos.Count - 1)
                    {
                        MyDraw.ClearLine(21);
                        MyDraw.DrawChoiceText(temp, b.skill[temp].name, textPos[temp]);
                        temp = temp + 1;
                        MyDraw.DrawChoiced(temp, b.skill[temp].name, textPos[temp]);
                        MyDraw.DrawChoiceInfo(b.skill[temp]);
                    }
                }
                else if (key.Key == ConsoleKey.Enter)
                {
                    if (b.skill[temp].CanUseSkill(b))
                    {
                        //选中技能之后,清楚技能信息
                        MyDraw.ClearChoiceText();
                        break;
                    }
                }
            }

            return(temp);
        }
Esempio n. 13
0
        public int GetPartyChoice()
        {
            int temp = 0;

            MyDraw.DrawChoiced(temp, players[temp].Name, textPos[temp]);
            bool enter = false;

            while (!enter)
            {
                ConsoleKeyInfo key = Console.ReadKey(true);
                if (key.Key == ConsoleKey.LeftArrow)
                {
                    if (temp > 0)
                    {
                        MyDraw.ClearLine(21);
                        MyDraw.DrawChoiceText(temp, players[temp].Name, textPos[temp]);
                        temp = temp - 1;
                        MyDraw.DrawChoiced(temp, players[temp].Name, textPos[temp]);
                    }
                }
                else if (key.Key == ConsoleKey.RightArrow)
                {
                    if (temp < textPos.Count - 1)
                    {
                        MyDraw.ClearLine(21);
                        MyDraw.DrawChoiceText(temp, players[temp].Name, textPos[temp]);
                        temp = temp + 1;
                        MyDraw.DrawChoiced(temp, players[temp].Name, textPos[temp]);
                    }
                }
                else if (key.Key == ConsoleKey.Enter)
                {
                    if (players[temp].CanBeTarget(tempSkill))
                    {
                        MyDraw.ClearChoiceText();
                        break;
                    }
                    else
                    {
                        MyDraw.DrawBattleMessage("无法选择已经死亡的目标,请重新选择");
                    }
                }
                else if (key.Key == ConsoleKey.Escape)
                {
                    MyDraw.ClearLine(1);
                    return(-1);
                }
            }
            return(temp);
        }
Esempio n. 14
0
 /// <summary>
 /// 判断某个角色是否可以使用技能
 /// </summary>
 /// <param name="attacker"></param>
 /// <returns></returns>
 public bool CanUseSkill(BaseCharacter attacker)
 {
     if (attacker.Hp <= hpCost || attacker.Mp < mpCost)
     {
         MyDraw.DrawBattleMessage("无法使用技能:Hp或者mp不满足技能的最小消耗!");
         return(false);
     }
     if (attacker.IsSilence() && type != SkillType.NormalAttack)
     {
         MyDraw.DrawBattleMessage(attacker.Name + " 无法使用技能: 被沉默了!");
         return(false);
     }
     return(true);
 }
Esempio n. 15
0
 /// <summary>
 /// 检查游戏是否已经结束
 /// </summary>
 /// <returns></returns>
 private bool IsGameOver()
 {
     if (IsAllDead(enemys))
     {
         MyDraw.DrawBattleMessage("敌人全灭,玩家胜利!");
         return(true);
     }
     if (IsAllDead(players))
     {
         MyDraw.DrawBattleMessage("玩家全灭,战斗失败!");
         return(true);
     }
     return(false);
 }
Esempio n. 16
0
        /// <summary>
        /// 移除一个状态
        /// </summary>
        /// <param name="s"></param>
        public void RemoveState(State s)
        {
            int i = 0;

            for (; i < state.Count; i++)
            {
                if (state[i].name == s.name && state[i].skillName == s.skillName)
                {
                    state[i]?.RemoveState(this);
                    state.RemoveAt(i);
                    MyDraw.DrawBattleMessageDelay(Name + "失去了" + s.name + "状态");
                    break;
                }
            }
        }
Esempio n. 17
0
 /// <summary>
 /// 是否被嘲讽
 /// </summary>
 /// <returns></returns>
 public double IsTaunt()
 {
     foreach (State s in state)
     {
         if (s.type == StateType.Taunt)
         {
             MyDraw.DrawBattleMessageDelay(Name + "处于" + s.name + " 嘲讽状态中!");
             if (s.times > 0)
             {
                 s.times -= 1;
             }
             return(s.ratio);
         }
     }
     return(-1.0);
 }
Esempio n. 18
0
        /// <summary>
        /// 清理角色的次数和回合数为一的状态0
        /// </summary>
        public void CleanUpState()
        {
            List <int> list = new List <int>();

            for (int i = state.Count - 1; i >= 0; i--)
            {
                if (state[i].counts == 0 && state[i].times == 0)
                {
                    list.Add(i);
                }
            }
            for (int i = 0; i < list.Count; i++)
            {
                string text = string.Format("{0}失去了{1}状态", Name, state[list[i]].name);
                MyDraw.DrawBattleMessageDelay(text);
                state.RemoveAt(list[i]);
            }
        }
Esempio n. 19
0
        /// <summary>
        /// 添加一个状态
        /// </summary>
        /// <param name="s"></param>
        public void AddState(State s)
        {
            int i = 0;

            for (; i < state.Count; i++)
            {
                if (state[i].name == s.name && state[i].skillName == s.skillName)
                {
                    state[i].times  = s.times;
                    state[i].counts = s.counts;
                    MyDraw.DrawBattleMessageDelay(Name + "的" + s.name + "状态持续时间延长!");
                    return;
                }
            }
            s.AddState?.Invoke(this);
            state.Add(s);
            MyDraw.DrawBattleMessageDelay(Name + "获得了" + s.name + "状态");
        }
Esempio n. 20
0
        /// <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);
        }
Esempio n. 21
0
        /// <summary>
        /// 判断角色是否具有物理反射
        /// </summary>
        /// <returns></returns>
        public bool IsPhysicalReflect()
        {
            bool temp = false;

            foreach (State s in state)
            {
                if (s.type == StateType.PhysicalReflect)
                {
                    MyDraw.DrawBattleMessageDelay(Name + " 攻击被弹回: 处于物理反射状态!");
                    if (s.times > 0)
                    {
                        s.times -= 1;
                    }
                    temp = true;
                }
            }
            if (temp)
            {
                CleanUpState();
            }
            return(temp);
        }
Esempio n. 22
0
        /// <summary>
        /// 判断角色是否具有魔法反射
        /// </summary>
        /// <returns></returns>
        public bool IsMagicReflect()
        {
            bool temp = false;

            foreach (State s in state)
            {
                if (s.type == StateType.MagicReflect)
                {
                    MyDraw.DrawBattleMessageDelay(Name + " 魔法被弹回:处于魔法反射状态");
                    if (s.times > 0)
                    {
                        s.times -= 1;
                    }
                    temp = true;
                }
            }
            if (temp)
            {
                CleanUpState();
            }
            return(temp);
        }
Esempio n. 23
0
        public bool IsDizzy()
        {
            bool temp = false;

            foreach (State s in state)
            {
                if (s.type == StateType.Dizzy)
                {
                    MyDraw.DrawBattleMessageDelay(Name + "处于" + s.name + " 混乱状态中,无法行动!");
                    if (s.times > 0)
                    {
                        s.times -= 1;
                    }
                    temp = true;
                }
            }
            if (temp)
            {
                CleanUpState();
            }
            return(temp);
        }
Esempio n. 24
0
        public bool IsForbidHeal()
        {
            bool temp = false;

            foreach (State s in state)
            {
                if (s.type == StateType.ForbidHeal)
                {
                    MyDraw.DrawBattleMessageDelay(Name + "处于" + s.name + "状态中,无法恢复生命值!");
                    if (s.times > 0)
                    {
                        s.times -= 1;
                    }
                    temp = true;
                }
            }
            if (temp)
            {
                CleanUpState();
            }
            return(temp);
        }
Esempio n. 25
0
        public bool IsSilence()
        {
            bool temp = false;

            foreach (State s in state)
            {
                if (s.type == StateType.Silence)
                {
                    MyDraw.DrawBattleMessageDelay(Name + " 无法释放技能:处于沉默状态!");
                    if (s.times > 0)
                    {
                        s.times -= 1;
                    }
                    temp = true;
                }
            }
            if (temp)
            {
                CleanUpState();
            }
            return(temp);
        }
Esempio n. 26
0
 public void BattleRun()
 {
     while (true)
     {
         actionIndex      = 0;
         chooseEnemyIndex = 0;
         MyDraw.DrawCounts(gameCounts);
         ExeStateAtCountStart();
         PlayerAction();
         EnemyAction();
         ExeStateAtCountEnd();
         StateCountDec();
         if (IsGameOver())
         {
             break;
         }
         gameCounts++;
         ClearUpState();
         MyDraw.DrawIntroText("按任意建进入下一回合");
         Console.ReadKey(true);
     }
 }
Esempio n. 27
0
        ///是否具有无敌状态
        public bool IsInvincible()
        {
            bool temp = false;

            foreach (State s in state)
            {
                if (s.type == StateType.Invincible)
                {
                    MyDraw.DrawBattleMessageDelay(Name + " 伤害无效: 当前无敌!");
                    if (s.times > 0)
                    {
                        s.times -= 1;
                    }
                    temp = true;
                }
            }
            if (temp)
            {
                CleanUpState();
            }
            return(temp);
        }
Esempio n. 28
0
        public bool IsRevive()
        {
            bool temp = false;

            foreach (State s in state)
            {
                if (s.type == StateType.Revive)
                {
                    MyDraw.DrawBattleMessageDelay(Name + "处于复活状态,重新恢复!");
                    Hp = s.hprecover;
                    if (s.times > 0)
                    {
                        s.times -= 1;
                    }
                    temp = true;
                }
            }
            if (temp)
            {
                CleanUpState();
            }
            return(temp);
        }
Esempio n. 29
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);
 }
Esempio n. 30
0
        /// <summary>
        /// 玩家开始行动
        /// </summary>
        private void PlayerAction()
        {
            for (int i = 0; i < players.Count; i++)
            {
                if (players[i].Hp <= 0 || players[i].IsDizzy())
                {
                    //混乱的,也不能行动
                    continue;
                }
                actionIndex = i;
                textPos.Clear();
                SetSkillPos();
                DrawPlayerSkills();
                MyDraw.DrawIntroText($"当前回合为{players[actionIndex].Name}行动了,请选择指令:");
                tempSkill = players[actionIndex].skill[GetSkillChoice(players[actionIndex])];
                MyDraw.DrawBattleMessage(players[actionIndex].Name + "选择了技能 " + tempSkill.name);
                //技能一共作用对象为5种:单个敌人、多个敌人、单个队友、多个队友、只能自身

                if (tempSkill.targetType == TargetType.EnemySingle)
                {
                    MyDraw.DrawIntroText("请选择目标:");

                    SetEnemyPos();
                    DrawEnemy();

                    chooseEnemyIndex = GetEnemyChoice();
                    if (chooseEnemyIndex == -1)
                    {
                        i--;
                        continue;
                    }
                    tempSkill.UseSkillSingle(players[actionIndex], actionIndex, enemys[chooseEnemyIndex], chooseEnemyIndex);
                }
                if (tempSkill.targetType == TargetType.EnemyMulti)
                {
                    tempSkill.UseSkillMulti(players[actionIndex], actionIndex, enemys);
                }
                if (tempSkill.targetType == TargetType.PartySingle)
                {
                    MyDraw.DrawIntroText("请选择目标:");
                    SetPartyPos();
                    DrawParty();
                    choosePartyIndex = GetPartyChoice();
                    if (choosePartyIndex == -1)
                    {
                        i--;
                        continue;
                    }
                    tempSkill.UseSkillSingle(players[actionIndex], actionIndex, players[choosePartyIndex], choosePartyIndex);
                }
                if (tempSkill.targetType == TargetType.PartyMulti)
                {
                    tempSkill.UseSkillMulti(players[actionIndex], actionIndex, players);
                }
                if (tempSkill.targetType == TargetType.Self)
                {
                    tempSkill.UseSkillSingle(players[actionIndex], actionIndex, players[actionIndex], actionIndex);
                }
                textPos.Clear();
            }
        }