예제 #1
0
 public GameControl()
 {
     moveOptions = new List<Button>();
     board = new Map();
     selectedB = null;
     selectedT = null;
     actionsPerTurn = Wallscape.Models.Settings.getInstance().getActions();
     actionCounter = 0;
 }
예제 #2
0
파일: Map.cs 프로젝트: pmoda/Wallscape
        public void placeToken(int x, int y, int p)
        {
            if (x >= 0 && y >= 0 && x < board.GetLength(0) && y < board.GetLength(1))
            {
                board[x, y] = "Player" + p.ToString(); 

                Token newToken = new Token(p);
                newToken.setX(x);
                newToken.setY(y);
                players[p].addToken(newToken);
                tokens.Add(newToken);
            }
        }
예제 #3
0
        public List<Button> attemptMove(Button button)
        {
            selectedB = button;
            
            Token selectedToken = board.getTokens()[Convert.ToInt32(button.Name)];
            selectedT = selectedToken;
            int positionX = selectedToken.getX();
            int positionY = selectedToken.getY();
            int player = selectedToken.getPlayer();
            String status = "Safe" + (player+1);

            if (board.at(positionX, positionY + 2) == status && board.at(positionX, positionY + 1) == "Open")
            {
                moveOptions.Add(makeOptionButton(positionX, positionY + 2, player));
            }
            if (board.at(positionX, positionY - 2) == status && board.at(positionX, positionY - 1) == "Open")
            {
                moveOptions.Add(makeOptionButton(positionX, positionY - 2, player));
            }

            if (board.at(positionX, positionY - 1) == "Open" &&
                (board.at(positionX, positionY - 2) == "Free" || board.at(positionX, positionY - 2).Contains("Player")))
            {
                if (board.at(positionX, positionY - 2).Contains("Player")){ 
                   if(board.at(positionX, positionY - 3) == "Open" && board.at(positionX, positionY - 4) == "Free"){
                        moveOptions.Add(makeOptionButton(positionX, positionY - 4, player));
                   }
                   if(board.at(positionX - 1, positionY - 2) == "Open" && board.at(positionX - 2, positionY - 2) == "Free")
                   {
                       moveOptions.Add(makeOptionButton(positionX - 2, positionY - 2, player));
                   }
                   if(board.at(positionX + 1, positionY - 2) == "Open" && board.at(positionX + 2, positionY - 2) == "Free")
                   {
                       moveOptions.Add(makeOptionButton(positionX + 2, positionY - 2, player));
                   }

                }else{
                    moveOptions.Add(makeOptionButton(positionX, positionY - 2, player));
                }
            }
            if (board.at(positionX, positionY + 1) == "Open" && 
                (board.at(positionX, positionY + 2) == "Free" || board.at(positionX, positionY + 2).Contains("Player")))
            {
                if (board.at(positionX, positionY + 2).Contains("Player")){ 
                   if(board.at(positionX, positionY + 3) == "Open" && board.at(positionX, positionY + 4) == "Free"){
                        moveOptions.Add(makeOptionButton(positionX, positionY + 4, player));
                   }
                   if (board.at(positionX - 1, positionY + 2) == "Open" && board.at(positionX - 2, positionY + 2) == "Free")
                   {
                       moveOptions.Add(makeOptionButton(positionX - 2, positionY + 2, player));
                   }
                   if (board.at(positionX + 1, positionY + 2) == "Open" && board.at(positionX + 2, positionY + 2) == "Free")
                   {
                       moveOptions.Add(makeOptionButton(positionX + 2, positionY + 2, player));
                   }
                }else{
                    moveOptions.Add(makeOptionButton(positionX, positionY + 2, player));
                }
            }
            if (board.at(positionX - 1, positionY) == "Open" && 
                (board.at(positionX - 2, positionY) == "Free"|| board.at(positionX - 2, positionY).Contains("Player")))
            {
                if (board.at(positionX - 2, positionY).Contains("Player"))
                {
                    if (board.at(positionX - 3, positionY) == "Open" && board.at(positionX - 4, positionY) == "Free")
                    {
                        moveOptions.Add(makeOptionButton(positionX - 4, positionY, player));
                    }
                    if (board.at(positionX - 2, positionY - 1) == "Open" && board.at(positionX - 2, positionY - 2) == "Free")
                    {
                        moveOptions.Add(makeOptionButton(positionX - 2, positionY - 2, player));
                    }
                    if (board.at(positionX - 2, positionY + 1) == "Open" && board.at(positionX - 2, positionY + 2) == "Free")
                    {
                        moveOptions.Add(makeOptionButton(positionX - 2, positionY + 2, player));
                    }
                }
                else
                {
                    moveOptions.Add(makeOptionButton(positionX - 2, positionY, player));
                }
            }
            if (board.at(positionX + 1, positionY) == "Open" &&
                (board.at(positionX + 2, positionY) == "Free" || board.at(positionX + 2, positionY).Contains("Player")))
            {
                if (board.at(positionX + 2, positionY).Contains("Player"))
                {
                    if (board.at(positionX + 3, positionY) == "Open" && board.at(positionX + 4, positionY) == "Free")
                    {
                        moveOptions.Add(makeOptionButton(positionX + 4, positionY, player));
                    }
                    if (board.at(positionX + 2, positionY - 1) == "Open" && board.at(positionX + 2, positionY - 2) == "Free")
                    {
                        moveOptions.Add(makeOptionButton(positionX + 2, positionY - 2, player));
                    }
                    if (board.at(positionX + 2, positionY + 1) == "Open" && board.at(positionX + 2, positionY + 2) == "Free")
                    {
                        moveOptions.Add(makeOptionButton(positionX + 2, positionY + 2, player));
                    }
                }
                else
                {
                    moveOptions.Add(makeOptionButton(positionX + 2, positionY, player));
                }
            }

            return moveOptions;
        }
예제 #4
0
파일: Player.cs 프로젝트: pmoda/Wallscape
 public void addToken(Token token)
 {
     token.setPlayer(this.id);
     tokens.Add(token);
 }