Example #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) + "";
    }