Exemplo n.º 1
0
        void JoinButtonClick(object sender, EventArgs e)
        {
            net.joinGame(ipTextBox.Text);

            backEnd     = new GameControler(net);
            net.Backend = backEnd;
            backEnd.connected();

            net.receiveOrder();
        }
Exemplo n.º 2
0
        void HostButtonClick(object sender, EventArgs e)
        {
            net.hostGame();

            backEnd     = new GameControler(net);
            net.Backend = backEnd;
            backEnd.connected();

            Random random      = new Random();
            int    firstPlayer = random.Next(1, 3);

            net.sendOrder(firstPlayer);
        }
        public GameAreaForm(GameControler gameControler, GameData data)
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
            this.gameControler = gameControler;
            this.data          = data;
            labelTurn.Hide();
            imageHolder = new ImageHolder(new System.ComponentModel
                                          .ComponentResourceManager(typeof(GameAreaForm)));

            myBombs    = new BombPicture[myBoard.getGridSize(), myBoard.getGridSize()];
            enemyBombs = new BombPicture[enemyBoard.getGridSize(), enemyBoard.getGridSize()];

            for (int i = 0; i < myBoard.getGridSize(); i++)
            {
                for (int j = 0; j < myBoard.getGridSize(); j++)
                {
                    Coords coords = myBoard.getGridCoords(i, j);
                    myBombs[i, j] = new BombPicture
                                        (coords.X + myBoard.Location.X, coords.Y + myBoard.Location.Y, imageHolder);
                    this.Controls.Add(myBombs[i, j]);

                    coords           = enemyBoard.getGridCoords(i, j);
                    enemyBombs[i, j] = new BombPicture
                                           (coords.X + enemyBoard.Location.X, coords.Y + enemyBoard.Location.Y, imageHolder);
                    this.Controls.Add(enemyBombs[i, j]);
                }
            }

            myBoard.SendToBack();
            enemyBoard.SendToBack();

            //test the drawing of bombpictures
            //data.setMyBoxState(5,5, GameData.BoxState.BOMBED);
            //data.setEnemyBoxState(7,7, GameData.BoxState.MISSED);
        }