Esempio n. 1
0
    void Update()
    {
        Vector2 direction    = new Vector2(0, 0);
        bool    inputPressed = false;

        if (Input.GetButtonDown("Vertical") || Input.GetButtonDown("Horizontal"))
        {
            direction    = direction + getDirection();
            enteringText = false;
            inputPressed = true;
            //      Debug.Log("DirectoinV: " + direction);
        }

        if (inputPressed)
        {
            cm.SetDirection(direction);
        }

        selectedOption = cm.GetSelectedOption();
        string   clientState = "";
        MenuLink ml          = selectedOption.GetComponent <MenuLink>();

        if (ml != null)
        {
            clientState = ml.GetState().ToString();
        }

        if (clientState == "inputfield")
        {
            inputField = ml.GetComponent <InputField>();

            enteringText       = true;
            inputField.enabled = true;
            inputField.ActivateInputField();
        }
        else
        {
            enteringText = false;
            if (inputField != null)
            {
                inputField.enabled = false;
            }
        }

        if (!enteringText)
        {
            if (Input.GetButtonDown("Fire1"))
            {
                switch (clientState)
                {
                case "menu":
                    menuHandler.EnterMenu(ml.GetMenuItem());
                    break;

                case "register":
                    //   SubmitAccount("UsernameRegister", "PasswordRegister", ml, true);
                    var submitobj      = GameObject.Find("Submit");
                    var accountHandler = submitobj.GetComponent <AccountHandler>();
                    accountHandler.SubmitAccount("UsernameRegister", "PasswordRegister", ml, true);
                    break;

                case "login":
                    //    SubmitAccount("UsernameLogin", "PasswordLogin", ml, false);
                    submitobj      = GameObject.Find("Submit");
                    accountHandler = submitobj.GetComponent <AccountHandler>();
                    accountHandler.SubmitAccount("UsernameLogin", "PasswordLogin", ml, false);
                    break;

                case "cancel":
                    menuHandler.GoUpMenu();
                    break;


                default:
                    break;
                }
            }

            if (Input.GetButtonDown("Fire2") && !(MenuPrefabHandler.statusBoxOpened || prefabHandler.ModalBoxHasBeenOpened()))
            {
                menuHandler.GoUpMenu();
            }
        }
        direction = new Vector2(0, 0);
    }