コード例 #1
0
ファイル: Board.cs プロジェクト: charti/InVers
        public Board(Board cpyBoard)
        {
            _players = new[] {
                new Player(cpyBoard.Players[0].Kind) {
                    CurrentToken = cpyBoard._players[0].CurrentToken},
                new Player(cpyBoard.Players[1].Kind) {
                    CurrentToken = cpyBoard._players[1].CurrentToken},
            };

            int idx = -1;
            foreach(var field in cpyBoard.FieldBoard)
            {
                idx++;
                if (field == null)
                    continue;
                if (field.Type == typeof(Move))
                    _board[idx] = new Move(idx);
                else
                {
                    var token = field as Token;
                    var newToken = new Token(token.Color);
                    newToken.IsFlipped = token.IsFlipped;
                    _board[idx] = newToken;
                }
            }

            CurrentTurn = _players.First(pl => pl.Color == cpyBoard.CurrentTurn.Color);
        }
コード例 #2
0
ファイル: Player.cs プロジェクト: charti/InVers
        public Player(PlayerKind kind)
        {
            Kind = kind;
            Color = (PlayerColor)_playerCount;
            CurrentToken = new Token(Color) { IsFlipped = true };

            _playerCount = (_playerCount + 1) % 2;
        }
コード例 #3
0
ファイル: Board.cs プロジェクト: charti/InVers
        private void InitBoard()
        {
            for (int i = 1; i <= 6; i++)
            {
                for (int j = 1; j <= 5; j += 2)
                {
                    var encodedIdx = 8 * i + j;
                    if ((i % 2) == 1)
                    {
                        _board[encodedIdx] = new Token(PlayerColor.red);
                        _board[encodedIdx + 1] = new Token(PlayerColor.yellow);
                    }
                    else
                    {
                        _board[encodedIdx + 1] = new Token(PlayerColor.red);
                        _board[encodedIdx] = new Token(PlayerColor.yellow);
                    }
                }
            }

            for (int i = 1; i < 63; i++)
                if (_board[i] == null && i != 7 && i != 56)
                    _board[i] = new Move(i);
        }