Example #1
0
    void OnGUI()
    {
        if (Time.timeScale == 0)
        {
            GUI.Label(new Rect(0, 0, Screen.width, 50), pane, paneLabelStyle);
            //If game is paused, draw pause menu.
            //Heights are 50, 125, 200, 275, 350, 375, etc. Increment by 25.
            switch (pane)
            {
            case "/Pause":
                if (GUI.Button(new Rect((Screen.width / 2) - itemWidth / 2, 50, itemWidth, itemHeight), "Objectives"))
                {
                    pane = "/Objective";
                }
                if (GUI.Button(new Rect((Screen.width / 2) - itemWidth / 2, 125, itemWidth, itemHeight), "Videos"))
                {
                    pane = "/Pause/Videos";
                }
                if (GUI.Button(new Rect((Screen.width / 2) - itemWidth / 2, 200, itemWidth, itemHeight), "Controls"))
                {
                    pane = "/Pause/Controls";
                }
                if (GUI.Button(new Rect((Screen.width / 2) - itemWidth / 2, 275, itemWidth, itemHeight), "Save"))
                {
                    Debug.Log("Saving... Please wait....");
                    SSM.save();
                    Debug.Log("Done saving!");
                }
                if (GUI.Button(new Rect((Screen.width / 2) - itemWidth / 2, 350, itemWidth, itemHeight), "Load"))
                {
                    Debug.Log("Loading... Please wait....");
                    SSM.load();
                    Debug.Log("Done loading!");
                }
                //if (GUI.Button(new Rect((Screen.width/2)-itemWidth/2,275,itemWidth,itemHeight), "Reload")) {
                //	Time.timeScale = 1f;
                //	LevelSerializer.LoadSavedLevelFromFile("SaveGame");
                //}
                break;

            case "/Inventory":
                inventoryView();
                break;

            case "/Objective":
                objectiveView();
                break;

            case "/Pause/Controls":
                if (GUI.Button(new Rect((Screen.width / 2) - itemWidth / 2, 350, itemWidth, itemHeight), "Back"))
                {
                    pane = "/Pause";
                }
                FieldInfo[] variables =
                    typeof(Controls).GetFields(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);                            //.Select(f => f.Name);
                int i = 0;
                // WARNING: REFLECTIONS AHEAD!
                foreach (FieldInfo variable in variables)
                {
                    if (GUI.Button(new Rect(((Screen.width / 4) - 150 / 2) + (Screen.width / 4), 50 + 75 * i, 150, itemHeight), variable.Name + ": " + variable.GetValue(controls)))
                    {
                        print(variable.Name + " >> " + variable.FieldType.ToString());
                        variable.SetValue(controls, ChangeKey((KeyCode)variable.GetValue(controls)));
                    }
                    i++;
                }
                break;

            case "/Pause/Videos":

                string [] fileEntries = Directory.GetFiles(Application.dataPath + "/Resources/Cutscenes/");
                int       o           = 0;
                foreach (string fileName in fileEntries)
                {
                    if (GUI.Button(new Rect((Screen.width / 2) - itemWidth / 2, 50 + 75 * o, itemWidth, itemHeight),
                                   "Video " + o.ToString()))
                    {
                        print(fileName);
                        System.Diagnostics.Process.Start(fileName);
                    }
                    o++;
                }
                if (GUI.Button(new Rect((Screen.width / 2) - itemWidth / 2, 350, itemWidth, itemHeight), "Back"))
                {
                    pane = "/Pause";
                }
                break;

            default:
                if (pane.StartsWith("/Store"))
                {
                    break;
                }
                if (pane.StartsWith("/Dead"))
                {
                    break;
                }
                if (pane.StartsWith("/Convo"))
                {
                    break;
                }
                Debug.Log("Invalid switch - " + pane);
                pane = "/Pause";
                break;
            }
        }
    }