FlipGameStartView.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. using System;
  2. using System.Collections.Generic;
  3. using ET;
  4. using FairyGUI;
  5. using UI.MiniGame;
  6. using UnityEngine;
  7. namespace GFGGame
  8. {
  9. public class FlipGameStartView : BaseView
  10. {
  11. private UI_FlipGameStartUI _ui;
  12. //后续这里改成读表内容
  13. private List<string> name = new List<string>(){ "翻牌", "2048" };
  14. private List<string> CustemsDesc = new List<string>()
  15. {
  16. "首次评价达到卓越奖励:",
  17. "首次评价达到优秀奖励:",
  18. "首次评价达到良好奖励:",
  19. };
  20. private int currentGame = 0;
  21. public override void Dispose()
  22. {
  23. if (_ui != null)
  24. {
  25. _ui.Dispose();
  26. _ui = null;
  27. }
  28. base.Dispose();
  29. }
  30. protected override void OnInit()
  31. {
  32. base.OnInit();
  33. packageName = UI_FlipGameStartUI.PACKAGE_NAME;
  34. _ui = UI_FlipGameStartUI.Create();
  35. this.viewCom = _ui.target;
  36. isfullScreen = true;
  37. _ui.m_settingTypeList.itemRenderer = RenderListType;
  38. _ui.m_descList.itemRenderer = RenderDescList;
  39. _ui.m_failRewardList.itemRenderer = RenderFailReward;
  40. _ui.m_passRewardList.itemRenderer = RenderPassReward;
  41. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  42. _ui.m_shop.onClick.Add(OnClickBtnShop);
  43. _ui.m_addIcon.onClick.Add(OnClickBtnAdd);
  44. _ui.m_gameStart.onClick.Add(OnClickBtnStart);
  45. }
  46. protected override void OnShown()
  47. {
  48. base.OnShown();
  49. UpdateView();
  50. UpdateList();
  51. }
  52. protected override void OnHide()
  53. {
  54. base.OnHide();
  55. }
  56. private void UpdateView()
  57. {
  58. //_ui.m_showGame.url = _ui.m_c1.selectedIndex;
  59. _ui.m_ticketNum.text = "999";
  60. }
  61. private void UpdateList()
  62. {
  63. _ui.m_settingTypeList.numItems = name.Count;
  64. _ui.m_descList.numItems = 3;
  65. _ui.m_passRewardList.numItems = name.Count;
  66. _ui.m_failRewardList.numItems = name.Count;
  67. }
  68. private void OnClickBtnBack()
  69. {
  70. this.Hide();
  71. }
  72. private void RenderFailReward(int index, GObject item)
  73. {
  74. //这里也读表
  75. }
  76. private void RenderPassReward(int index, GObject item)
  77. {
  78. //这里也读表
  79. }
  80. private void RenderDescList(int index, GObject item)
  81. {
  82. UI_descItem descItem = UI_descItem.Proxy(item);
  83. descItem.m_desc.text = CustemsDesc[index];
  84. descItem.m_rewardNum.text = index.ToString();
  85. switch (index)
  86. {
  87. case 0:
  88. break;
  89. case 1:
  90. descItem.m_star3.visible = false;
  91. break;
  92. case 2:
  93. descItem.m_star3.visible = false;
  94. descItem.m_star2.visible = false;
  95. break;
  96. default:
  97. break;
  98. };
  99. UI_descItem.ProxyEnd();
  100. //这里也读表
  101. }
  102. private void RenderListType(int index, GObject item)
  103. {
  104. UI_Button6 button6 = UI_Button6.Proxy(item);
  105. button6.m_title1.text = name[index];
  106. button6.m_title2.text = name[index];
  107. button6.target.onClick.Add(OnClickChangeGame);
  108. button6.target.data = name;
  109. UI_Button6.ProxyEnd();
  110. }
  111. private void OnClickChangeGame(EventContext param)
  112. {
  113. if(currentGame == _ui.m_c1.selectedIndex)
  114. {
  115. return;
  116. }
  117. currentGame = _ui.m_c1.selectedIndex;
  118. UpdateView();
  119. UpdateList();
  120. }
  121. private void OnClickBtnShop()
  122. {
  123. }
  124. private void OnClickBtnAdd()
  125. {
  126. }
  127. private void OnClickBtnStart()
  128. {
  129. if(_ui.m_c1.selectedIndex == 0)
  130. {
  131. ViewManager.Show<FlipGameView>();
  132. this.Hide();
  133. }
  134. }
  135. }
  136. }