예제 #1
0
    // Use this for initialization
    void Start()
    {
        ActionBarControl.OnButtonPress += this.ReceiveInput;
        ActionBarActions.OnBarAction   += this.CheckWindowState;

        GameObject          getMaxButtons       = GameObject.Find("GUIMenuControls");
        ActionBarOptionsGUI actionBarOptionsGUI = getMaxButtons.GetComponent <ActionBarOptionsGUI> ();

        buttonActions = new string[actionBarOptionsGUI.maxButtonsPerBar];

        this.toolbarID = this.gameObject.name;

        if (this.toolbarID == "Menu Bar")
        {
            for (int i = 0; i < actionBarOptionsGUI.toolbarValues[0].z; i++)
            {
                this.buttonActions[i] = "GM" + (i + 1);
            }
        }

        if (this.toolbarID == "PlayerMovement")
        {
            this.buttonActions[0] = "Forward";
            this.buttonActions[1] = "Backward";
            this.buttonActions[2] = "StrafeLeft";
            this.buttonActions[3] = "StrafeRight";
            this.buttonActions[4] = "Jump";
        }

        UpdateWindowSizes();
    }
예제 #2
0
    public static event actionButtonPress OnButtonPress; // Broadcast when a button is pressed or activated via a binding

    // Use this for initialization
    void Start()
    {
        ActionBarOptionsGUI.OnValuesChange += this.UpdateBarValues;
        ActionBarOptionsGUI.OnKeybindMode  += this.KeybindMode;
        ActionBarControl.OnKeybindChange   += this.DuplicateBindCatcher;

        inputKey = "";

        toolbarID = this.gameObject.name;

        // Determine which memory location of each array holds the information needed for this bar

        if (this.toolbarID != "Menu Bar" && this.toolbarID != "PlayerMovement")
        {
            barID = System.Convert.ToInt16(this.toolbarID.Substring(9));
        }
        else if (this.toolbarID == "PlayerMovement")
        {
            barID = 1;
        }
        else
        {
            barID = 0;
        }
        this.screenText = new GUIStyle();
        this.screenText.normal.textColor = Color.white;
        this.screenText.fontSize         = 25;
        this.screenText.alignment        = TextAnchor.MiddleCenter;

        // Find and Get values needed from action bar options class
        GameObject          getValues           = GameObject.Find("GUIMenuControls");
        ActionBarOptionsGUI actionBarOptionsGUI = getValues.GetComponent <ActionBarOptionsGUI> ();

        // Assign array sizes for bindings / ability storage
        maxButtons = System.Convert.ToInt16(actionBarOptionsGUI.maxButtonsPerBar);

        this.keyBinding = new string[maxButtons];
        //this.buttonAction = new string[maxButtons];

        if (this.toolbarID == "Menu Bar")
        {
            for (int i = 0; i < actionBarOptionsGUI.toolbarValues[0].z; i++)
            {
                this.keyBinding[i] = "F" + (i + 1);
            }
        }

        if (this.toolbarID == "PlayerMovement")
        {
            this.keyBinding[0] = "w";
            this.keyBinding[1] = "s";
            this.keyBinding[2] = "a";
            this.keyBinding[3] = "d";
            this.keyBinding[4] = "Space";
        }

        UpdateBarValues();
    }
예제 #3
0
    // Update action bar settings from action bar options
    void UpdateBarValues()
    {
        // Find and Get values needed from action bar options class
        GameObject          getValues           = GameObject.Find("GUIMenuControls");
        ActionBarOptionsGUI actionBarOptionsGUI = getValues.GetComponent <ActionBarOptionsGUI> ();

        this.toolbarValues = actionBarOptionsGUI.toolbarValues [barID];
        this.barPadding    = actionBarOptionsGUI.barPadding [barID];

        // Calc width and height of bar based on button size and bar padding
        this.barWidth  = (((this.toolbarValues.x + this.barPadding) * this.toolbarValues.z) + barPadding) + 10;
        this.barHeight = this.toolbarValues.y + (this.barPadding * 2);

        // If bar Anchor as already been assigned a location do not reassign
        if (this.barAnchorX == 0)
        {
            this.barAnchorX = (Screen.width / 2) - this.barWidth / 2;
            if (this.barID == 0)
            {
                this.barAnchorY = Screen.height - (this.barHeight * (this.barID + 1));
            }
            else
            {
                this.barAnchorY = Screen.height - (this.barHeight * this.barID);
            }
        }
        // Setup action bar window for this action bar
        this.actionbarWindow = new Rect(this.barAnchorX, this.barAnchorY, this.barWidth, this.barHeight);

        // Determine if bindings are changable
        this.setKeyBindings = actionBarOptionsGUI.setKeyBindings;

        for (int i = 0; i < maxButtons; i++)
        {
            if (i > this.toolbarValues.z - 1)
            {
                this.keyBinding[i] = "";
            }
        }
    }