Exemplo n.º 1
0
    public void BindKey(KeyBinderKeys keyName, KeyCode keyBind)
    {
        string key = keyName.ToString();
        Dictionary <string, KeyCode> currentDictionary = MyKeybinds;

        if (key.Contains("ACT"))
        {
            currentDictionary = MyActionbinds;
        }

        if (!currentDictionary.ContainsKey(key))
        {
            currentDictionary.Add(key, keyBind);
        }
        else
        {
            string myKey = currentDictionary.FirstOrDefault(x => x.Value == keyBind).Key;
            if (myKey != null)
            {
                currentDictionary[myKey] = KeyCode.None;
                UIManager.MyInstance.UpdateKeyText(myKey, KeyCode.None);
            }
            currentDictionary[key] = keyBind;
        }

        UIManager.MyInstance.UpdateKeyText(key, keyBind);
        bindName = string.Empty;
    }
Exemplo n.º 2
0
 public static KeyCode GetKeyCode(KeyBinderKeys key)
 {
     return(MyInstance.MyKeybinds[key.ToString()]);
 }