/// <summary> /// /// </summary> /// <param name="maze"></param> private void MazeGeneratedHandler(AbstractMazeCell <FreeSOMazeData>[,] maze) { RawMaze = maze; try { var charIndex = ThankU.Next(0, EveryDeadEndCell.Count); CharismaPlayer.Location = EveryDeadEndCell[charIndex]; lock (EveryDeadEndCell) EveryDeadEndCell.Remove(CharismaPlayer.Location); var logicIndex = ThankU.Next(0, EveryDeadEndCell.Count); LogicPlayer.Location = EveryDeadEndCell[logicIndex]; } catch (Exception e) { Console.WriteLine("oops " + e.Message); } EveryDeadEndCell = new List <AbstractMazeCell <FreeSOMazeData> >(); Solution = CurrentMaze.GetPathFromOriginToExit(CharismaPlayer.Location, LogicPlayer.Location, -1); // add hints based on hint probability if (Solution != null) { MinimumSolutionMoves = Solution.Count; var hintProbability = HintProbabilities[ChosenMazeDifficulty].Item1; for (int cell = 0; cell < Solution.Count; cell++) { Solution[cell].CellData.UnvisitedSolution = true; var roll = ThankU.Next(1, 101); if (roll <= hintProbability) { Solution[cell].CellData.ShowHint = true; } } EnqueueGotoState(FreeSOMazeStates.LoadingMaze); CumulativeHintProbability = HintProbabilities[ChosenMazeDifficulty].Item2; } }
private void MazeGeneratedHandler(AbstractMazeCell <TSOMazeData>[,] maze) { MazeArray = maze; // random number from 0 to 3 inclusive for one of the 4 colors var colorIndex = Rng.Next((int)VMEODTwoPersonJobObjectMazePluginCellColors.Blue, (int)VMEODTwoPersonJobObjectMazePluginCellColors.Blank); ThisRoundOriginColor = colorIndex; var cellList = ColorCells[colorIndex]; // randon number from 0 to list.count for any cell of that color colorIndex = Rng.Next(0, cellList.Count); CharismaPlayerOrigin = cellList[colorIndex]; // get the solution var numberOfMoves = Rng.Next(MIN_MOVES_TO_EXIT, MAX_MOVES_TO_EXIT + 1); SolutionPath = CurrentMaze.GetPathFromOriginToExit(CharismaPlayerOrigin, null, numberOfMoves); if (SolutionPath != null) { SolutionCell = SolutionPath[SolutionPath.Count - 1]; } else { Reset(); } if (SolutionCell != null) { SolutionCell.CellData.Color = VMEODTwoPersonJobObjectMazePluginCellColors.Blue; SolutionCell.CellData.IsExit = true; MazeGenerated = true; } else { Reset(); } }