Exemple #1
0
 /// <summary>
 /// Method updates all layers based on given model
 /// </summary>
 /// <param name="boardModel"></param>
 public void UpdateGameBoard(GameModel.GameBoardModel boardModel)
 {
     for (int z = 0; z < numberOfLayers; z++)
     {
         UpdateLayer(boardModel.GetLayerAt(z), z);
     }
 }
Exemple #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="boardModel">Board model</param>
        /// <param name="z">Layer's number from boardModel</param>
        public LayerView(GameModel.GameBoardModel boardModel, int z)
        {
            layerSize = boardModel.boardSize;

            InitializeLayer();
            CreateFields(boardModel.GetLayerAt(z));
        }
Exemple #3
0
 /// <summary>
 /// Method creates layers based on given model
 /// </summary>
 /// <param name="model">Board model</param>
 private void CreateLayers(GameModel.GameBoardModel boardModel)
 {
     for (int z = 0; z < numberOfLayers; z++)
     {
         layers[z] = new LayerView(boardModel, z);
         layers[z].InsertLayerIntoGameBoard(ref gameBoard, z, 0);
     }
 }
Exemple #4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="boardModel">Board model</param>
        public GameBoardView(GameModel.GameBoardModel boardModel)
        {
            numberOfLayers = boardModel.numberOfLayers;

            InitializeGameBoard();
            CreateLayers(boardModel);
            UpdateGameBoard(boardModel);
        }
Exemple #5
0
        /// <summary>
        /// Method restarts game
        /// </summary>
        public void ResetGame()
        {
            LoadBoardSize();

            gameModel     = new Model.GameBoardModel(this.boardSize, this.numberOfLayers);
            gameModelView = new View.GameBoardView(gameModel);
            gameModelView.InsertGameBoardIntoMainGrid(ref mainBoardGrid, 0, 1);

            gameStatistic.ResetStatistic();

            StartGame();
        }
Exemple #6
0
        /// <summary>
        /// Method converts string (saved gamed) to game board, game settings and game score
        /// </summary>
        /// <param name="savedGame"></param>
        public void ImportGame(String savedGame)
        {
            string [] list = savedGame.Split('.');

            Model.GameSettings.GetInstance.ImportSettingsFromString(list[0], list[1], list[2], list[3], list[4]);
            LoadBoardSize();

            gameModel     = new Model.GameBoardModel(this.boardSize, this.numberOfLayers);
            gameModelView = new View.GameBoardView(gameModel);
            gameModelView.InsertGameBoardIntoMainGrid(ref mainBoardGrid, 0, 1);
            gameModel.ImportGameBoardModelFromString(list[5], list[6]);

            gameStatistic.ResetStatistic();
            gameStatistic.ImportScoreModelFromString(list[7]);

            UpdateView();
        }
Exemple #7
0
        public GameController(ref Windows.UI.Xaml.Controls.Grid mainBoard,
                              ref Windows.UI.Xaml.Controls.TextBlock bestScore,
                              ref Windows.UI.Xaml.Controls.TextBlock actualScore)
        {
            LoadBoardSize();

            gameStatistic     = new Model.GameScoreModel();
            gameStatisticView = new View.GameScoreView(ref bestScore, ref actualScore);

            mainBoardGrid = mainBoard;
            gameModel     = new Model.GameBoardModel(this.boardSize, this.numberOfLayers);
            gameModelView = new View.GameBoardView(gameModel);

            gameModelView.InsertGameBoardIntoMainGrid(ref mainBoardGrid, 0, 1);

            StartGame();
        }