示例#1
0
 public void RemoveText(SkillValueUI skillValueUI)
 {
     storedSkillValueUI.Remove(skillValueUI);
 }
示例#2
0
    public void DisplaySkillValue(Unit caster, Unit target, Transform skillUIValueParent, float val = 0, AttackData attackData = null)
    {
        GameObject   go           = Instantiate(skillUIText, skillUIValueParent.position, Quaternion.identity); // Initialize
        SkillValueUI skillValueUI = go.GetComponent <SkillValueUI>();                                           // Initialize

        target.storedskillValueUI.Add(skillValueUI);                                                            // add skill value ui to unit for on destroy
        go.GetComponent <SkillValueUI>().skillUIManager = this;                                                 // Initialize
        Text text = go.GetComponent <Text>();                                                                   // Initalization

        go.transform.SetParent(skillUIValueParent);                                                             // Set parent
        skillValueUI.index = target.hitRecievedCount;

        // Set text off set
        if (skillUIValueParent.childCount >= 2)
        {
            textOffsetDist = skillUIValueParent.GetChild(skillUIValueParent.childCount - 2).GetComponent <SkillValueUI>().CalculateDistanceTravelled();
        }

        // Reset all texts movement again
        storedSkillValueUI.Add(skillValueUI);
        for (int i = 0; i < storedSkillValueUI.Count; i++)
        {
            storedSkillValueUI[i].EnableMoving();
        }

        Vector3 pos = go.transform.localPosition;                  // Initalization

        pos.x = Random.Range(-xDisplacementStr, xDisplacementStr); // Randomize x position

        // If value is not 0
        if (val != 0)
        {
            text.text = Mathf.Abs(val).ToString();  // Display damage

            // Set font size
            if (attackData.activeSkillValueModifier == attackData.skillData.perfectValueMultiplier)
            {
                text.fontSize = _combatManager.activeAttackBar.skillUIPerfectFontSize;
            }
            else
            {
                text.fontSize = _combatManager.activeAttackBar.skillUIFontSize;
            }

            // Set text UI Colour
            if (attackData.activeSkillValueModifier == attackData.skillData.perfectValueMultiplier)
            {
                text.color = _combatManager.activeAttackBar.perfectSkillUIColour;
            }
            else if (attackData.activeSkillValueModifier == attackData.skillData.greatValueMultiplier)
            {
                text.color = _combatManager.activeAttackBar.greatSkillUIColour;
            }
            else if (attackData.activeSkillValueModifier == attackData.skillData.goodValueMultiplier)
            {
                text.color = _combatManager.activeAttackBar.goodSkillUIColour;
            }
            else if (attackData.activeSkillValueModifier == attackData.skillData.missValueMultiplier)
            {
                text.color = _combatManager.activeAttackBar.missSkillUIColour;
            }
        }
        // If value is 0
        else
        {
            text.fontSize = _combatManager.activeAttackBar.skillUIMissFontSize; // Set font size
            text.text     = "Miss";                                             // Display miss text
            text.color    = _combatManager.activeAttackBar.missSkillUIColour;
        }

        yVal  = (yDistBetweenUI + textOffsetDist) * (target.hitRecievedCount - 1);
        pos.y = go.transform.localPosition.y + yVal;

        go.transform.localPosition = pos;   // Update position

        // Set canvas sorting order to always appear infront of any other skill Text UI.
        skillValueUI.canvas.sortingOrder = target.hitRecievedCount;

        // If this is the last UI of the skill on for this attack
        // Reset hit recieved count for next skill UI
        if (_combatManager.activeSkill)
        {
            if (target.hitRecievedCount == _combatManager.activeSkill.hitsRequired)
            {
                target.hitRecievedCount = 0;
            }
        }
    }