Beispiel #1
0
    public void Update()
    {
        if (hero.isAlive())
        {
            int           cur     = hero.getCurHealth();
            int           max     = hero.getMaxHealth();
            float         percent = (float)cur / max;
            float         width   = HBD.GetComponent <RectTransform>().rect.width *percent;
            RectTransform ht      = HB.GetComponent <RectTransform>() as RectTransform;
            ht.sizeDelta = new Vector2(width, 7);

            text.text = cur.ToString() + "/" + max.ToString();

            if (hero.getModTime("dodge") != 0)
            {
                buff.text = "+" + hero.getModValue("dodge").ToString() + " Dodge (" + hero.getModTime("dodge").ToString() + " turns) + \n";
            }
            if (hero.getModTime("stun") != 0)
            {
                buff.text = "Stunned (" + hero.getModTime("stun").ToString() + " turns) + \n";
            }
            else
            {
                buff.text = "";
            }
        }
        else
        {
            text.text = "";
            RectTransform ht  = HB.GetComponent <RectTransform>() as RectTransform;
            RectTransform hbt = HBD.GetComponent <RectTransform>() as RectTransform;
            hbt.sizeDelta = new Vector2(0, 0);
            ht.sizeDelta  = new Vector2(0, 0);
        }
    }