Exemplo n.º 1
0
    /*
     * Changing the style of the font on the font controller requested.
     */
    public void ChangeStyle(string UIElementName, FontStyle style)
    {
        UIFontController fc = GetFontController(UIElementName);

        if (fc == null)
        {
            Debug.LogWarning($"Cannot set font style {style} on font controller {UIElementName}, as it doesn't exist or cannot be found.");
            return;
        }
        fc.ChangeFontStyle(style);
    }
Exemplo n.º 2
0
    /*
     * Setting or changing the value on the font controller requested.
     */
    public void SetValue(string UIElementName, string value)
    {
        UIFontController fc = GetFontController(UIElementName);

        if (fc == null)
        {
            Debug.LogWarning($"Cannot set {value} on font controller {UIElementName}, as it doesn't exist or cannot be found.");
            return;
        }

        fc.SetValue(value);
    }
Exemplo n.º 3
0
    /*
     * Gets the requested font controller; returns null if it doesn't exist
     */
    public UIFontController GetFontController(string UIElementName)
    {
        if (!HasControllers())
        {
            Debug.LogWarning("There is no controllers, this likely isn't attached to the right gameObject!");
            return(null);
        }

        for (int i = 0; i < fontControllers.Count; i++)
        {
            UIFontController fc = fontControllers[i];
            if (fc.name == UIElementName)
            {
                return(fc);
            }
        }

        return(null);
    }
Exemplo n.º 4
0
    void Start()
    {
        activeGunIndex = -1;

        if (!uiController.HasControllers())
        {
            uiController.CollectUIControllers();
        }

        activeAmmoDisplay = uiController.GetFontController("UI_AmmoPos");

        for (int i = 0; i < ammos.Length; i++)
        {
            ammoDisplays[i] = uiController.GetFontController("UI_Ammo" + ammos[i].type.ToString() + "Pos");
        }

        inventoryUpdated = true;
        updateMaxAmmo    = true;
    }
Exemplo n.º 5
0
    void UpdateLoadButtons()
    {
        if (GlobalPlayerVariables.savesExist)
        {
            loadButton.GetComponent <Button>().interactable = true;
            UIFontController loadButtonFont = loadButton.GetComponent <UIFontController>();
            loadButtonFont.ChangeFontMaterial(null);
            loadButtonFont.ForceRefreshText();

            for (int i = 0; i < loadGroup.Length; i++)
            {
                if (GlobalPlayerVariables.saves[i] != null)
                {
                    Button           loadButton = loadGroup[i].GetComponent <Button>();
                    UIFontController controller = loadButton.transform.GetComponent <UIFontController>();
                    loadButton.interactable = true;
                    controller.ChangeFontMaterial(null);
                    controller.SetValue("Save 0" + (i + 1));
                }
            }
        }
    }
Exemplo n.º 6
0
    IEnumerator CountTimeAnimation(UIFontController controller, float maxInSeconds)
    {
        int currentVal = 0;

        while (maxInSeconds >= currentVal)
        {
            if (skipActiveCorutine)
            {
                break;
            }


            controller.SetValue(ConvertTime(currentVal));
            currentVal += countingInterval;

            yield return(new WaitForSeconds(countingSpeedInterval));
        }

        controller.SetValue(ConvertTime(maxInSeconds));
        activeCoroutine = false;
        yield break;
    }
Exemplo n.º 7
0
    IEnumerator CountPercentageAnimation(UIFontController controller, int max)
    {
        int currentVal = 0;

        while (max >= currentVal)
        {
            if (skipActiveCorutine)
            {
                break;
            }


            controller.SetValue(currentVal + "%");
            currentVal += countingInterval;

            yield return(new WaitForSeconds(countingSpeedInterval));
        }

        controller.SetValue(max + "%");
        activeCoroutine = false;
        yield break;
    }
Exemplo n.º 8
0
    /*
     * Creates the ammos, and tried to retrieve the relevant font controller attached.
     */
    // void CreateAmmos(){
    //     // We do the ammo in the inventory because the gun ammo is NOT tied to the gun in Doom, it is tied to the overall inventory.
    //     updateMaxAmmo = true;
    //     AmmoType[] types = (AmmoType[])Enum.GetValues(typeof(AmmoType));

    //     for(int i = 0; i < ammoTypeCount; i++){
    //         AmmoType type = types[i];
    //         Ammo ammo = new Ammo(type);
    //         ammos[i] = ammo;

    //         UIFontController fc = uiController.GetFontController("UI_Ammo" + type.ToString() + "Pos");
    //         ammoDisplays[i] = fc;
    //     }
    // }

    /*
     *  Goes through and updates all the Ammo UI pieces
     */
    public void UpdateGUI()
    {
        if (!inventoryUpdated)
        {
            return;
        }

        inventoryUpdated = false;
        int iterator = 1;

        for (int i = 0; i < ammoDisplays.Length; i++)
        {
            UIFontController cont = ammoDisplays[i];
            if (cont == null)
            {
                continue;
            }

            Ammo ammo = ammos[iterator];

            cont.SetValue(ammo.count + "");

            // we're only updating max ammo once, possibly twice if the player has picked up a backpack
            // so it's not as important to store the all relevant font controllers
            if (updateMaxAmmo)
            {
                uiController.SetValue("UI_Ammo" + ammo.type.ToString() + "MaxPos", ammo.max < 0 ? "" : ammo.max + "");
            }

            iterator++;
        }

        updateMaxAmmo = false;
        if (activeAmmo != null)
        {
            activeAmmoDisplay.SetValue(activeAmmo.count < 0 ? "" : activeAmmo.count + "");
        }
    }