Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (mana == null)
        {
            mana = playerObject.GetComponent <PlayerScript>().GetPlayerData().mana;
            return;
        }

        mana.Update();
        //barImage.fillAmount = mana.GetManaNormalized();
        Rect uvRect = barImage.uvRect;

        uvRect.x       -= 0.5f * Time.deltaTime;
        barImage.uvRect = uvRect;

        Vector2 barMaskSizeDelta = maskRectTransform.sizeDelta;

        barMaskSizeDelta.x          = mana.GetManaNormalized() * barMaskWidth;
        maskRectTransform.sizeDelta = barMaskSizeDelta;

        float rand = Random.Range(0, 1f);

        if (rand > 0.98f)
        {
            mana.TrySpendMana(30);
        }
    }
Пример #2
0
 private void FixedUpdate()
 {
     if (mana != null)
     {
         mana.Update(manaText);
         barImage.fillAmount = mana.GetManaNormalized();
     }
 }
Пример #3
0
    private void Update()
    {
        mana.Update();

        Rect uvRect = barRawImage.uvRect;

        uvRect.x          += .2f * Time.deltaTime;
        barRawImage.uvRect = uvRect;

        Vector2 barMaskSizeDelta = barMaskRectTransform.sizeDelta;

        barMaskSizeDelta.x             = mana.GetManaNormalized() * barMaskWidth;
        barMaskRectTransform.sizeDelta = barMaskSizeDelta;

        edgeRectTransform.anchoredPosition = new Vector2(mana.GetManaNormalized() * barMaskWidth, 0);

        edgeRectTransform.gameObject.SetActive(mana.GetManaNormalized() < 1f);
    }