public void OnOver(AbstractTextEffect item) { if (uidTextEffectDict.ContainsKey(item)) { uidTextEffectDict.Remove(item); } }
IEnumerator OnPlaySubHP(TextEffectType type, int val, Color color, Transform transform, Vector3 offset, bool isFllow) { int count = 5; if (Mathf.Abs(val) < count) { count = Mathf.Abs(val); } int v = val / count; string txt = ""; if (v >= 0) { txt = "+" + v; } else { txt = "" + v; } for (int i = 0; i < count; i++) { AbstractTextEffect textEffect = Play(type, txt, color, transform, offset, isFllow); yield return(new WaitForSeconds(0.15f)); } }
public void OnItemEnd(AbstractTextEffect item) { if (actives.Contains(item)) { actives.Remove(item); } if (actives.Count == 0) { gameObject.SetActive(false); pool.Push(this); } }
public void Push(AbstractTextEffect item) { UIFllowWorldPosition uiFllow = item.GetComponent <UIFllowWorldPosition>(); if (uiFllow != null) { uiFllow.enabled = false; } pool.Push(item); if (textEffectManager != null) { textEffectManager.OnOver(item); } }
public AbstractTextEffect Play(TextEffectType type, object val, Color color, Transform transform, Vector3 offset, bool isFllow) { AbstractTextEffect textEffect = Play(type, val, color, transform.position + offset, transform); if (isFllow) { UIFllowWorldPosition uiFllow = textEffect.GetComponent <UIFllowWorldPosition>(); if (uiFllow == null) { uiFllow = textEffect.gameObject.AddComponent <UIFllowWorldPosition>(); } uiFllow.targetWorld = transform; uiFllow.offset = offset; uiFllow.enabled = true; } return(textEffect); }
public AbstractTextEffect PlayHP(float hp, Transform transform, Vector3 offset, bool isFllow = false) { int val = (int)hp; if (val == 0) { return(null); } string txt; Color color; if (hp >= 0) { txt = "+" + val; color = colorHP_Plus; } else { txt = "" + val; color = colorHP_Minus; } TextEffectType type = TextEffectType.Normal; AbstractTextEffect textEffect = null; // if(val < 0) // { // type = TextEffectType.Damage; // // StartCoroutine(OnPlaySubHP(type, val, color, transform, offset, isFllow)); // } // else // { // textEffect = OnPlaySubHP(type, txt, color, transform, offset, isFllow); // } if (val < 0) { type = TextEffectType.Damage; } textEffect = Play(type, txt, color, transform, offset, isFllow); return(textEffect); }
public AbstractTextEffect PlayHP(float hp, UnitCtl unitCtl, int fontSize = 30, bool isFllow = false) { if (fontSize <= 30) { return(null); } if (hp == 0) { return(null); } Vector3 offset = Vector3.zero; switch (unitCtl.unitData.unitType) { case UnitType.Build: offset = offset_Build; break; default: offset = offset_Solider; break; } AbstractTextEffect textEffect = PlayHP(hp, unitCtl.transform, offset, isFllow); if (textEffect != null && textEffect is TextEffectNormal) { TextEffectNormal textEffectNormal = (TextEffectNormal)textEffect; textEffectNormal.text.fontSize = fontSize; if (fontSize > 30) { textEffectNormal.randomScale = 0f; } } return(textEffect); }
public AbstractTextEffect Play(TextEffectType type, object val, Color color, Vector3 worldPosition, System.Object uid) { TextEffectPool pool = poolDict[type]; AbstractTextEffect textEffect = null; if (type == TextEffectType.Damage) { if (uidTextEffectDict.ContainsKey(uid)) { textEffect = uidTextEffectDict[uid]; } } if (textEffect == null) { textEffect = pool.Get(); textEffect.transform.SetParent(transform, false); // textEffect.transform.localScale = Vector3.one; textEffect.pool = pool; if (type == TextEffectType.Damage) { uidTextEffectDict.Add(uid, textEffect); } } Vector3 pt = mainCamera.WorldToScreenPoint(worldPosition).SetZ(0); (textEffect.transform as RectTransform).anchoredPosition = pt * rate; textEffect.gameObject.SetActive(true); textEffect.Play(val, color); // Debug.Log("textEffect.Play txt=" + val + " color=" + color ); return(textEffect); }
public void Clear() { prefab = null; pool.Clear(); }