示例#1
0
 public void endBind()
 {
     binding = false;
     if (textToBind != null && groupToBind != null)
     {
         textToBind.text = groupToBind[0].currentKey.ToString();
     }
     textToBind  = null;
     groupToBind = null;
     mouseDown   = false;
     if (buttonToBind != null)
     {
         buttonToBind.EndBind();
     }
     buttonToBind = null;
 }
示例#2
0
    private void SetUpControlsMenu()
    {
        keybindButtons = new List <KeybindButton>();

        int   controlsCount = System.Enum.GetValues(typeof(GameControls)).Length;
        float yScale        = keybindButtonPrefab.GetComponent <RectTransform>().sizeDelta.y;

        contentWindow.sizeDelta = new Vector2(contentWindow.sizeDelta.x, (controlsCount - 1) * yScale); // count - 1 so ESCAPE can't be rebound

        for (int i = 0; i < controlsCount - 1; i++)
        {
            GameControls  c             = (GameControls)i;
            KeybindButton keybindButton = Instantiate(keybindButtonPrefab, contentWindow);
            keybindButton.SetUp(-yScale * i, c, KeybindingController.GetKeybindName(c));

            keybindButtons.Add(keybindButton);
        }

        uiBlocker.SetActive(false);
        keybindExplanation.SetActive(false);
    }
示例#3
0
    public void startBind(GameObject obj, List <ActionType> group)
    {
        KeybindButton kbb = obj.GetComponent <KeybindButton>();

        if (binding)
        {
            if (kbb.keyLabel == textToBind && group == groupToBind)
            {
                endBind();
                return;
            }
            endBind();
        }

        buttonToBind      = kbb;
        textToBind        = kbb.keyLabel;
        groupToBind       = group;
        binding           = true;
        kbb.keyLabel.text = "Cancel";
        mouseDown         = true;
    }
示例#4
0
    public void CreateKeybindButtons(List <List <ActionType> >[] groups, StateManager.View[] gameModes)
    {
        if (KeyButtonPrefab == null)
        {
            Debug.Log("Keybind Button Prefab was null.");
            return;
        }

        RectTransform buttonSize = KeyButtonPrefab.GetComponent <RectTransform> ();

        int xPos = (int)((Screen.width / 2) * -0.9) - (int)(buttonSize.rect.width * canvas.scaleFactor) + (int)canvas.transform.position.x;
        int yPos = (int)(Screen.height * 0.85);

        foreach (StateManager.View v in gameModes)
        {
            if (groups[(int)v].Count > 0)
            {
                xPos += (int)(buttonSize.rect.width * canvas.scaleFactor * 1.2);
            }
            yPos = (int)(Screen.height * 0.85);
            foreach (List <ActionType> group in groups[(int)v])
            {
                GameObject    keyButton    = Instantiate(KeyButtonPrefab);
                KeybindButton buttonScript = keyButton.GetComponent <KeybindButton> ();
                keyButton.transform.SetParent(keybindMenu.transform, false);
                buttonScript.Init(group);
                keyButton.transform.position = new Vector3(xPos, yPos, 0);
                float realXPos = keyButton.transform.localPosition.x;
                float realYPos = keyButton.transform.localPosition.y;
                yPos -= (int)(buttonSize.rect.height * canvas.scaleFactor * 1.5);

                if (yPos < buttonSize.rect.height * canvas.scaleFactor * 1.5)
                {
                    xPos += (int)(buttonSize.rect.width * canvas.scaleFactor * 1.2);
                    yPos  = (int)(Screen.height * 0.85);
                }
            }
        }
    }