Esempio n. 1
0
    private void UpdateUI()
    {
        selectionUI.SetActive(selectedUnit != null);

        if (!setup)
        {
            return;
        }

        if (!selectedUnit)
        {
            return;
        }

        // General
        nameText.text = selectedUnit.monster.GetName();
        int team = (selectedUnit.team == 0) ? 1 : 0;

        teamImage.color = team * UIColor.AllyLight() + (1 - team) * UIColor.EnemyLight();


        // Health
        float healthWidth = 360f * selectedUnit.currentHealth / selectedUnit.monster.MaxHealth();

        health.GetComponent <RectTransform>().sizeDelta = new Vector2(healthWidth, 40);
        healthText.text   = selectedUnit.currentHealth + " / " + selectedUnit.monster.MaxHealth();
        healthImage.color = team * UIColor.Ally() + (1 - team) * UIColor.Enemy();

        // Energy
        float energyWidth = 360f * selectedUnit.currentEnergy / 100f;

        energy.GetComponent <RectTransform>().sizeDelta = new Vector2(energyWidth, 40);
        energyText.text = selectedUnit.currentEnergy + " / " + 100f;

        // Attributes
        strText.text = selectedUnit.monster.GetAttribute(Attribute.Str) + "";
        agiText.text = selectedUnit.monster.GetAttribute(Attribute.Agi) + "";
        wisText.text = selectedUnit.monster.GetAttribute(Attribute.Wis) + "";
        vitText.text = selectedUnit.monster.GetAttribute(Attribute.Vit) + "";
        reaText.text = selectedUnit.monster.GetAttribute(Attribute.Rea) + "";
        wilText.text = selectedUnit.monster.GetAttribute(Attribute.Wil) + "";
    }
Esempio n. 2
0
    private void UpdateUI()
    {
        uiHover.SetActive(IsAlive());

        float   healthPercent = 100f * currentHealth / monster.MaxHealth();
        float   energyPercent = 100f * currentEnergy / 100f;
        Vector3 pos           = transform.position + uiHoverOffset;

        uiHealth.GetComponent <RectTransform>().sizeDelta = new Vector2(healthPercent, 20);
        uiEnergy.GetComponent <RectTransform>().sizeDelta = new Vector2(energyPercent, 20);
        uiHover.transform.position = RectTransformUtility.WorldToScreenPoint(Camera.main, pos);

        if (team == 0)
        {
            uiHealth.GetComponent <Image>().color = UIColor.Ally();
        }
        else
        {
            uiHealth.GetComponent <Image>().color = UIColor.Enemy();
        }

        // Remove nulls
        for (var i = uiDamageText.Count - 1; i > -1; i--)
        {
            if (uiDamageText[i] == null)
            {
                uiDamageText.RemoveAt(i);
            }
        }

        foreach (GameObject go in uiDamageText)
        {
            pos  = go.GetComponent <TextEffectMover>().position;
            pos += transform.position;
            go.transform.position = RectTransformUtility.WorldToScreenPoint(Camera.main, pos);
        }
    }
Esempio n. 3
0
 public static Color AllyLight()
 {
     return(0.5f * UIColor.Ally() + 0.5f * Color.white);
 }