Esempio n. 1
0
 /// <summary>
 /// 指定した名前と対応するハンドラの生成を試みます
 /// </summary>
 /// <param name="name"></param>
 /// <param name="teamHandler"></param>
 /// <returns></returns>
 public static bool TryCreateHandler(string name, out TeamHandlerBase teamHandler)
 {
     teamHandler = null;
     try
     {
         teamHandler = CreateHandler(name);
         return(true);
     }
     catch (InvalidOperationException) { return(false); }
 }
Esempio n. 2
0
        /// <summary>
        /// 各々のチームで次の動作を決定し、<see cref="Intent"/>配列(Agent1, Agent2, Agent1, Agent2の順)を返却します
        /// </summary>
        private Intent[] MakeIntents(int turn, TeamHandlerBase teamHandler1, TeamHandlerBase teamHandler2)
        {
            Intent[] intents = new Intent[4];
            teamHandler1.Turn(turn, i => intents[0] = i, i => intents[1] = i);
            teamHandler2.Turn(turn, i => intents[2] = i, i => intents[3] = i);

            for (int i = 0; intents.Length > i; i++)
            {
                if (intents[i] == null)
                {
                    if (WriteConsole)
                    {
                        Console.WriteLine("Intent is null");
                    }
                    intents[i] = Intent.StayIntent;
                }
            }

            return(intents);
        }
Esempio n. 3
0
        private bool Abort(CancellationToken token, TeamHandlerBase teamHandler1, TeamHandlerBase teamHandler2)
        {
            bool ret = false;

            if (token.IsCancellationRequested)
            {
                ret = true;
            }

            if (ret)
            {
                if (WriteConsole)
                {
                    Console.WriteLine("Game Aborted");
                }
                RaiseFinished(teamHandler1, teamHandler2);
                Finished?.Invoke(this, new EventArgs());
            }

            return(ret);
        }
Esempio n. 4
0
 private void RaiseFinished(TeamHandlerBase teamHandler1, TeamHandlerBase teamHandler2)
 {
     teamHandler1?.GameFinished();
     teamHandler2?.GameFinished();
 }
Esempio n. 5
0
 private void RaiseStarted(TeamHandlerBase teamHandler1, TeamHandlerBase teamHandler2)
 {
     teamHandler1?.GameStarted(this, Teams.Team1);
     teamHandler2?.GameStarted(this, Teams.Team2);
 }