예제 #1
0
 public bool[,] GetFieldAsBoolsForPlayer(Player player)
 {
     var arrOut = new bool[FieldSize, FieldSize];
     for (int i = 0; i < FieldSize; i += 1)
     {
         for (int j = 0; j < FieldSize; j += 1)
         {
             if (_fieldData[i, j] == player) arrOut[i, j] = true;
         }
     }
     return arrOut;
 }
예제 #2
0
 private void SetPlayerWon(Player player)
 {
     var pos = GameField.Instance.WritablePositionStart;
     Console.SetCursorPosition(pos.X, pos.Y + 4);
     Console.WriteLine("Player {0} won the game.", player.Icon);
     GameActive = false;
 }
예제 #3
0
        private void RequestTurn(Player player)
        {
            if (!GameActive) return;

            var validTurn = false;
            while(!validTurn && GameActive)
            {
                var newPos = player.Turn();
                if (!GameField.Instance.CheckPositionAvailable(newPos)) continue;

                _turnList.Add(string.Format("{0} {1}", player.Icon, newPos.ToString()));
                validTurn = GameField.Instance.SetPositionForPlayer(newPos, player);
            }
        }
예제 #4
0
        // Sets a player to a given position.
        public bool SetPositionForPlayer(Position position, Player player)
        {
            if (position == null || !CheckPositionAvailable(position)) return false;
            _fieldData[position.X, position.Y] = player;

            FieldsSet += 1;

            return true;
        }
예제 #5
0
 public GameFieldEventArgs(GameField.Position position, Player player)
 {
     Position = position;
     Player = player;
 }