Beispiel #1
0
 // Use this for initialization
 void Start()
 {
     sceneManager      = SMGameEnvironment.Instance.SceneManager;
     levelProgress     = sceneManager.UnmodifiableLevelProgress;
     activeGroup       = sceneManager.Groups [0];
     activeGroupLevels = sceneManager.LevelsInGroup(activeGroup);
 }
Beispiel #2
0
 public SMUnmodifiableLevelProgress(SMILevelProgress levelProgress, SMIConfigurationAdapter configurationAdapter)
 {
     foreach (var level in configurationAdapter.Levels)
     {
         status.Add(level, levelProgress.GetLevelStatus(level));
     }
     foreach (var group in configurationAdapter.Groups)
     {
         groupStatus.Add(group, levelProgress.GetGroupStatus(group));
     }
     hasPlayed      = levelProgress.HasPlayed;
     lastLevelId    = levelProgress.LastLevelId;
     currentLevelId = levelProgress.CurrentLevelId;
 }
Beispiel #3
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();
    }
Beispiel #4
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();
    }
Beispiel #5
0
 // Use this for initialization
 void Start()
 {
     selectionIndex = Array.IndexOf(transitionPrefab, SMGameEnvironment.Instance.SceneManager.TransitionPrefab);
     levelProgress  = SMGameEnvironment.Instance.SceneManager.UnmodifiableLevelProgress;
 }