public void SpawnText(string message, Vector2 position, float textSize = 72f, CombatHitType type = CombatHitType.Normal, Color?textColor = null)
    {
        GameObject textObj = GetCombatTextObject();

        textObj.SetActive(true);
        textObj.transform.SetParent(this.transform);
        textObj.transform.localScale = Vector3.one;
        textObj.transform.SetAsLastSibling();

        // Init the UI
        textObj.GetComponent <FloatingCombatTextObject>().Initialize(message, position, textSize, type, textColor);
    }
Esempio n. 2
0
    public void Initialize(string message, Vector2 position, float textSize, CombatHitType type, Color?textColor = null)
    {
        progress = 0f;
        trans    = GetComponent <RectTransform>();
        textObj  = GetComponent <TextMeshProUGUI>();

        //trans.anchoredPosition = position;
        trans.position   = position;
        textObj.text     = message;
        textObj.fontSize = textSize;
        color            = textColor ?? Color.white;

        switch (type)
        {
        case CombatHitType.Normal:
            if (textColor == null)
            {
                color = Color.white;
            }
            break;

        case CombatHitType.Critical:
            if (textColor == null)
            {
                color = Color.yellow;
            }
            textObj.fontSize = textSize * 1.2f;
            break;

        case CombatHitType.Glancing:
            if (textColor == null)
            {
                color = Color.red;
            }
            break;
        }
        textObj.color = color;

        StartCoroutine(HandleFloatingAction());
    }