private void CreatingBuildingSpotControls(object sebred, GameBoard gameBoard)
 {
     Debug.WriteLine("Start creating BuildingSpotControls.");
     buildingSpotControls = new BuildingSpotControl[gameBoard.BuildingSpots.Count];
     for (var i = 0; i < gameBoard.BuildingSpots.Count; i++)
     {
         buildingSpotControls[i] = new BuildingSpotControl
         {
             BuildingSpot = gameBoard.BuildingSpots[i],
             Location = gameBoard.BuildingSpots[i].SpotIndex.GetPoint()
         };
         buildingSpotControls[i].cv += GameBoard2Controler_cv;
         ;
     }
     gameForm.UiThread(
         () =>
         {
             foreach (var buildingSpotControl in buildingSpotControls)
             {
                 gameForm.Controls.Add(buildingSpotControl);
             }
             Debug.WriteLine("BuildingSpot Controls Load.");
         }
         );
 }
 public void CreateNewGame()
 {
     gameBoard = new GameBoard(5, 5);
     OnGameBoardIsCreated(gameBoard);
     playerOne = new Player(null);
     playerOne.CreatePalace = gameBoardControler.GetBSpot;
     GameStarted += playerOne.OnGetBuildSpot;
     OnPlayerIsCreated(playerOne);
     playerTwo = new Player(null);
     playerTwo.CreatePalace = () => gameBoard.BuildingSpots[3];
     GameStarted += playerTwo.OnGetBuildSpot;
     //OnPlayerIsCreated(player2);
 }
        private void CreatingTileControls(object sender, GameBoard gameBoard)
        {
            Debug.WriteLine("Starting creating TileContros");

            tileControls = new TileControl[gameBoard.Rows * gameBoard.Collums];
            var controlSize = new Size(60, 60);
            for (var i = 0; i < gameBoard.Collums; i++)
            {
                for (var j = 0; j < gameBoard.Rows; j++)
                {
                    tileControls[(i * gameBoard.Collums) + j] = new TileControl(gameBoard.GetTile(i, j))
                    {
                        Tile = gameBoard.GetTile(i, j),
                        Location = gameBoard.GetTile(i, j).TileIndex.GetPoint
                            (controlSize.Width, controlSize.Height)
                    };
                    tileControls[(i * gameBoard.Collums) + j].cv += Go;
                    gameControler.GameBegin += tileControls[(i*gameBoard.Collums) + j].Reset2;
                }
            }
            gameForm.UiThread(
                () =>
                {
                    foreach (var tileControl in tileControls)
                    {
                        gameForm.Controls.Add(tileControl);
                    }
                    Debug.WriteLine("Tile Controls Load.");
                }
                );
        }
Exemple #4
0
 public void Turn(GameBoard gameBoard)
 {
     player.Turn(gameBoard);
 }
Exemple #5
0
        public GameBoard Turn2(GameBoard gameBoard)
        {
            timeCounterThread = new Thread(
                () =>
                {
                    WaitTimeForTurn(timeInSeconds);
                }
                )
            {
                IsBackground = true
            };
            timeCounterThread.Start();

            PlayerStats = new TileParams();
            foreach (var item in PlayerTiles.Where(item => item.IsActive))
            {
                PlayerStats += item.TileParams;
            }
            foreach (var building in PlayerBuildingSpots.Select(building => building.Building))
            {
                PlayerStats += building.BuildingParams;
            }
            PlayerMoney += PlayerStats.Money;
            PlayerMoney++;
            foreach (var buildRequest in PlayerBuildQuery)
            {
                buildRequest.AddProgress(PlayerStats.Production);
            }
            PlayerBuildQuery.RemoveAll(item => item.IsCompleted);
            requestsIsCounting = true;
            timeCounterThread.Join();
            Debug.WriteLine("Turn is Over");

            return gameBoard;
        }
 private void OnGameBoardIsCreated(GameBoard e)
 {
     GameBoardIsCreated?.Invoke(this, e);
 }