ShowTextWidget.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. }
  73. }