Exemple #1
0
 private void TestButton_Click(object sender, EventArgs e)
 {
     PlayerTeam pt = new PlayerTeam();
     MonsterTeam mt = new MonsterTeam();
     Combat combat = new Combat(pt, mt);
     this.TestTextBox.Text = combat.BeginCombat();
 }
Exemple #2
0
 /// <summary>
 /// 队伍执行下一个动作
 /// </summary>
 /// <param name="turn">当前回合数</param>
 /// <param name="enemy">敌人(玩家队伍)</param>
 /// <returns>本次行动日志</returns>
 public string DoNextAction(int turn, PlayerTeam enemy)
 {
     Unit nextActionUnit = null;
     double maxValue = 0;
     double randValue = 0;
     int count = 0;
     //根据队伍行动状态选取下一个行动单位并执行动作
     if (this.ActionState == MonsterActionState.AllReady)
     {
         //随机选取未行动的Boss
         for (int i = 0; i < Bosses.Length; i++)
         {
             if (Bosses[i].ActionState == UnitActionState.Ready)
             {
                 count++;
                 randValue = RandomBuilder.GetDouble();
                 if (randValue > maxValue)
                 {
                     nextActionUnit = Bosses[i];
                     maxValue = randValue;
                 }
             }
         }
         //最后一个Boss行动,修改队伍行动状态
         if (count <= 1)
         {
             this.ActionState = MonsterActionState.BossDone;
         }
     }
     //无Boss行动 选取精英行动
     if (nextActionUnit == null && this.ActionState == MonsterActionState.BossDone)
     {
         //随机选取未行动的精英
         for (int i = 0; i < Elites.Length; i++)
         {
             if (Elites[i].ActionState == UnitActionState.Ready)
             {
                 count++;
                 randValue = RandomBuilder.GetDouble();
                 if (randValue > maxValue)
                 {
                     nextActionUnit = Elites[i];
                     maxValue = randValue;
                 }
             }
         }
         //如果为最后一个精英行动,修改队伍行动状态
         if (count <= 1)
         {
             this.ActionState = MonsterActionState.ElitesDone;
         }
     }
     //无Boss和精英行动 选取喽啰行动
     if (nextActionUnit == null && this.ActionState == MonsterActionState.ElitesDone)
     {
         //随机选取未行动的喽啰
         for (int i = 0; i < Minions.Length; i++)
         {
             if (Minions[i].ActionState == UnitActionState.Ready)
             {
                 count++;
                 randValue = RandomBuilder.GetDouble();
                 if (randValue > maxValue)
                 {
                     nextActionUnit = Minions[i];
                     maxValue = randValue;
                 }
             }
         }
         //如果为最后一个喽啰动,修改队伍行动状态
         if (count <= 1)
         {
             this.ActionState = MonsterActionState.AllDone;
         }
     }
     //如果无可行动单位,返回空字符串
     if (nextActionUnit == null)
     {
         return "";
     }
     else
     {
         //执行该单位动作
         return nextActionUnit.Action(turn, enemy);
     }
 }
Exemple #3
0
 /// <summary>
 /// 战斗构造函数
 /// 初始化一场战斗
 /// </summary>
 /// <param name="player">玩家队伍</param>
 /// <param name="monster">怪物队伍</param>
 public Combat(PlayerTeam player, MonsterTeam monster)
 {
     this.PlayerTeam = player;
     this.MonsterTeam = monster;
 }