Ejemplo n.º 1
0
    public static GameObject setHudElement(Transform t, String type, String name, int bind, RectTransform beside, float origSpaceNeeded)
    {
        if (type == "Other")
        {
            type = "Gun";             // For these purposes:
        }
        if (OptionsMenu.hudPanels.ContainsKey(type))
        {
            GameObject panel = MonoBehaviour.Instantiate(OptionsMenu.hudPanels[type]);

            // Ordered by add order
            float spaceNeeded = PlayerHud.getHudHeightUsed(t);

            panel.transform.SetParent(t, false);
            // This is a terrible way to set position, but it should work for now.
            if (type == "Cooldown" || type == "Trap" || type == "Gun" || type == "Other" || type == "Generic")               // Traps should probably give more information
            {
                panel.transform.Find("Text").GetComponent <Text> ().text = "(" + OptionsMenu.getBindString(OptionsMenu.binds [bind]) + ") " + name;
            }
            else if (type == "Icicle")
            {
                panel.transform.Find("Text").GetComponent <Text> ().text = "(" + OptionsMenu.getBindString(OptionsMenu.binds [bind]) + ")";
            }
            // Special case:
            if (type == "Gun3Modes")
            {
                panel.transform.Find("Gun1").Find("Text").GetComponent <Text> ().text = "(" + OptionsMenu.getBindString(OptionsMenu.binds [OptionsMenu.PRIMARY_1]) + ") " + name;
                panel.transform.Find("Gun2").Find("Text").GetComponent <Text> ().text = "(" + OptionsMenu.getBindString(OptionsMenu.binds [OptionsMenu.PRIMARY_2]) + ") Accurate-Fire";
                panel.transform.Find("Gun3").Find("Text").GetComponent <Text> ().text = "(" + OptionsMenu.getBindString(OptionsMenu.binds [OptionsMenu.PRIMARY_3]) + ") Conductive-Fire";
            }
            if (beside == null)
            {
                panel.GetComponent <RectTransform> ().anchoredPosition = new Vector2(panel.GetComponent <RectTransform> ().anchoredPosition.x, -280 + (int)(spaceNeeded - origSpaceNeeded));
            }
            else
            {
                panel.GetComponent <RectTransform> ().anchoredPosition = new Vector2(panel.GetComponent <RectTransform> ().anchoredPosition.x, beside.anchoredPosition.y);
            }
            return(panel);
        }
        return(null);
    }