ShowTextWidget.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using Common.Utility.CombatTimer;
  2. using Fort23.Core;
  3. using Fort23.UTool;
  4. using GameLogic.Combat.CombatTool;
  5. using UnityEngine;
  6. namespace Fort23.Mono
  7. {
  8. [UIBinding(prefab = "ShowTextWidget")]
  9. public partial class ShowTextWidget : UIComponent
  10. {
  11. private void Init()
  12. {
  13. }
  14. public override void AddEvent()
  15. {
  16. }
  17. public override void DelEvent()
  18. {
  19. }
  20. public override void AddButtonEvent()
  21. {
  22. }
  23. public void ShowUI(CombatHeroEntity heroEntity,long att , HarmType harmType, bool isHarm)
  24. {
  25. Vector3 worldPos =heroEntity.combatHeroGameObject.hpTransform.position;
  26. Vector3 p = UIManager.Instance.CurrCustomCameraStack.camera.WorldToScreenPoint(worldPos);
  27. Vector3 p2 = UIManager.Instance.UICamera.ScreenToWorldPoint(p);
  28. transform.position = p2;
  29. if (isHarm)
  30. {
  31. text.color=heroEntity.IsEnemy?Color.white:Color.red;
  32. }
  33. else
  34. {
  35. text.color=Color.green;
  36. }
  37. text.text = att.ToString();
  38. anim.Play("show",false);
  39. // if (Animator != null)
  40. // {
  41. // if (harmType.HasFlag(HarmType.BaoJi))
  42. // {
  43. // Animator.Play("ShowTextWidgetBaoji");
  44. // }
  45. // else
  46. // {
  47. // Animator.Play("ShowTextWidgetShow");
  48. // }
  49. // }
  50. CombatTimerManager.Instance.AddTimer(1, delegate
  51. {
  52. GObjectPool.Instance.Recycle(this);
  53. });
  54. }
  55. }
  56. }