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