ShowTextWidget.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. using System.Diagnostics;
  2. using Common.Utility.CombatTimer;
  3. using Fort23.Core;
  4. using Fort23.UTool;
  5. using GameLogic.Combat.CombatTool;
  6. using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical;
  7. using UnityEngine;
  8. namespace Fort23.Mono
  9. {
  10. [UIBinding(prefab = "ShowTextWidget")]
  11. public partial class ShowTextWidget : UIComponent
  12. {
  13. private void Init()
  14. {
  15. }
  16. public override void AddEvent()
  17. {
  18. }
  19. public override void DelEvent()
  20. {
  21. }
  22. public override void AddButtonEvent()
  23. {
  24. }
  25. public void ShowUI(CombatHeroEntity heroEntity, long att, HarmType harmType, bool isHarm)
  26. {
  27. Vector3 worldPos = heroEntity.combatHeroGameObject.hpTransform.position;
  28. Vector3 p = UIManager.Instance.CurrCustomCameraStack.camera.WorldToScreenPoint(worldPos);
  29. Vector3 p2 = UIManager.Instance.UICamera.ScreenToWorldPoint(p);
  30. transform.position = p2;
  31. string playName = "show";
  32. if (harmType.HasFlag(HarmType.Shields))
  33. {
  34. text.color = Color.cyan;
  35. }
  36. else if (harmType.HasFlag(HarmType.Buff))
  37. {
  38. playName = "buffshow";
  39. text.color = Color.white;
  40. }
  41. else if (harmType.HasFlag(HarmType.Recover))
  42. {
  43. text.color = Color.green;
  44. }
  45. else if (harmType.HasFlag(HarmType.Default))
  46. {
  47. text.color = Color.red;
  48. }
  49. // if (isHarm)
  50. // {
  51. // text.color=heroEntity.IsEnemy?Color.white:Color.red;
  52. // }
  53. // else
  54. // {
  55. // text.color=Color.green;
  56. // }
  57. text.text = att.ToString();
  58. anim.Play(playName, false);
  59. // if (Animator != null)
  60. // {
  61. // if (harmType.HasFlag(HarmType.BaoJi))
  62. // {
  63. // Animator.Play("ShowTextWidgetBaoji");
  64. // }
  65. // else
  66. // {
  67. // Animator.Play("ShowTextWidgetShow");
  68. // }
  69. // }
  70. CombatTimerManager.Instance.AddTimer(1, delegate { GObjectPool.Instance.Recycle(this); });
  71. }
  72. public void ShowUI(Vector3 p2, long att, HarmType harmType, bool isHarm)
  73. {
  74. // Vector3 worldPos = heroEntity.combatHeroGameObject.hpTransform.position;
  75. // Vector3 p = UIManager.Instance.CurrCustomCameraStack.camera.WorldToScreenPoint(worldPos);
  76. // Vector3 p2 = UIManager.Instance.UICamera.ScreenToWorldPoint(p);
  77. transform.position = p2;
  78. string playName = "show";
  79. if (harmType.HasFlag(HarmType.Shields))
  80. {
  81. text.color = Color.cyan;
  82. }
  83. else if (harmType.HasFlag(HarmType.Buff))
  84. {
  85. playName = "buffshow";
  86. text.color = Color.white;
  87. }
  88. else if (harmType.HasFlag(HarmType.Recover))
  89. {
  90. text.color = Color.green;
  91. }
  92. else if (harmType.HasFlag(HarmType.Default))
  93. {
  94. text.color = Color.red;
  95. }
  96. // if (isHarm)
  97. // {
  98. // text.color=heroEntity.IsEnemy?Color.white:Color.red;
  99. // }
  100. // else
  101. // {
  102. // text.color=Color.green;
  103. // }
  104. text.text = att.ToString();
  105. anim.Play(playName, false);
  106. // if (Animator != null)
  107. // {
  108. // if (harmType.HasFlag(HarmType.BaoJi))
  109. // {
  110. // Animator.Play("ShowTextWidgetBaoji");
  111. // }
  112. // else
  113. // {
  114. // Animator.Play("ShowTextWidgetShow");
  115. // }
  116. // }
  117. CombatTimerManager.Instance.AddTimer(1, delegate { GObjectPool.Instance.Recycle(this); });
  118. }
  119. }
  120. }