コード例 #1
0
ファイル: BattleManager.cs プロジェクト: ggwhsd/CSharpStudy
 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);
     }
 }
コード例 #2
0
ファイル: BattleManager.cs プロジェクト: ggwhsd/CSharpStudy
        /// <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();
            }
        }