Exemplo n.º 1
0
 void UpdateGameBoard()
 {
     foreach (Transform puyoUnit in transform)
     {
         GameBoard.Add(puyoUnit.position.x, puyoUnit.position.y, puyoUnit);
     }
 }
Exemplo n.º 2
0
    public IEnumerator DropToFloor()
    {
        WaitForSeconds wait       = new WaitForSeconds(.25f);
        Vector3        currentPos = RoundVector(gameObject.transform.position);

        for (int row = (int)currentPos.y - 1; row >= 0; row--)
        {
            int currentX = (int)currentPos.x;
            if (GameBoard.IsEmpty(currentX, row))
            {
                forcedDownwards = true;
                GameBoard.Clear(currentX, row + 1);
                GameBoard.Add(currentX, row, gameObject.transform);
                gameObject.transform.position += Vector3.down;
                yield return(wait);
            }
            else
            {
                activelyFalling = false;
                forcedDownwards = false;
                break;
            }
        }
        forcedDownwards = false;
        activelyFalling = false;
    }
Exemplo n.º 3
0
        /// <summary>
        ///     Updates the board after En Passant. Does not check legality.
        /// </summary>
        /// <param name="attacker">Pawn that is passing</param>
        /// <param name="capture">Capture to make</param>
        /// <param name="lostPiece">Pawn being captured</param>
        private void UpdateBoardForEnPassant(IPawn attacker, ICapture capture, IPawn lostPiece)
        {
            GameBoard.Remove(attacker.Location);
            attacker.MoveTo(capture.EndingPosition);
            GameBoard.Add(capture.EndingPosition);

            GameBoard.Remove(lostPiece.Location);
            lostPiece.Location = ChessPosition.None;

            MoveHistory.Add(attacker, capture);
        }
