示例#1
0
        public void MakeMove(ActionData action)
        {
            try
            {
                while (PauseX.Pause)
                {
                    Thread.Sleep(100);
                }

                ExecuteAction(action);

                if (OnNewMove != null)
                {
                    OnNewMove(action);
                }

                PlayerToMove = PlayerToMove == PlayerOne ? PlayerTwo : PlayerOne;
                if (!CheckFinishGame())
                {
                    Thread.Sleep(400);

                    PlayerToMove.Move(Position);
                }
                else
                {
                    FinishGame();
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
示例#2
0
        public void StartGame(PositionData startPosition, Player playerOne, Player playerTwo)
        {
            Actions.Clear();
            PlayerOne = playerOne;
            PlayerOne.Logic.OnActionDecided = this.MakeMove;
            PlayerTwo = playerTwo;
            PlayerTwo.Logic.OnActionDecided = this.MakeMove;
            Position     = startPosition;
            PlayerToMove = playerOne;

            if (!CheckFinishGame())
            {
                PlayerToMove.Move(Position);
            }

            while (MatchInfo == null)
            {
                Thread.Sleep(20);
            }
        }