public MainWindow() { InitializeComponent(); m_GameLevelState = new GameData.GameLevelState(); m_GameLevelState.InitializeNewLevel_Default(); for (int i = 0; i < 100; ++i) { System.Diagnostics.Debug.WriteLine("Pre match-check board state:"); m_GameLevelState.m_BoardProcessing.OutputBoardStateToDebugTrace(m_GameLevelState.m_BoardState); for (int j = 0; j < 10; j++) { System.Diagnostics.Debug.WriteLine("Current board state:"); m_GameLevelState.m_BoardProcessing.OutputBoardStateToDebugTrace(m_GameLevelState.m_BoardState); List <GameDataInterop.GameState.BoardGemMatch> oBoardGemMatchList = m_GameLevelState.m_BoardProcessing.FindAllMatches(m_GameLevelState.m_BoardState); System.Diagnostics.Debug.WriteLine(String.Format("Found {0} matches during board processing.", oBoardGemMatchList.Count())); var oMoveSequence = m_GameLevelState.m_MoveProcessing.Debug_GenRandomMoveSequence(100); GameDataInterop.GameState.BoardMoveResult oBoardMoveResult = m_GameLevelState.m_MoveProcessing.ExecuteBoardMoveSequence_Complete(m_GameLevelState.m_BoardState, oMoveSequence); System.Diagnostics.Debug.WriteLine( String.Format("Processed random move sequence; {0} matches pre-cascade, {1} post-cascade.", oBoardMoveResult.m_oBoardMatchList_PreCascade.Count(), (oBoardMoveResult.m_oBoardMatchList_PostCascade != null) ? oBoardMoveResult.m_oBoardMatchList_PostCascade.Count() : 0)); } } }
public GameDataInterop.GameState.BoardMoveResult ExecuteBoardMoveSequence_Complete(GameDataInterop.BoardState oBoardState, GameDataInterop.GameState.BoardMoveSequence oBoardMoveSequence) { GameDataInterop.GameState.BoardMoveResult oBoardMoveResult = new GameDataInterop.GameState.BoardMoveResult(); // TODO: Copy board state, so we can leave unmodified in the event of an error while processing the move // Execute the move sequence // Check correctness of move sequence as we go GameDataInterop.CellIndex oCurrentCellIndex = oBoardMoveSequence.m_StartCellIndex; foreach (var oMoveStep in oBoardMoveSequence.m_oMoveStepList) { VLRTech.Util.Checks.Runtime.AssertThrow(oCurrentCellIndex.Equals(oMoveStep.m_StartCellIndex)); ExecuteBoardMoveStep_BoardUpdateOnly(oBoardState, oMoveStep); oCurrentCellIndex = oCurrentCellIndex.GetNeighboringCellIndex(oMoveStep.m_eDirection); } // Collect initial matches List <GameDataInterop.GameState.BoardGemMatch> oBoardMatchList = m_GameLevelState.m_BoardProcessing.FindAllMatches(oBoardState); oBoardMoveResult.m_oBoardMatchList_PreCascade = oBoardMatchList; int nCascadeIteration = 0; while (true) { // Initial check, in case we didn't produce any pre-cascade matches if (oBoardMatchList.Count() == 0) { break; } ++nCascadeIteration; ExecuteBoardClearMatches(oBoardState, oBoardMatchList); ExecuteBoardCascade_Consolidate(oBoardState); ExecuteBoardCascade_Skyfall(oBoardState); oBoardMatchList = m_GameLevelState.m_BoardProcessing.FindAllMatches(oBoardState); if (oBoardMatchList.Count() == 0) { // We're done break; } if (oBoardMoveResult.m_oBoardMatchList_PostCascade == null) { oBoardMoveResult.m_oBoardMatchList_PostCascade = new List <GameDataInterop.GameState.BoardGemMatch>(); } // Mark all matches in this generation with the applicable iteration number, // and add to results list foreach (var oBoardGemMatch in oBoardMatchList) { oBoardGemMatch.m_nCascadeIteration = nCascadeIteration; oBoardMoveResult.m_oBoardMatchList_PostCascade.Add(oBoardGemMatch); } } // TODO: Calculate point total return(oBoardMoveResult); }