HpAddEntityView.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using UnityEngine;
  3. using XGame.Database;
  4. using XGame.Framework.Map;
  5. using XGame.Framework.ObjectCollection;
  6. namespace FL.Map.UI
  7. {
  8. public class HpAddEntityView : EntityView<HpAddEntityVM>
  9. {
  10. protected override void OnEnable(object intent)
  11. {
  12. }
  13. protected override void OnDisable()
  14. {
  15. }
  16. protected override void OnDispose()
  17. {
  18. }
  19. public void ShowValue(int value, Vector3 position, EElementType elementType, Action callback)
  20. {
  21. VM.HpText.text = /*value > 0 ? $"+{value}" : */value.ToString();
  22. VM.HpText.color = value > 0 ? ColorDefine.green : elementType.ToDamageColor();
  23. VM.Tr.localPosition = position;
  24. var timer = Context.Time.AddDelayTimer(500, callback);
  25. }
  26. }
  27. public class HpAddEntityVM : EntityViewModel
  28. {
  29. public UnityEngine.UI.Text HpText { get; private set; }
  30. public Transform Root { get; private set; }
  31. public Animation AniRoot { get; private set; }
  32. protected override void OnInit(IObjectCollector collector)
  33. {
  34. HpText = collector.GetComponent<UnityEngine.UI.Text>("HpText");
  35. Root = collector.GetGameObject("Root").transform;
  36. AniRoot = collector.GetComponent<Animation>("AniRoot");
  37. }
  38. }
  39. }