ActivityGetYuanXiaoTargetView.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System.Collections;
  2. using cfg.GfgCfg;
  3. using UnityEngine;
  4. using UI.ActivityGetYuanXiao;
  5. using FairyGUI;
  6. namespace GFGGame
  7. {
  8. public class ActivityGetYuanXiaoTargetView : BaseWindow
  9. {
  10. private UI_ActivityGetYuanXiaoTargetUI _ui;
  11. private PickUpGameCfg _cfg;
  12. public override void Dispose()
  13. {
  14. if (_ui != null)
  15. {
  16. _ui.Dispose();
  17. _ui = null;
  18. }
  19. base.Dispose();
  20. }
  21. protected override void OnInit()
  22. {
  23. base.OnInit();
  24. packageName = UI_ActivityGetYuanXiaoTargetUI.PACKAGE_NAME;
  25. _ui = UI_ActivityGetYuanXiaoTargetUI.Create();
  26. viewCom = _ui.target;
  27. viewCom.Center();
  28. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  29. modal = true;
  30. _ui.m_btnCancel.onClick.Add(OnBtnCancelClick);
  31. _ui.m_btnConfirm.onClick.Add(OnBtnConfirmClick);
  32. _ui.m_collectList.itemRenderer = CollectionListRenderer;
  33. }
  34. protected override void OnShown()
  35. {
  36. base.OnShown();
  37. _cfg = (PickUpGameCfg)viewData;
  38. _ui.m_c1.selectedIndex = (_cfg.TargetId.Count == 0 ? 1 : 0);
  39. if (_ui.m_c1.selectedIndex == 0)
  40. {
  41. _ui.m_collectList.numItems = _cfg.TargetId.Count;
  42. }
  43. else
  44. {
  45. InitScore();
  46. }
  47. }
  48. private void OnBtnConfirmClick()
  49. {
  50. Hide();
  51. EventAgent.DispatchEvent(ConstMessage.ACTIVITY_GETYUANXIAO_START);
  52. }
  53. private void OnBtnCancelClick()
  54. {
  55. Hide();
  56. }
  57. private void CollectionListRenderer(int index, GObject obj)
  58. {
  59. UI_gameTarget target = UI_gameTarget.Proxy(obj);
  60. target.m_iconType.url = string.Format("ui://ActivityGetYuanXiao/clfg_icon_{0}", _cfg.TargetId[index].Key);
  61. int num = _cfg.TargetId[index].Val;
  62. target.m_num.text = num.ToString();
  63. UI_gameTarget.ProxyEnd();
  64. }
  65. private void InitScore()
  66. {
  67. _ui.m_score.text = _cfg.TargetScore.ToString();
  68. }
  69. }
  70. }