ShowTextWidget.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. if (Animator != null)
  39. {
  40. if (harmType.HasFlag(HarmType.BaoJi))
  41. {
  42. Animator.Play("ShowTextWidgetBaoji");
  43. }
  44. else
  45. {
  46. Animator.Play("ShowTextWidgetShow");
  47. }
  48. }
  49. CombatTimerManager.Instance.AddTimer(1, delegate
  50. {
  51. GObjectPool.Instance.Recycle(this);
  52. });
  53. }
  54. }
  55. }