Пример #1
0
    public void AssignUI()
    {
        unitGO.transform.SetParent(transform);
        //healthImage = unitGO.transform.Find("Health/Current Health Image").GetComponent<Image>();
        //nameText = unitGO.transform.Find("Name/Name Text").GetComponent<Text>();
        //energyImage = unitGO.transform.Find("Energy/Current Energy Image").GetComponent<Image>();
        //manaImage = unitGO.transform.Find("Mana/Current Mana Image").GetComponent<Image>();
        //selectImage = unitGO.transform.Find("Select/Select Image").GetComponent<Image>();

        effectParent = unitGO.transform.Find("Effects").transform; // Assign effects parent

        // If unit type is an enemy, Assign effect UI
        if (unitType == UnitType.ENEMY)
        {
            effectParent.gameObject.SetActive(true);

            for (int i = 0; i < _combatManager.maxEffectsActive; i++)
            {
                effectImages.Add(effectParent.GetChild(i).GetComponent <Image>());

                EffectImage effectImage = effectImages[i].GetComponent <EffectImage>();
                effectImage.unit = this;
                effectImage.ToggleEffectImage(false);
                effectImage.ToggleEffectPowerText(false);
            }
        }
        else
        {
            effectParent.gameObject.SetActive(false);
        }
    }
Пример #2
0
    public void UpdateEffectVisual(Effect effect, int effectPower, int effectDuration, SkillData skillData)
    {
        // If unit is currently already inflicted with an effect, increase the power of the same effect instead of adding a new effect
        for (int i = 0; i < effects.Count; i++)
        {
            if (effect.name == effects[i].name)
            {
                EffectImage effectImage = effectImages[i].GetComponent <EffectImage>();

                effectImage.UpdateEffectPower(effectPower);

                effectImage.Functionality(skillData);

                return;
            }
        }

        // If this effect is unique to the current effects on the unit, spawn another one.
        for (int i = 0; i < effectImages.Count; i++)
        {
            if (!effectImages[i].enabled)
            {
                EffectImage effectImage = effectImages[i].GetComponent <EffectImage>();

                effects.Add(effect);
                effectPowers.Add(effectPower);

                effectImage.UpdateEffectPower(effectPower);
                effectImage.UpdateEffectDuration(effectDuration);
                effectImage.ToggleEffectImage(true);
                effectImage.ToggleEffectPowerText(true);
                effectImage.SetEffectImage(effect.effectImage);

                effectImage.Functionality(skillData);

                return;
            }
        }
    }