UIComponent.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using FL.Data;
  2. using FL.FGUI;
  3. using XGame.Framework.Nodes;
  4. namespace FL.Nodes.Summon
  5. {
  6. public class UIComponent : NodeComponent
  7. {
  8. public override void OnEnable(object intent)
  9. {
  10. Context.AddListener(EventDefine.SummonInto, OnSummonInto);
  11. Context.AddListener(EventDefine.SummonMwDraw, OnSummonMwDraw);
  12. Context.AddListener(EventDefine.SummonSbDraw, OnSummonSbDraw);
  13. Context.AddListener(EventDefine.AdSuccess, OnAdSuccess);
  14. }
  15. public override void OnDisable()
  16. {
  17. Context.RemoveListener(EventDefine.SummonInto, OnSummonInto);
  18. Context.RemoveListener(EventDefine.SummonMwDraw, OnSummonMwDraw);
  19. Context.RemoveListener(EventDefine.SummonSbDraw, OnSummonSbDraw);
  20. Context.RemoveListener(EventDefine.AdSuccess, OnAdSuccess);
  21. }
  22. private void OnAdSuccess(int eventId, object args)
  23. {
  24. var type = (EPayActionType)args;
  25. if (type == EPayActionType.SummonSbAd)
  26. {
  27. EventSingle.Instance.Notify(EventDefine.SummonSbAd);
  28. OnSummonSbDraw(eventId, args);
  29. }
  30. else if (type == EPayActionType.SummonMwAd)
  31. {
  32. EventSingle.Instance.Notify(EventDefine.SummonMwAd);
  33. OnSummonMwDraw(eventId, args);
  34. }
  35. }
  36. private void OnSummonMwDraw(int eventId, object args)
  37. {
  38. if (Context.UI.IsOpened(UIKeys.PartnerSummonMwResultPanel))
  39. return;
  40. Context.UI.OpenAsync(UIKeys.PartnerSummonMwResultPanel);
  41. }
  42. private void OnSummonSbDraw(int eventId, object args)
  43. {
  44. if (Context.UI.IsOpened(UIKeys.PartnerSummonSbResultPanel))
  45. return;
  46. Context.UI.OpenAsync(UIKeys.PartnerSummonSbResultPanel);
  47. }
  48. private void OnSummonInto(int eventId, object args)
  49. {
  50. Context.UI.OpenAsync(UIKeys.PartnerSummonMainPanel);
  51. }
  52. }
  53. }