Example #1
0
        public void DisplayCustomTextAbove(CombatEntity entity, string text,
                                           bool bUseUnscaleTime = true, Color customColor = default(Color), int fontSize = -1)
        {
            if (_dmgTextPrefab == null)
            {
                _dmgTextPrefab = Resources.Load <GameObject>("Prefab/DamageText");
            }

            entity.FindCharacterSprite();
            if (entity.CharacterSprite != null)
            {
                Vector2 rendererPosition = entity.CharacterSprite.RendererPosition;
                rendererPosition.y += 1.8f;
                GameObject gameObject = UnityEngine.Object.Instantiate(_dmgTextPrefab, rendererPosition, Quaternion.identity);
                DamageText damageText = gameObject.GetComponent <DamageText>();
                damageText.SetText(text);
                if (customColor.a > 0f)
                {
                    damageText.SetColor(customColor);
                }
                if (fontSize >= 0)
                {
                    damageText.SetSize(fontSize);
                }
                if (!bUseUnscaleTime)
                {
                    gameObject.GetComponentInChildren <UI2DFloatyText>()._useUnscaleTime = false;
                    return;
                }
            }
            else
            {
                Debug.LogError("Missing CharacterSprite");
            }
        }