Esempio n. 1
0
 public static void callUpdateAmmoAmount(int index, int ammount)
 {
     if (buttonList[index] is UIbutton)
     {
         UIbutton      tmp  = (UIbutton)buttonList[index];
         buttonDetails dets = tmp.Gamebutton.GetComponent <buttonDetails>();
         dets.updateAmmoAmmount(ammount);
     }
     else if (buttonList[index] is UITrigger)
     {
         UITrigger     tmp  = (UITrigger)buttonList[index];
         buttonDetails dets = tmp.Gamebutton.GetComponent <buttonDetails>();
         dets.updateAmmoAmmount(ammount);
     }
 }
Esempio n. 2
0
 public static void callReload(XboxAxis axis)
 {
     Debug.Log("Reloading!");
     for (int i = 0; i < buttonList.Count; i++)
     {
         if (buttonList[i] is UITrigger)
         {
             UITrigger tmp = (UITrigger)buttonList[i];
             if (tmp.axis == axis)
             {
                 buttonDetails dets = tmp.Gamebutton.GetComponent <buttonDetails>();
                 dets.reload();
                 break;
             }
         }
     }
 }
Esempio n. 3
0
 public static void callReload(XboxKey key)
 {
     Debug.Log("Reloading!");
     for (int i = 0; i < buttonList.Count; i++)
     {
         if (buttonList[i] is UIbutton)
         {
             UIbutton tmp = (UIbutton)buttonList[i];
             if (tmp.key == key)
             {
                 buttonDetails dets = tmp.Gamebutton.GetComponent <buttonDetails>();
                 dets.reload();
                 break;
             }
         }
     }
 }
Esempio n. 4
0
    //single Key method for adding a button
    public static void AddButton(XboxKey key, string weaponName, float refreshTime, int ammo)
    {
        //this method assumes the caller knows what they're doing
        //will add duplicates
        GameObject temp = Instantiate(btnTemplate);

        temp.transform.SetParent(HUDCanvas.transform, false);
        buttonDetails dets       = temp.GetComponent <buttonDetails>();
        RectTransform Rtransform = btnTemplate.GetComponent <RectTransform>();

        dets.updateInfo(weaponName, refreshTime, ammo, true);
        GameObject button = dets.Create(key, Rtransform);
        //change position by size and add padding
        RectTransform newTransform = button.GetComponent <RectTransform>();
        Vector2       anchored     = newTransform.anchoredPosition;
        float         posY;

        if (buttonList.Count == 0)
        {
            posY = startPosition.y;
        }
        else
        {
            posY = startPosition.y - (paddingY * buttonList.Count) - (Rtransform.rect.height * buttonList.Count);
        }
        Debug.Log("posY: " + posY);
        anchored.y = posY;
        anchored.x = startPosition.x;
        newTransform.anchoredPosition = anchored;

        //Set btnData and add it to the list
        UIbutton btnData;

        btnData.key        = key;
        btnData.keyCount   = 1;
        btnData.Gamebutton = button;
        btnData.ammo       = ammo;
        btnData.isAble     = true;
        btnData.fullAmmo   = ammo;
        buttonList.Add(btnData);
    }