示例#1
0
    public void ShowDmgText(Vector3 pos, float dmg, int type, bool isReinforced)
    {
        GameObject text = GameManager.Inst().ObjManager.MakeObj("DamageText");

        text.transform.position = pos;
        text.SetActive(true);
        DamageText dmgText = text.GetComponent <DamageText>();

        if (type == (int)DamageType.PLAYERHEAL)
        {
            dmgText.SetPlusText(dmg);
        }
        else
        {
            dmgText.SetText(dmg);
        }
        dmgText.SetSize(dmgText.DefaultSize);
        dmgText.SetColor(type);

        if (isReinforced)
        {
            //text.transform.localScale = Vector3.one * 2.0f;
            dmgText.SetSize(48);
            dmgText.SetColor((int)DamageType.REINFORCED);
        }

        ActivationTimer timer = text.GetComponent <ActivationTimer>();

        timer.IsStart = true;
    }
示例#2
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");
            }
        }