Exemplo n.º 4
0
        public static Stack <CellType>[] CreateBoardFromPlayedColumns(CellType firstMove, int Height, int Width, List <int> playedColumns)
        {
            var gameBoard    = new GameBoard(Height, Width);
            var playedColumn = firstMove;

            foreach (var column in playedColumns)
            {
                gameBoard.Add(column, playedColumn);
                playedColumn = playedColumn == CellType.X ? CellType.O : CellType.X;
            }

            return(gameBoard.Board);
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Updates board for Castle. Does not check legality.
        /// </summary>
        /// <param name="king"></param>
        /// <param name="move"></param>
        /// <param name="rook"></param>
        private void UpdateBoardForCastle(IKing king, IMove move, IRook rook)
        {
            ChessPosition newRookLocation = ModelLocator.CastlingHelper.GetEndingPositionForCastlingRook(king, rook);

            GameBoard.Remove(king.Location);    // remove King from board
            king.MoveTo(move.EndingPosition);   // move King, update location
            GameBoard.Add(move.EndingPosition); // place King on board at update location

            GameBoard.Remove(rook.Location);    // remove Rook from board
            rook.MoveTo(newRookLocation);       // move Rook, update location
            GameBoard.Add(rook.Location);       // place Rook on board at updated location

            MoveHistory.Add(king, move);
        }
Exemplo n.º 6
0
        public GameBoard GetSelectedGameBoard()
        {
            var game      = _savedGames[GameSelected];
            var firstMove = game.FirstMove;
            var board     = new GameBoard(game.Height, game.Width)
            {
                FirstMove      = firstMove,
                SelectedColumn = game.SelectedColumn
            };
            var playedMove = firstMove;
            var secondMove = firstMove == CellType.X ? CellType.X : CellType.O;

            foreach (var move in game.Moves)
            {
                board.Add(move.Column, playedMove);
                playedMove = playedMove == CellType.X ? CellType.O : CellType.X;
            }

            return(board);
        }
Exemplo n.º 7
0
        public Move addCard(Card card, int x, int y, bool isAlpha)
        {
            GameBoard.Add(keyString(x, y), new GameSquare(card, isAlpha));

            Card westCard = x > 0 ? GameBoard.GetValueOrDefault(keyString(x - 1, y), null)?.Card : null;
            Card eastCard = x < 2 ? GameBoard.GetValueOrDefault(keyString(x + 1, y), null)?.Card : null;

            Card southCard = y < 2 ? GameBoard.GetValueOrDefault(keyString(x, y + 1), null)?.Card : null;
            Card northCard = y > 0 ? GameBoard.GetValueOrDefault(keyString(x, y - 1), null)?.Card : null;


            if (eastCard != null && getVal(eastCard.W) < getVal(card.E))
            {
                GameBoard.GetValueOrDefault(keyString(x + 1, y)).IsAlpha = isAlpha;
            }

            if (westCard != null && getVal(westCard.E) < getVal(card.W))
            {
                GameBoard.GetValueOrDefault(keyString(x - 1, y)).IsAlpha = isAlpha;
            }

            if (southCard != null && getVal(southCard.N) < getVal(card.S))
            {
                GameBoard.GetValueOrDefault(keyString(x, y + 1)).IsAlpha = isAlpha;
            }

            if (northCard != null && getVal(northCard.S) < getVal(card.N))
            {
                GameBoard.GetValueOrDefault(keyString(x, y - 1)).IsAlpha = isAlpha;
            }

            int score = GameBoard.Values.Where(sq => sq.IsAlpha).Count();

            LastMove = new Move()
            {
                X = x, Y = y, Card = card, Score = score
            };
            return(LastMove);
        }
Exemplo n.º 8
0
        public void GenerateGameBoard()
        {
            String level = Properties.Resources.Level;

            String[] gameBoard = level.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

            int rowCounter  = 0;
            int listCounter = 0;

            foreach (String row in gameBoard)
            {
                String[] columns = row.Split(' ');
                for (int columnCounter = 0; columnCounter < NumberOfColumns; columnCounter++)
                {
                    switch (columns[columnCounter])
                    {
                    case "HD":
                        GameBoard.Add(new GameField {
                            Position = new Position {
                                Column = columnCounter, Row = rowCounter
                            }
                        });
                        GameBoard[listCounter].SetType(FieldType.playerdown);
                        if (!PlayerPositions[0].Set)
                        {
                            PlayerPositions[0].Column = columnCounter;
                            PlayerPositions[0].Row    = rowCounter;
                            PlayerPositions[0].Set    = true;
                        }
                        else
                        {
                            if (PlayerPositions.Count > 1)
                            {
                                PlayerPositions[1].Column = columnCounter;
                                PlayerPositions[1].Row    = rowCounter;
                                PlayerPositions[1].Set    = true;
                            }
                            else
                            {
                                GameBoard.Add(new GameField {
                                    Position = new Position {
                                        Column = columnCounter, Row = rowCounter
                                    }
                                });
                                GameBoard[listCounter].SetType(FieldType.empty);
                            }
                        }
                        break;

                    case "FW":
                        GameBoard.Add(new GameField {
                            Position = new Position {
                                Column = columnCounter, Row = rowCounter
                            }
                        });
                        GameBoard[listCounter].SetType(FieldType.firewall);
                        break;

                    case "EP":
                        GameBoard.Add(new GameField {
                            Position = new Position {
                                Column = columnCounter, Row = rowCounter
                            }
                        });
                        GameBoard[listCounter].SetType(FieldType.empty);
                        break;

                    case "UB":
                        GameBoard.Add(new GameField {
                            Position = new Position {
                                Column = columnCounter, Row = rowCounter
                            }
                        });
                        GameBoard[listCounter].SetType(FieldType.unbreakable);
                        break;

                    case "BC":
                        GameBoard.Add(new GameField {
                            Position = new Position {
                                Column = columnCounter, Row = rowCounter
                            }
                        });
                        GameBoard[listCounter].SetType(FieldType.bitcoin);
                        break;

                    default:
                        GameBoard.Add(new GameField {
                            Position = new Position {
                                Column = columnCounter, Row = rowCounter
                            }
                        });
                        GameBoard[listCounter].SetType(FieldType.empty);
                        break;
                    }
                    listCounter++;
                }
                rowCounter++;
            }
            _converted = ConvertGameboard(GameBoard);
        }
Exemplo n.º 9
0
        public void GenerateGameBoard()
        {
            Debug.WriteLine("Generate GameBoard called");
            Debug.WriteLine("Sending start to server");
            int listCounter = 0;

            _client.Send("start");
            string response = _client.Receive();

            Debug.WriteLine("Response received");
            Debug.WriteLine(response);
            char[] level = response.ToCharArray();
            foreach (char s in level)
            {
                if (s == 0)
                {
                    break;
                }
                switch (s)
                {
                case 'e':
                    GameBoard.Add(new GameField {
                        Position = new Position {
                            Column = listCounter % NumberOfColumns, Row = listCounter / NumberOfColumns
                        }
                    });
                    GameBoard[listCounter].SetType(FieldType.empty);
                    break;

                case 'f':
                    GameBoard.Add(new GameField {
                        Position = new Position {
                            Column = listCounter % NumberOfColumns, Row = listCounter / NumberOfColumns
                        }
                    });
                    GameBoard[listCounter].SetType(FieldType.firewall);
                    break;

                case 'x':
                    GameBoard.Add(new GameField {
                        Position = new Position {
                            Column = listCounter % NumberOfColumns, Row = listCounter / NumberOfColumns
                        }
                    });
                    GameBoard[listCounter].SetType(FieldType.explosion);
                    break;

                case 'u':
                    GameBoard.Add(new GameField {
                        Position = new Position {
                            Column = listCounter % NumberOfColumns, Row = listCounter / NumberOfColumns
                        }
                    });
                    GameBoard[listCounter].SetType(FieldType.unbreakable);
                    break;

                case 'l':
                    GameBoard.Add(new GameField {
                        Position = new Position {
                            Column = listCounter % NumberOfColumns, Row = listCounter / NumberOfColumns
                        }
                    });
                    GameBoard[listCounter].SetType(FieldType.laptop);
                    break;

                case 'b':
                    GameBoard.Add(new GameField {
                        Position = new Position {
                            Column = listCounter % NumberOfColumns, Row = listCounter / NumberOfColumns
                        }
                    });
                    GameBoard[listCounter].SetType(FieldType.bitcoin);
                    break;

                case '3':
                    GameBoard.Add(new GameField {
                        Position = new Position {
                            Column = listCounter % NumberOfColumns, Row = listCounter / NumberOfColumns
                        }
                    });
                    GameBoard[listCounter].SetType(FieldType.playerup);
                    break;

                case '4':
                    GameBoard.Add(new GameField {
                        Position = new Position {
                            Column = listCounter % NumberOfColumns, Row = listCounter / NumberOfColumns
                        }
                    });
                    GameBoard[listCounter].SetType(FieldType.playeruplaptop);
                    break;

                case '1':
                    GameBoard.Add(new GameField {
                        Position = new Position {
                            Column = listCounter % NumberOfColumns, Row = listCounter / NumberOfColumns
                        }
                    });
                    GameBoard[listCounter].SetType(FieldType.playerdown);
                    break;

                case '2':
                    GameBoard.Add(new GameField {
                        Position = new Position {
                            Column = listCounter % NumberOfColumns, Row = listCounter / NumberOfColumns
                        }
                    });
                    GameBoard[listCounter].SetType(FieldType.playerdownlaptop);
                    break;

                case '7':
                    GameBoard.Add(new GameField {
                        Position = new Position {
                            Column = listCounter % NumberOfColumns, Row = listCounter / NumberOfColumns
                        }
                    });
                    GameBoard[listCounter].SetType(FieldType.playerleft);
                    break;

                case '8':
                    GameBoard.Add(new GameField {
                        Position = new Position {
                            Column = listCounter % NumberOfColumns, Row = listCounter / NumberOfColumns
                        }
                    });
                    GameBoard[listCounter].SetType(FieldType.playerleftlaptop);
                    break;

                case '5':
                    GameBoard.Add(new GameField {
                        Position = new Position {
                            Column = listCounter % NumberOfColumns, Row = listCounter / NumberOfColumns
                        }
                    });
                    GameBoard[listCounter].SetType(FieldType.playerright);
                    break;

                case '6':
                    GameBoard.Add(new GameField {
                        Position = new Position {
                            Column = listCounter % NumberOfColumns, Row = listCounter / NumberOfColumns
                        }
                    });
                    GameBoard[listCounter].SetType(FieldType.playerrightlaptop);
                    break;

                default:
                    break;
                }

                listCounter++;
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components  = new System.ComponentModel.Container();
            this.timer1      = new System.Windows.Forms.Timer(this.components);
            this._background = new System.Windows.Forms.PictureBox();
            this.panel1      = new System.Windows.Forms.Panel();
            this.button1     = new System.Windows.Forms.Button();
            this.button3     = new System.Windows.Forms.Button();
            _gameBoard       = new GameBoard();

            ((System.ComponentModel.ISupportInitialize)(this._background)).BeginInit();
            this.panel1.SuspendLayout();
            this.SuspendLayout();
            //
            // timer1
            //
            this.timer1.Enabled  = true;
            this.timer1.Interval = 10;
            this.timer1.Tick    += new System.EventHandler(this.timer1_Tick);
            //
            // baddy1
            //
            _gameBoard.BuildBadies();
            _gameBoard.BuildGoody();
            // gameBoard
            //
            this._background.Image    = global::WindowsFormsApp1.Properties.Resources.agario_white_background;
            this._background.Location = new System.Drawing.Point(2, 13);
            this._background.Margin   = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this._background.Name     = "gameBoard";
            this._background.Size     = new System.Drawing.Size(1557, 820);
            this._background.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
            this._background.TabIndex = 0;
            this._background.TabStop  = false;
            //
            // panel1
            //
            this.panel1.Controls.Add(this.button3);
            this.panel1.Controls.Add(this.button1);
            this.panel1.Location = new System.Drawing.Point(107, 852);
            this.panel1.Name     = "panel1";
            this.panel1.Size     = new System.Drawing.Size(1372, 100);
            this.panel1.TabIndex = 5;
            //
            // button1
            //
            this.button1.Location = new System.Drawing.Point(47, 13);
            this.button1.Name     = "button1";
            this.button1.Size     = new System.Drawing.Size(155, 75);
            this.button1.TabIndex = 0;
            this.button1.Text     = "button1";
            this.button1.UseVisualStyleBackColor = true;
            //
            // button3
            //
            this.button3.Location = new System.Drawing.Point(258, 14);
            this.button3.Name     = "button3";
            this.button3.Size     = new System.Drawing.Size(163, 74);
            this.button3.TabIndex = 1;
            this.button3.Text     = "button3";
            this.button3.UseVisualStyleBackColor = true;
            //
            // Form1
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
            this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
            this.AutoSize            = true;
            this.ClientSize          = new System.Drawing.Size(1568, 1079);
            this.Controls.Add(this.panel1);
            _gameBoard.Add(Controls);

            this.Controls.Add(this._background);
            this.Margin          = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.Name            = "Form1";
            this.StartPosition   = System.Windows.Forms.FormStartPosition.WindowsDefaultBounds;
            this.Text            = "Form1";
            this.Load           += new System.EventHandler(this.Form1_Load);
            this.KeyPress       += new System.Windows.Forms.KeyPressEventHandler(this.Form1_KeyPress);
            this.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.Form1_PreviewKeyDown);
            _gameBoard.EndInit();
            ((System.ComponentModel.ISupportInitialize)(this._background)).EndInit();
            this.panel1.ResumeLayout(false);
            this.ResumeLayout(false);
        }
Exemplo n.º 11
0
 public void AddToGameBoard(int index, string value)
 {
     GameBoard.Add(index, value);
     changeCurrentPlayer();
 }