Ejemplo n.º 1
0
    void OnGUI()
    {
        GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height));
        GUILayout.FlexibleSpace();
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.BeginVertical();
        GUILayout.FlexibleSpace();


        GUILayout.Label("Scene Manager Demo - Level Selector");
        GUILayout.FlexibleSpace();
        if (sceneManager.ConfigurationName.Contains("DemoGame"))
        {
            GUILayout.Label("This is the demo version of the game with only 2 levels.");
        }
        else
        {
            GUILayout.Label("This is the full version of the game with 4 levels.");
        }

        GUILayout.FlexibleSpace();

        if (sceneManager.ConfigurationName.Contains("Grouped"))
        {
            foreach (var group in sceneManager.Groups)
            {
                var groupStatus = levelProgress.GetGroupStatus(group);
                if (GUILayout.Button(group + " [" + groupStatus + "]"))
                {
                    activeGroup       = group;
                    activeGroupLevels = sceneManager.LevelsInGroup(activeGroup);
                }
                if (activeGroup == group)
                {
                    RenderLevels(activeGroupLevels);
                }
            }
        }
        else
        {
            RenderLevels(sceneManager.Levels);
        }

        GUILayout.FlexibleSpace();

        if (GUILayout.Button("Reset Progress"))
        {
            sceneManager.LevelProgress.ResetLastLevel();
            foreach (string levelId in sceneManager.Levels)
            {
                sceneManager.LevelProgress.SetLevelStatus(levelId, SMLevelStatus.New);
            }

            foreach (string groupId in sceneManager.Groups)
            {
                sceneManager.LevelProgress.SetGroupStatus(groupId, SMGroupStatus.New);
            }

            levelProgress = sceneManager.UnmodifiableLevelProgress;
        }


        if (GUILayout.Button("Return to main menu"))
        {
            sceneManager.LoadScreen("MainMenu");
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndVertical();

        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        GUILayout.EndArea();
    }
Ejemplo n.º 2
0
    void OnGUI()
    {
        SMSceneManager sceneManager = SMGameEnvironment.Instance.SceneManager;

        GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height));
        GUILayout.FlexibleSpace();
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.BeginVertical();
        GUILayout.FlexibleSpace();


        GUILayout.Label("Scene Manager Demo - Main Menu");
        GUILayout.FlexibleSpace();
        if (sceneManager.ConfigurationName.Contains("DemoGame"))
        {
            GUILayout.Label("This is the demo version of the game with only 2 levels.");
        }
        else
        {
            GUILayout.Label("This is the full version of the game with 4 levels.");
        }

        GUILayout.FlexibleSpace();

        if (GUILayout.Button("New Game"))
        {
            sceneManager.LoadFirstLevel();
        }

        if (levelProgress.HasPlayed)
        {
            if (GUILayout.Button("Continue Playing " + levelProgress.LastLevelId))
            {
                sceneManager.LoadNextLevel();
            }
        }

        if (GUILayout.Button("Reset Progress"))
        {
            sceneManager.LevelProgress.ResetLastLevel();
            foreach (string levelId in sceneManager.Levels)
            {
                sceneManager.LevelProgress.SetLevelStatus(levelId, SMLevelStatus.New);
            }
            foreach (string groupId in sceneManager.Groups)
            {
                sceneManager.LevelProgress.SetGroupStatus(groupId, SMGroupStatus.New);
            }
            levelProgress = sceneManager.UnmodifiableLevelProgress;
        }

        GUILayout.FlexibleSpace();
        GUILayout.Label("Start an already played level...");

        if (GUILayout.Button("Select Level"))
        {
            sceneManager.LoadScreen("LevelSelectionMenu");
        }

        GUILayout.FlexibleSpace();
        GUILayout.Label("Select transition for switching between levels");
        selectionIndex = GUILayout.SelectionGrid(selectionIndex, transitionName, 5);
        sceneManager.TransitionPrefab = transitionPrefab[selectionIndex];
        GUILayout.FlexibleSpace();
        GUILayout.EndVertical();

        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        GUILayout.EndArea();
    }