Beispiel #1
0
        int _zIndexOfTouchFields = Basics.Infinity(); // The touch fields always have to stay on top

        #endregion Fields

        #region Constructors

        // --- Methods of the class ---
        /// <summary>The constructor</summary>
        /// <param name="gameBoard">The GameBoard to consider as the basis</param>
        public GameBoard(Kalaha.Model.GameBoard gameBoard,
                            Canvas gameBoardCanvas,
                            PointerEventHandler PointerEnteredHouse,
                            PointerEventHandler PointerExitedHouse,
                            RoutedEventHandler TouchFieldSelected)
        {
            _gameBoard = gameBoard;
            _canvasToPaintOn = gameBoardCanvas;

            KalahPosition kalahPosition;
            kalahPosition = GetKalahPosition();
            CreatePitsAndSetCoordinatesAndSizes(kalahPosition);
            CreateImagesAndTouchFieldsAndNumFieldsOfHouses(PointerEnteredHouse, PointerExitedHouse, TouchFieldSelected);
            CreateImagesAndNumFieldsOfKalahs();
        }
Beispiel #2
0
        /// <returns>A complete copy of the Gameboard</returns>
        public GameBoard GetACopy()
        {
            GameBoard theCopy = new GameBoard(_numHousesPerPlayer, _numInitialSeeds);

            for (int index = 0; index < _numPitsInTotal; ++index)
            {
                theCopy._pit[index] = new Pit(0);
                theCopy._pit[index].AddSeeds(_pit[index].GetNumberofSeeds());
            }

            return theCopy;
        }
Beispiel #3
0
        /// <summary>
        /// The constructor takes a View_Base object (or an instance of any derived class) in order
        /// to store it for later use.
        /// </summary>
        private Presenter()
        {
            //DEBUG     Logging.I.LogMessage("Calling constructor of Presenter.\n");

            _view = null;

            // Initially, there is no game running:
            _gameStatus = GameStatus.Ended;

            // Create the game board, defining the number of pits per player:
            _modelGameBoard = new Kalaha.Model.GameBoard();

            // Create the two players:
            _southPlayer = new Player(Player.Position.South);
            _northPlayer = new Player(Player.Position.North);

            // Start with an empty undo list:
            _undoManager = new UndoManager();

            // Restore previously saved values for all kinds of settings:
            string restoredThemeName = "";
            GameStorage.I.RestoreSavedValues(ref _southPlayer, ref _northPlayer, ref restoredThemeName);
            SwitchToRestoredTheme(restoredThemeName);

            // Define the southern player to start first:
            _playerWhoIsFirst = _southPlayer;          //TODO: Restore the first player from the saved values.

            // Set the HubPage workaround to "don't show explanation":
            _tellHubPageToShowThemeExplanation = false;
        }