Ejemplo n.º 1
0
    // returns a clone of the board so that the player does not actually change
    // the elements on the initial board itself
    public MonkeyBoard GoToBoardAndBind(int index)
    {
        // this is to transit the number of lives across all boards
        int currentLives = InitialLives;

        if (CurrentBoard != null)
        {
            currentLives = CurrentBoard.NumberOfLives;

            // disengage the gameover event for current board
            CurrentBoard.AllLivesUsed -= AllLivesUsedBinding;
        }

        if (index >= MapPathList.Count)
        {
            throw new Exception("Attempting to jump to a board index that is more than current board count!");
        }

        CurrentBoardIndex = index;
        CurrentBoard      = MonkeyBoard.LoadXmlMap(MapPathList[CurrentBoardIndex]);

        // need to plus one since board level starts with 1 while index starts with 0
        CurrentBoard.BoardLevel = CurrentBoardIndex + 1;
        CurrentBoard.SetNumberOfLives(currentLives);

        // do some initialization here for gameover
        CurrentBoard.AllLivesUsed += AllLivesUsedBinding;

        return(CurrentBoard);
    }
Ejemplo n.º 2
0
 private void DisplayBoard(MonkeyBoard board)
 {
     // defensive programming needed in case the board package doesn't go into cyclic mode
     if (board != null)
     {
         BoardUI.Board   = board;
         MainBarUI.Board = board;
     }
 }
Ejemplo n.º 3
0
        // returns a clone of the board so that the player does not actually change
        // the elements on the initial board itself
        public MonkeyBoard JumpToBoard(int index)
        {
            // this is to transit the number of lives across all boards
            int currentLives = InitialLives;

            if (CurrentBoard != null)
            {
                currentLives = CurrentBoard.NumberOfLives;
            }

            if (index >= MapPathList.Count)
            {
                throw new Exception("Attempting to jump to a board index that is more than current board count!");
            }

            CurrentBoardIndex = index;
            CurrentBoard      = MonkeyBoard.LoadXmlMap(MapPathList[CurrentBoardIndex]);

            // need to plus one since board level starts with 1 while index starts with 0
            CurrentBoard.BoardLevel = CurrentBoardIndex + 1;
            CurrentBoard.SetNumberOfLives(currentLives);

            return(CurrentBoard);
        }
Ejemplo n.º 4
0
 private void DisplayBoard(MonkeyBoard board)
 {
     BoardUI.Board   = board;
     MainBarUI.Board = board;
 }