private void Reset()
        {
            MazeGenerated         = false;
            MazeSolved            = false;
            LogicPlayerHasInit    = false;
            CharismaPlayerHasInit = false;

            // indeces: 0 for blue, 1 for green, 2 for red, 3 for yellow as seen in enum: VMEODTwoPersonJobObjectMazePluginCellColors
            ColorCells = new List <AbstractMazeCell <TSOMazeData> >[] { new List <AbstractMazeCell <TSOMazeData> >(MAX_COLORS),
                                                                        new List <AbstractMazeCell <TSOMazeData> >(MAX_COLORS), new List <AbstractMazeCell <TSOMazeData> >(MAX_COLORS + 1),
                                                                        new List <AbstractMazeCell <TSOMazeData> >(MAX_COLORS + 1) };

            // build color pools
            int blanksPerPool = (MAX_ROWS * MAX_COLUMNS - MAX_COLORS * 4) - 2;

            blanksPerPool /= 8;
            AllColorPools  = new List <ColorPool>()
            {
                new ColorPool(VMEODTwoPersonJobObjectMazePluginCellColors.Blank, blanksPerPool),
                new ColorPool(VMEODTwoPersonJobObjectMazePluginCellColors.Blank, blanksPerPool),
                new ColorPool(VMEODTwoPersonJobObjectMazePluginCellColors.Blue, MAX_COLORS),
                new ColorPool(VMEODTwoPersonJobObjectMazePluginCellColors.Blank, blanksPerPool),
                new ColorPool(VMEODTwoPersonJobObjectMazePluginCellColors.Blank, blanksPerPool),
                new ColorPool(VMEODTwoPersonJobObjectMazePluginCellColors.Green, MAX_COLORS),
                new ColorPool(VMEODTwoPersonJobObjectMazePluginCellColors.Blank, blanksPerPool),
                new ColorPool(VMEODTwoPersonJobObjectMazePluginCellColors.Blank, blanksPerPool),
                new ColorPool(VMEODTwoPersonJobObjectMazePluginCellColors.Red, MAX_COLORS + 1),
                new ColorPool(VMEODTwoPersonJobObjectMazePluginCellColors.Blank, blanksPerPool),
                new ColorPool(VMEODTwoPersonJobObjectMazePluginCellColors.Blank, blanksPerPool),
                new ColorPool(VMEODTwoPersonJobObjectMazePluginCellColors.Yellow, MAX_COLORS + 1),
            };

            if (CurrentMaze == null) // first run
            {
                CurrentMaze = AbstractMazeGenerator <TSOMazeData> .GetEmptyMaze(MAX_ROWS, MAX_COLUMNS);

                CurrentMaze.OnMazeGenerated       += MazeGeneratedHandler;
                CurrentMaze.OnFinalProcessingCell += OnProcessedCellHandler;
            }
            // random origin from the 5 choices of enum: BuildFromOrigins
            var origin = Rng.Next(0, (int)BuildFromOrigins.Dead_Center + 1);

            // also resets previous mazes
            CurrentMaze.BuildFromOrigin(origin);
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="state"></param>
        private void GotoState(FreeSOMazeStates state)
        {
            GameState = state;
            Tock      = 0;
            switch (state)
            {
            case FreeSOMazeStates.Lobby:
            {
                ChosenMazeDifficulty = FreeSOMazeDifficulties.Unselected;
                CharismaPlayer?.Reset();
                if (CharismaPlayer?.IsLoaded ?? false)
                {
                    SendLobbyInfoEvent(CharismaPlayer, LogicPlayer);
                }
                LogicPlayer?.Reset();
                if (LogicPlayer?.IsLoaded ?? false)
                {
                    SendLobbyInfoEvent(LogicPlayer, CharismaPlayer);
                }

                if (CurrentMaze != null)
                {
                    CurrentMaze.OnMazeGenerated       -= MazeGeneratedHandler;
                    CurrentMaze.OnFinalProcessingCell -= OnProcessedCellHandler;
                    CurrentMaze.OnDeadEndCreation     -= OnDeadEndHandler;
                    Solution          = null;
                    RawMaze           = null;
                    MazeTimeRemaining = 0;
                    BroadcastSharedEvent("FreeSOMaze_time", BitConverter.GetBytes(MazeTimeRemaining));
                }
                else
                {
                    EveryDeadEndCell = new List <AbstractMazeCell <FreeSOMazeData> >();
                }
                break;
            }

            case FreeSOMazeStates.GeneratingMaze:
            {
                CurrentMaze = AbstractMazeGenerator <FreeSOMazeData> .GetEmptyMaze(MazeSizes[ChosenMazeDifficulty], MazeSizes[ChosenMazeDifficulty]);

                CurrentMaze.OnMazeGenerated       += MazeGeneratedHandler;
                CurrentMaze.OnFinalProcessingCell += OnProcessedCellHandler;
                CurrentMaze.OnDeadEndCreation     += OnDeadEndHandler;
                var origin = ThankU.Next(0, (int)BuildFromOrigins.Dead_Center + 1);
                CurrentMaze.BuildFromOrigin(origin);
                BroadcastSharedEvent("FreeSOMaze_goto_maze", BitConverter.GetBytes((int)ChosenMazeDifficulty));
                break;
            }

            case FreeSOMazeStates.LoadingMaze:
            {
                MazeTimeRemaining = 0;
                int cardinal = 0;
                if (CharismaPlayer != null)
                {
                    cardinal = GetSolutionCardinal(CharismaPlayer);
                    CharismaPlayer.CurrentFacingCardinal = (FreeSOMazeCardinals)Enum.ToObject(typeof(FreeSOMazeCardinals), cardinal);
                    CharismaPlayer.Send("FreeSOMaze_show_maze", CharismaPlayer.GetLocationData((int)FreeSOMazeCardinals.Invalid));
                }
                if (LogicPlayer != null)
                {
                    cardinal = GetSolutionCardinal(LogicPlayer);
                    LogicPlayer.CurrentFacingCardinal = (FreeSOMazeCardinals)Enum.ToObject(typeof(FreeSOMazeCardinals), cardinal);
                    LogicPlayer.Send("FreeSOMaze_show_maze", LogicPlayer.GetLocationData((int)FreeSOMazeCardinals.Invalid));
                }
                break;
            }

            case FreeSOMazeStates.NavigatingMaze:
            {
                CharismaPlayer.Cooldown = GLOBAL_COOLDOWN;
                LogicPlayer.Cooldown    = GLOBAL_COOLDOWN;
                SendAllowMazeEvent(CharismaPlayer, false);
                SendAllowMazeEvent(LogicPlayer, false);
                MazeTimeRemaining = RoundTimes[ChosenMazeDifficulty];
                BroadcastSharedEvent("FreeSOMaze_time", BitConverter.GetBytes(MazeTimeRemaining));
                break;
            }

            case FreeSOMazeStates.Gameover:
            {
                MazeTimeRemaining = 0;
                break;
            }
            }
        }