Esempio n. 1
0
    public static void ProcessSelection(int CurrentSelection)
    {
        switch (CurrentSelection)                          // switch used to process the users selection on the main menu
        {
        case 0:
            //quit the game
                                                #if UNITY_EDITOR
            UnityEditor.EditorApplication.isPlaying = false;
                                                #else
            Application.Quit();
                                                #endif
            break;

        case 1:
            Application.LoadLevel("MainGame");                                      // loads the main game
            break;

        case 2:
            MenuStateScript.MenuStateChange(1);                                      // changes to the option menu state
            break;

        case 3:
            MenuStateScript.MenuStateChange(2);                                      // changes to the leaderboard menu state
            break;
        }
    }
    public static void ProcessSelection(int CurrentSelection)
    {
        switch (CurrentSelection)
        {
        case 0:                        //aspect ratio
            // loop around the subsection for aspect ratio
            if (SubSelection > 4)
            {
                SubSelection = 0;
            }
            if (SubSelection < 0)
            {
                SubSelection = 4;
            }

            AspectRatioCounter = SubSelection;
            Debug.Log("Aspect Ratio set to : " + AspectRatioCounter);
            AspectRatioObject.GetComponent <Text> ().text = AspectRatios [AspectRatioCounter];           // changes the text on the GUI
            break;

        case 1:                        //resolution
            // loop around the subsection for Resolutions
            if (SubSelection > 3)
            {
                SubSelection = 0;
            }
            if (SubSelection < 0)
            {
                SubSelection = 3;
            }

            ResolutionsCounter = SubSelection;
            Debug.Log("Resolution set to : " + ResolutionsCounter);
            ResolutionsObject.GetComponent <Text> ().text = Resolutions [ResolutionsCounter];           // changes the text on the GUI
            break;

        case 2:                        //full screen
            // loop around the subsection for full screen
            if (SubSelection > 1)
            {
                SubSelection = 0;
            }
            if (SubSelection < 0)
            {
                SubSelection = 1;
            }

            FullScreen = !FullScreen;                                             // toggles full screen
            FullScreenObject.GetComponent <Text> ().text = FullScreen.ToString(); // changes the text on the GUI
            break;

        case 3:                        //Blood
            // loop around the subsection for blood
            if (SubSelection > 3)
            {
                SubSelection = 0;
            }
            if (SubSelection < 0)
            {
                SubSelection = 3;
            }

            BloodCounter = SubSelection;
            BloodObject.GetComponent <Text> ().text = Blood [BloodCounter];                                    // changes the text on the GUI
            break;

        case 4:
            //change aspect ratio resolution full screen and blood here

            //aspect ratio
            switch (AspectRatioCounter)
            {
            case 0:                                    //5:4
                Debug.Log("Aspect Ratio 5:4 Selected");
                AspectRatioChange(1.25f);
                break;

            case 1:                                    //4:3
                Debug.Log("Aspect Ratio 4:3 Selected");
                AspectRatioChange(1.3333f);
                break;

            case 2:                                    //16:10
                Debug.Log("Aspect Ratio 16:10 Selected");
                AspectRatioChange(1.6f);
                break;

            case 3:                                    //5:3
                Debug.Log("Aspect Ratio 5:3 Selected");
                AspectRatioChange(1.66666666667f);
                break;

            case 4:                                    //16:9
                Debug.Log("Aspect Ratio 16:9 Selected");
                AspectRatioChange(1.78f);
                break;
            }

            //resolution and full screen "Screen.fullScreen = FullScreen;" would be just full screen
            switch (ResolutionsCounter)
            {
            case 0:                                     //1024x768
                Screen.SetResolution(1024, 768, FullScreen);
                break;

            case 1:                                     //1280x1024
                Screen.SetResolution(1280, 1024, FullScreen);
                break;

            case 2:                                    //1680,1050
                Screen.SetResolution(1680, 1050, FullScreen);
                break;

            case 3:                                    //1920x1080
                Screen.SetResolution(1920, 1080, FullScreen);
                break;

            case 4:                                    //1920x1200
                Screen.SetResolution(1920, 1200, FullScreen);
                break;
            }

            //Blood
            switch (BloodCounter)
            {
            case 0:                                    //Red

                break;

            case 1:                                    //Green

                break;

            case 2:                                    //Off

                break;
            }
            MenuStateScript.MenuStateChange(0);                                      // return to menu
            break;
        }
    }
    // Update is called once per frame
    void Update()
    {
        //turning left and right
        if (Turned == false)
        {
            if (WheelchairMovementScript.CurrentAngle < 315 && WheelchairMovementScript.CurrentAngle > 180)
            {
                Turned = true;
                if (WheelchairMovementScript.MovedFowards == true && Options.activeSelf)
                {
                    MenuOptionsSelectionScript.SubSelection--;
                    MenuOptionsSelectionScript.ProcessSelection(CurrentSelection);
                }
                else
                {
                    CurrentSelection--;
                    ChangeMenuSelection();
                    Debug.Log(CurrentSelection + "" + Turned);
                }
            }
            if (WheelchairMovementScript.CurrentAngle > 45 && WheelchairMovementScript.CurrentAngle < 180)
            {
                Turned = true;
                if (WheelchairMovementScript.MovedFowards == true && Options.activeSelf)
                {
                    MenuOptionsSelectionScript.SubSelection++;
                    MenuOptionsSelectionScript.ProcessSelection(CurrentSelection);
                }
                else
                {
                    CurrentSelection++;
                    ChangeMenuSelection();
                    Debug.Log(CurrentSelection + "" + Turned);
                }
            }
        }
        else if (Turned == true)
        {
            if (WheelchairMovementScript.CurrentAngle > 340 || WheelchairMovementScript.CurrentAngle < 20)
            {
                Turned = false;
                Debug.Log(Turned);
            }
        }

        //moving backwards and fowards
        if (reset == false)
        {
            if (WheelchairMovementScript.MovedFowards == true)
            {
                Debug.Log("MovedFowards Equals true");

                //main menu
                if (MainMenu.activeSelf)
                {
                    MenuMainSelectionScript.ProcessSelection(CurrentSelection);
                    CurrentSelection = 0;                                                             // reset the selection for next menu
                    MenuSwitch       = true;
                }
                //options menu
                if (Options.activeSelf)
                {
                    Debug.Log("Options" + CurrentSelection);

                    MenuOptionsSelectionScript.ProcessSelection(CurrentSelection);
                }

                if (Leaderboard.activeSelf && MenuSwitch != true)
                {
                    MenuStateScript.MenuStateChange(0);                                                              // changes to the Main menu state
                    MenuSwitch = true;
                }
                reset = true;
            }
        }
        else
        {
            if (WheelchairMovementScript.MovedFowards == false)
            {
                Debug.Log("MovedFowards Equals false");
                if (Options.activeSelf)
                {
                    MenuOptionsSelectionScript.SubSelection = 0;                                                             // reset the subselection
                }
                MenuSwitch = false;
                reset      = false;
            }
        }
        if (Leaderboard.activeSelf)
        {
            UnityEngine.EventSystems.EventSystem.current.SetSelectedGameObject(MainMenu_Button2); // sets he only button on the leaderboard to active
        }
        OnGUI();                                                                                  // used to display variable to the screen to debug
    }