// 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); }
// 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); }