public void ChangeMappingKey(string keyMap)
 {
     //KeyCode newKeyCode = (KeyCode) System.Enum.Parse(typeof(KeyCode), keyCode) ;
     changingBinding = false;
     GameInputManager.SetKeyMap(keyMap, inputKey);
     panelBinding.SetActive(false);
 }
Beispiel #2
0
 // Changes the Binding of Serving by converting certain aspects so it will be compatible with each other and eventually changing the KeyMap
 public void ChangeBindServe()
 {
     PlayerPrefs.SetString("Serve", Serve.text.ToUpper());
     DefaultServeBind.text = PlayerPrefs.GetString("Serve", "Z");
     KCS = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("Serve", "Z"));
     GameInputManager.SetKeyMap("Serve", KCS);
 }
Beispiel #3
0
 // Changes the Binding of Pouring by converting certain aspects so it will be compatible with each other and eventually changing the KeyMap
 public void ChangeBindPour()
 {
     PlayerPrefs.SetString("Pour", Pour.text.ToUpper());
     DefaultPourBind.text = PlayerPrefs.GetString("Pour", "X");
     KCP = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("Pour", "X"));
     GameInputManager.SetKeyMap("Pour", KCP);
 }
Beispiel #4
0
    // Gets the Bindings of Serving and Pouring via converted PlayerPrefs
    public void GetBinds()
    {
        DefaultPourBind.text = PlayerPrefs.GetString("Pour", "X");
        KCP = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("Pour", "X"));
        GameInputManager.SetKeyMap("Pour", KCP);

        DefaultServeBind.text = PlayerPrefs.GetString("Serve", "Z");
        KCS = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("Serve", "Z"));
        GameInputManager.SetKeyMap("Serve", KCS);
    }
Beispiel #5
0
    // Update is called once per frame
    void Update()
    {
        //print(GameInputManager.isConfiguringControls);
        if (isConfiguring)
        {
            foreach (KeyCode kcode in Enum.GetValues(typeof(KeyCode)))
            {
                if (Input.GetKeyUp(kcode))
                {
                    key           = kcode;
                    keyText.text  = kcode.ToString();
                    isConfiguring = false;
                    GetComponent <Image>().color = standardColor;
                    GameInputManager.SetKeyMap(currentSlot.actionName, kcode);
                    GameInputManager.isConfiguringControls = false;
                    break;
                }
            }
            return;
        }

        if (coll.bounds.Contains(Input.mousePosition) && Input.GetMouseButtonDown(0) && !disabled)
        {
            dragging = true;
            GameInputManager.isConfiguringControls = true;
        }
        else
        {
            if (coll.bounds.Contains(Input.mousePosition) && Input.GetMouseButtonUp(0) && dragging)
            {
                SnapToSlot();
                dragging = false;
            }
        }


        if (dragging)
        {
            transform.position = Input.mousePosition;
        }
        else
        {
            //transform.position = currentSlot.position;
            GetComponent <RectTransform>().position = currentSlot.GetComponent <RectTransform>().position;
            //GetComponent<RectTransform>().anchorMax = currentSlot.GetComponent<RectTransform>().anchorMax;
        }
    }
Beispiel #6
0
    void SnapToSlot()
    {
        ControlSlot closestSlot = manager.slotPositions[0];
        float       minDistance = (manager.slotPositions[0].position - transform.position).sqrMagnitude;

        foreach (ControlSlot t in manager.slotPositions)
        {
            float dist = (t.position - transform.position).sqrMagnitude;

            if (dist < minDistance)
            {
                minDistance = dist;
                closestSlot = t;
            }
        }

        if (closestSlot.actionName.Equals(currentSlot.actionName))
        {
            isConfiguring = true;
            GameInputManager.isConfiguringControls = true;
            GetComponent <Image>().color           = editingColor;
        }
        else
        {
            Keybind otherKey = closestSlot.button;

            closestSlot.button = this;
            currentSlot.button = otherKey;
            if (otherKey != null)
            {
                otherKey.SetSlot(currentSlot);
            }
            else
            {
                GameInputManager.SetKeyMap(currentSlot.actionName, KeyCode.None);
            }
            SetSlot(closestSlot);

            GameInputManager.isConfiguringControls = false;
        }
    }
    void FixedUpdate()
    {
        if (!isListening)
        {
            return;
        }

        for (int i = 0; i < values.Length; i++)
        {
            keys[i] = Input.GetKey((KeyCode)values[i]);
            if (keys[i] == true)
            {
                GameInputManager.SetKeyMap(keyToSet, (KeyCode)values[i]);

                if (onKeyChanged != null)
                {
                    onKeyChanged.Invoke();
                }

                isListening = false;
                return;
            }
        }
    }
Beispiel #8
0
 public void SetSlot(ControlSlot slot)
 {
     currentSlot = slot;
     GameInputManager.SetKeyMap(slot.actionName, key);
 }