Beispiel #1
0
    public void LoadMazeLevel(List <string> arguments)
    {
        if (MazeLevelGameplayManager.Instance == null)
        {
            if (PersistentGameManager.CurrentSceneType == SceneType.Overworld)
            {
                Logger.Warning("We are currently in the overworld scene. Switching scenes.");
                PersistentGameManager.SetLastMazeLevelName("default");
                PersistentGameManager.SetCurrentSceneName("default");

                PhotonNetwork.LoadLevel("Maze"); // TODO this loads the default maze, should load specific maze
            }
            else
            {
                Logger.Error("Cannot find MazeLevelManager. Returning.");
            }
            return;
        }

        MazeLevelData mazeLevelData;

        if (arguments.Count < 2)
        {
            PersistentGameManager.SetLastMazeLevelName("default");
            PersistentGameManager.SetCurrentSceneName("default");

            mazeLevelData = MazeLevelLoader.LoadMazeLevelData(PersistentGameManager.CurrentSceneName);
            MazeLevelLoader.LoadMazeLevel(mazeLevelData);
            return;
            //string message = "The command '<color=" + ConsoleConfiguration.HighlightColour + ">load maze</color>' needs an additional argument with the name of the maze level";
            //Logger.Warning(message);

            //message += "\nThe Currently available levels are: \n";
            //message = MazeLevelLoader.GetAllMazeLevelNamesForPrint(message);
            //throw new NotEnoughArgumentsConsoleException(message);
        }

        string mazeName = arguments[1];

        mazeLevelData = MazeLevelLoader.LoadMazeLevelData(mazeName);

        if (mazeLevelData == null && Console.Instance.ConsoleState != ConsoleState.Closed)
        {
            string printLine = "<color=" + ConsoleConfiguration.HighlightColour + ">" + arguments[1] + "</color> is not a known maze level and cannot be loaded.\n\n";
            printLine += "The Currently available levels are: \n";
            printLine  = MazeLevelLoader.GetAllMazeLevelNamesForPrint(printLine);
            Console.Instance.PrintToReportText(printLine);
        }

        PersistentGameManager.SetLastMazeLevelName(mazeName);
        PersistentGameManager.SetCurrentSceneName(mazeName);

        mazeLevelData = MazeLevelLoader.LoadMazeLevelData(PersistentGameManager.CurrentSceneName);
        MazeLevelLoader.LoadMazeLevel(mazeLevelData);
    }
Beispiel #2
0
    public void Start()
    {
        switch (PersistentGameManager.CurrentSceneType)
        {
        case SceneType.Overworld:
            Logger.Log("instantiate overworld sprites, tiles and characters");
            if (PersistentGameManager.SceneLoadOrigin == SceneLoadOrigin.Gameplay)
            {
                if (PersistentGameManager.OverworldName == "")
                {
                    PersistentGameManager.SetOverworldName("overworld");
                }

                string overworldName = PersistentGameManager.OverworldName;
                Logger.Log($"We will load the maze '{overworldName}'");
                OverworldData startUpOverworldData = OverworldLoader.LoadOverworldData(overworldName);

                if (startUpOverworldData == null)
                {
                    Logger.Error("Could not find the default overworld for startup");
                }

                OverworldLoader.LoadOverworld(startUpOverworldData);

                if (OverworldGameplayManager.Instance.Overworld == null)
                {
                    Logger.Log(Logger.Initialisation, "No overworld loaded on startup. Returning");
                    return;
                }
            }     // We loaded a overworld scene through the editor. Set up an empty grid for in the editor
            else
            {
                Logger.Log("create empty grid");
                EditorCanvasUI.Instance.OverworldModificationPanel.GenerateTiles();
            }
            break;

        case SceneType.Maze:
            // We loaded a maze scene through the game. Set up the maze level
            if (PersistentGameManager.SceneLoadOrigin == SceneLoadOrigin.Gameplay)
            {
                if (PersistentGameManager.CurrentSceneName == "")
                {
                    PersistentGameManager.SetCurrentSceneName("default");
                }

                string mazeName = PersistentGameManager.CurrentSceneName;

                PersistentGameManager.SetLastMazeLevelName(mazeName);
                Logger.Log($"We will load the maze '{mazeName}'");
                MazeLevelData startUpMazeLevelData = MazeLevelLoader.LoadMazeLevelData(mazeName);

                if (startUpMazeLevelData == null)
                {
                    Logger.Error($"Could not find the level {mazeName} for startup. Will load defult level instead.");
                    mazeName             = "default";
                    startUpMazeLevelData = MazeLevelLoader.LoadMazeLevelData(mazeName);
                }

                MazeLevelLoader.LoadMazeLevel(startUpMazeLevelData);

                if (CurrentGameLevel == null)
                {
                    Logger.Log(Logger.Initialisation, "No level loaded on startup. Returning");
                    return;
                }
                if (CurrentGameLevel.PlayerCharacterSpawnpoints.Count == 0)
                {
                    return;
                }

                PlayableLevelNames = MazeLevelLoader.GetAllPlayableLevelNames();
            }     // We loaded a maze scene through the editor. Set up an empty grid for in the editor
            else
            {
                Logger.Log("create empty grid");
                EditorCanvasUI.Instance.MazeModificationPanel.GenerateTiles();
            }
            break;

        default:
            Logger.Error($"Scenetype {PersistentGameManager.CurrentSceneType} is not implemented yet");
            break;
        }
    }