コード例 #1
0
    void SetMessageCursorMode(string Mode)
    {
        if (Mode == "Confirm")
        {
            MessageCursorIsSelecting              = false;
            MessageCursorRenderer.sprite          = ConfirmationCursor;
            MessageCursor.transform.localPosition = new Vector3(0.9f, -0.2f, 0);
        }
        else if (Mode == "Select")
        {
            MessageCursorIsSelecting              = true;
            MessageCursorRenderer.sprite          = SelectionCursor;
            MessageCursor.transform.localPosition = new Vector3(-0.75f, -0.17f, 0);
            CurrentMenuState = MenuState;

            OptionA.SetActive(true);
            OptionB.SetActive(true);
        }
    }
コード例 #2
0
    public void ToggleMenu()
    {
        ToggleActive(Menu);
        ToggleActive(MenuCursor);
        Message.SetActive(false);
        MessageCursor.SetActive(false);
        OptionA.SetActive(false);
        OptionB.SetActive(false);
        AricomonSpawner asp = AricomonSpawner.GetComponent(typeof(AricomonSpawner)) as AricomonSpawner;

        if (PlayerScript.speed == 0)
        {
            PlayerScript.speed = 5;
            asp.OpenMenu       = false;
        }
        else
        {
            PlayerScript.speed = 0;
            asp.OpenMenu       = true;
        }
    }
コード例 #3
0
    void Update()
    {
        if (Input.GetButtonDown("Jump"))
        {
            ToggleMenu();
        }

        if (MenuCursor.activeSelf)
        {
            if (Input.GetButtonDown("Up") && MenuState != 0)   // Moves cursor with up arrow
            {
                MenuState--;
                MenuCursor.transform.Translate(new Vector3(0, 0.48f, 0));
            }
            else if (Input.GetButtonDown("Down") && MenuState != 6)     // Moves cursor with down arrow
            {
                MenuState++;
                MenuCursor.transform.Translate(new Vector3(0, -0.48f, 0));
            }

            if (Input.GetAxis("Mouse X") != 0 || Input.GetAxis("Mouse Y") != 0)
            {
                if (Input.mousePosition.y < 480)
                {
                    MenuState = 6;
                    MenuCursor.transform.localPosition = new Vector3(-1.3f, -1.44f, 0);
                }
                else if (Input.mousePosition.y < 515)
                {
                    MenuState = 5;
                    MenuCursor.transform.localPosition = new Vector3(-1.3f, -0.96f, 0);
                }
                else if (Input.mousePosition.y < 550)
                {
                    MenuState = 4;
                    MenuCursor.transform.localPosition = new Vector3(-1.3f, -0.48f, 0);
                }
                else if (Input.mousePosition.y < 585)
                {
                    MenuState = 3;
                    MenuCursor.transform.localPosition = new Vector3(-1.3f, 0, 0);
                }
                else if (Input.mousePosition.y < 620)
                {
                    MenuState = 2;
                    MenuCursor.transform.localPosition = new Vector3(-1.3f, 0.48f, 0);
                }
                else if (Input.mousePosition.y < 655)
                {
                    MenuState = 1;
                    MenuCursor.transform.localPosition = new Vector3(-1.3f, 0.96f, 0);
                }
                else
                {
                    MenuState = 0;
                    MenuCursor.transform.localPosition = new Vector3(-1.3f, 1.44f, 0);
                }

                if (OptionA.activeSelf)
                {
                    if (Input.mousePosition.x <= 325)
                    {
                        OptionState = 0;
                        MessageCursor.transform.localPosition = new Vector3(-0.75f, -0.17f, 0);
                    }
                    else
                    {
                        OptionState = 1;
                        MessageCursor.transform.localPosition = new Vector3(0.05f, -0.17f, 0);
                    }
                }
            }

            if (Input.GetButtonDown("Fire1") || Input.GetMouseButtonDown(0))
            {
                ToggleActive(Message);
                ToggleActive(MessageCursor);

                OptionA.SetActive(false);
                OptionB.SetActive(false);

                if (Message.activeSelf)
                {
                    switch (MenuState)
                    {
                    case 3:
                        SaveScript.Save("firedSave");     // Saves the game
                        MessageText.text = "The game was saved!";
                        SetMessageCursorMode("Confirm");
                        break;

                    case 4:
                        if (File.Exists(Application.persistentDataPath + "/firedSave"))       // Loads save data
                        {
                            LoadScript.Load("firedSave");
                        }
                        MessageText.text = "The game was loaded!";
                        SetMessageCursorMode("Confirm");
                        break;

                    case 6:
                        MessageText.text = "Are you sure you want to quit?";
                        SetMessageCursorMode("Select");
                        break;

                    default:
                        MessageText.text = "This feature has not been implemented yet.";
                        SetMessageCursorMode("Confirm");
                        break;
                    }
                }
                else
                {
                    switch (CurrentMenuState)
                    {
                    case 6:
                        switch (OptionState)
                        {
                        case 0:
                            Application.Quit();
                            break;

                        default:
                            break;
                        }
                        break;
                    }
                }
            }
        }

        if (MessageCursor.activeSelf)
        {
            if (MessageCursorIsSelecting)
            {
                if (Input.GetButtonDown("Left") && OptionState != 0)
                {
                    OptionState--;
                    MessageCursor.transform.localPosition = new Vector3(-0.75f, -0.17f, 0);
                }
                else if (Input.GetButtonDown("Right") && OptionState != 1)
                {
                    OptionState++;
                    MessageCursor.transform.localPosition = new Vector3(0.05f, -0.17f, 0);
                }
            }
            else
            {
                if (MessageCursor.transform.localPosition.y >= -0.17f)
                {
                    MessageCursorIsGoingUp = false;
                }
                else if (MessageCursor.transform.localPosition.y <= -0.2f)
                {
                    MessageCursorIsGoingUp = true;
                }

                if (MessageCursorIsGoingUp)
                {
                    MessageCursor.transform.Translate(new Vector3(0, 0.0055f, 0));
                }
                else
                {
                    MessageCursor.transform.Translate(new Vector3(0, -0.0055f, 0));
                }
            }
        }
    }