MainUIView.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. using FairyGUI;
  2. using UI.Main;
  3. using UI.CommonGame;
  4. using UnityEngine;
  5. using System.Collections.Generic;
  6. using ET;
  7. namespace GFGGame
  8. {
  9. public class MainUIView : BaseView
  10. {
  11. private UI_MainUI _ui;
  12. private GameObject _scenePrefab;
  13. private GameObject _sceneObject;
  14. private ValueBarController _valueBarController;
  15. private float effectTime = 0.7f;
  16. private bool isOpen = false;
  17. private GButton _btnGongGao;
  18. private GButton _btnHaoYou;
  19. private GButton _btnYouJian;
  20. private GButton _btnRenWu;
  21. private GButton _btnPengYouQuan;
  22. private GButton _btnJInShu;
  23. private GButton _btnTianGong;
  24. private GButton _btnStore;
  25. private GButton _btnTuJian;
  26. private GameObject _effectObj0;
  27. private GoWrapper _wrapper0;
  28. private GameObject _effectObj1;
  29. private GoWrapper _wrapper1;
  30. private GameObject _effectObj2;
  31. private GoWrapper _wrapper2;
  32. private GameObject _effectObj3;
  33. private GoWrapper _wrapper3;
  34. private GameObject _effectObj4;
  35. private GoWrapper _wrapper4;
  36. private GameObject _effectObj0_1;
  37. private GoWrapper _wrapper0_1;
  38. private GameObject _effectObj1_1;
  39. private GoWrapper _wrapper1_1;
  40. private GameObject _effectObj2_1;
  41. private GoWrapper _wrapper2_1;
  42. private GameObject _effectObj3_1;
  43. private GoWrapper _wrapper3_1;
  44. private GameObject _effectObj4_1;
  45. private GoWrapper _wrapper4_1;
  46. private GameObject _effectObj5;
  47. private GoWrapper _wrapper5;
  48. public override void Dispose()
  49. {
  50. _valueBarController.Dispose();
  51. _valueBarController = null;
  52. SceneController.DestroyObjectFromView(_effectObj0);
  53. SceneController.DestroyObjectFromView(_effectObj1);
  54. SceneController.DestroyObjectFromView(_effectObj2);
  55. SceneController.DestroyObjectFromView(_effectObj3);
  56. SceneController.DestroyObjectFromView(_effectObj4);
  57. SceneController.DestroyObjectFromView(_effectObj0_1);
  58. SceneController.DestroyObjectFromView(_effectObj1_1);
  59. SceneController.DestroyObjectFromView(_effectObj2_1);
  60. SceneController.DestroyObjectFromView(_effectObj3_1);
  61. SceneController.DestroyObjectFromView(_effectObj4_1);
  62. base.Dispose();
  63. }
  64. protected override void Init()
  65. {
  66. base.Init();
  67. packageName = UI_MainUI.PACKAGE_NAME;
  68. _ui = UI_MainUI.Create();
  69. viewCom = _ui.target;
  70. isfullScreen = true;
  71. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneMain"));
  72. }
  73. protected override void OnInit()
  74. {
  75. base.OnInit();
  76. _valueBarController = new ValueBarController(_ui.m_valueBar);
  77. _btnGongGao = _ui.m_list.GetChild("btnGongGao").asButton;
  78. _btnHaoYou = _ui.m_list.GetChild("btnHaoYou").asButton;
  79. _btnYouJian = _ui.m_list.GetChild("btnYouJian").asButton;
  80. _btnRenWu = _ui.m_list.GetChild("btnRenWu").asButton;
  81. _btnPengYouQuan = _ui.m_list.GetChild("btnPengYouQuan").asButton;
  82. _btnStore = _ui.m_list.GetChild("btnStore").asButton;
  83. _btnTianGong = _ui.m_list.GetChild("btnTianGong").asButton;
  84. _btnTuJian = _ui.m_list.GetChild("btnTuJian").asButton;
  85. _btnJInShu = _ui.m_list.GetChild("btnJInShu").asButton;
  86. _btnGongGao.visible = false;
  87. _btnHaoYou.visible = false;
  88. _btnRenWu.visible = false;
  89. _btnPengYouQuan.visible = false;
  90. _btnJInShu.visible = false;
  91. _btnTianGong.visible = false;
  92. _ui.m_btnMain.target.onTouchBegin.Add(OnClickBtnMain);
  93. _ui.m_btnHuanZhuang.target.onTouchBegin.Add(OnClickBtnHuanZhuang);
  94. _ui.m_btnZhaiXing.target.onTouchBegin.Add(OnClickBtnZhaiXing);
  95. _ui.m_btnXiuFang.target.onTouchBegin.Add(OnClickBtnXiuFang);
  96. _ui.m_btnCiPai.target.onTouchBegin.Add(OnClickBtnCiPai);
  97. _ui.m_btnStudio.target.onTouchBegin.Add(OnClickBtnStudio);
  98. _ui.m_headBar.target.onClick.Add(OnClickHeadBar);
  99. _btnStore.onClick.Add(OnClickBtnStore);
  100. _btnTuJian.onClick.Add(OnClickBtnTuJian);
  101. _btnYouJian.onClick.Add(OnClickBtnYouJian);
  102. AddEffect();
  103. EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, OnNumericChange);
  104. }
  105. protected override void OnShown()
  106. {
  107. base.OnShown();
  108. _ui.m_btnChange.selected = true;
  109. _ui.m_headBar.m_txtName.text = RoleDataManager.roleName;
  110. if (_sceneObject == null)
  111. {
  112. _sceneObject = GameObject.Instantiate(_scenePrefab);
  113. }
  114. SceneController.UpdateMainScene(_sceneObject);
  115. UpdateRoleLvl();
  116. _valueBarController.OnShown();
  117. CheckFunOpen();
  118. // UpdateToCheckGuide();
  119. Timers.inst.AddUpdate(Update);
  120. }
  121. protected override void OnHide()
  122. {
  123. base.OnHide();
  124. if (_sceneObject != null)
  125. {
  126. GameObject.Destroy(_sceneObject);
  127. _sceneObject = null;
  128. }
  129. _valueBarController.OnHide();
  130. Timers.inst.Remove(Update);
  131. }
  132. private void AddEffect()
  133. {
  134. string resPath0 = ResPathUtil.GetViewEffectPath("ui_zjm", "ui_xf_tx");
  135. SceneController.AddObjectToView(_effectObj0, _wrapper0, _ui.m_btnXiuFang.m_holder, resPath0, out _effectObj0, out _wrapper0);
  136. SceneController.AddObjectToView(_effectObj1, _wrapper1, _ui.m_btnHuanZhuang.m_holder, resPath0, out _effectObj1, out _wrapper1);
  137. SceneController.AddObjectToView(_effectObj2, _wrapper2, _ui.m_btnZhaiXing.m_holder, resPath0, out _effectObj2, out _wrapper2);
  138. SceneController.AddObjectToView(_effectObj3, _wrapper3, _ui.m_btnCiPai.m_holder, resPath0, out _effectObj3, out _wrapper3);
  139. string resPath1 = ResPathUtil.GetViewEffectPath("ui_zjm", "ui_zzl_tx");
  140. SceneController.AddObjectToView(_effectObj4, _wrapper4, _ui.m_btnMain.m_holder, resPath1, out _effectObj4, out _wrapper4);
  141. string resPath3 = ResPathUtil.GetViewEffectPath("ui_zjm", "ui_zjm_dj");
  142. SceneController.AddObjectToView(_effectObj0_1, _wrapper0_1, _ui.m_btnXiuFang.m_holder1, resPath3, out _effectObj0_1, out _wrapper0_1);
  143. SceneController.AddObjectToView(_effectObj1_1, _wrapper1_1, _ui.m_btnHuanZhuang.m_holder1, resPath3, out _effectObj1_1, out _wrapper1_1);
  144. SceneController.AddObjectToView(_effectObj2_1, _wrapper2_1, _ui.m_btnZhaiXing.m_holder1, resPath3, out _effectObj2_1, out _wrapper2_1);
  145. SceneController.AddObjectToView(_effectObj3_1, _wrapper3_1, _ui.m_btnCiPai.m_holder1, resPath3, out _effectObj3_1, out _wrapper3_1);
  146. SceneController.AddObjectToView(_effectObj4_1, _wrapper4_1, _ui.m_btnMain.m_holder1, resPath3, out _effectObj4_1, out _wrapper4_1);
  147. string resPath2 = ResPathUtil.GetViewEffectPath("ui_zjm", "ui_zjm_tx");
  148. SceneController.AddObjectToView(_effectObj5, _wrapper5, _ui.m_headBar.m_holder, resPath2, out _effectObj5, out _wrapper5);
  149. }
  150. private void OnClickBtnMain()
  151. {
  152. if (isOpen) return;
  153. isOpen = true;
  154. _ui.m_btnMain.m_holder1.visible = true;
  155. Timers.inst.Add(effectTime, 1, (param) =>
  156. {
  157. _ui.m_btnMain.m_holder1.visible = false;
  158. // this.Hide();
  159. ViewManager.Show(ViewName.STORY_CHAPTER_LIST_VIEW, null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  160. isOpen = false; ;
  161. });
  162. }
  163. private void OnClickBtnHuanZhuang()
  164. {
  165. if (isOpen) return;
  166. isOpen = true;
  167. _ui.m_btnHuanZhuang.m_holder1.visible = true;
  168. Timers.inst.Add(effectTime, 1, (param) =>
  169. {
  170. _ui.m_btnHuanZhuang.m_holder1.visible = false;
  171. this.Hide();
  172. ViewManager.Show(ViewName.DRESS_UP_VIEW);
  173. isOpen = false;
  174. });
  175. }
  176. private void OnClickBtnZhaiXing()
  177. {
  178. if (isOpen) return;
  179. isOpen = true;
  180. _ui.m_btnZhaiXing.m_holder1.visible = true;
  181. Timers.inst.Add(effectTime, 1, (param) =>
  182. {
  183. _ui.m_btnZhaiXing.m_holder1.visible = false;
  184. ViewManager.Show(ViewName.LUCKY_BOX_VIEW, null, null, false, true);
  185. isOpen = false;
  186. });
  187. }
  188. private void OnClickBtnXiuFang()
  189. {
  190. if (isOpen) return;
  191. isOpen = true;
  192. _ui.m_btnXiuFang.m_holder1.visible = true;
  193. Timers.inst.Add(effectTime, 1, (param) =>
  194. {
  195. _ui.m_btnXiuFang.m_holder1.visible = false;
  196. ViewManager.Show(ViewName.XIU_FANG_VIEW, null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  197. isOpen = false;
  198. });
  199. }
  200. private void OnClickBtnCiPai()
  201. {
  202. if (isOpen) return;
  203. isOpen = true;
  204. _ui.m_btnCiPai.m_holder1.visible = true;
  205. Timers.inst.Add(effectTime, 1, (param) =>
  206. {
  207. _ui.m_btnCiPai.m_holder1.visible = false;
  208. ViewManager.Show(ViewName.CARD_DETAIL_VIEW, null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  209. isOpen = false;
  210. });
  211. }
  212. private void OnClickBtnStudio()
  213. {
  214. ViewManager.Show<StudioView>(null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  215. }
  216. private void OnClickBtnStore()
  217. {
  218. ViewManager.Show(ViewName.RECHARGE_STORE_VIEW);
  219. }
  220. private void OnClickBtnTuJian()
  221. {
  222. ViewManager.Show(ViewName.FIELD_GUIDE_VIEW, null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  223. }
  224. private void OnClickBtnYouJian()
  225. {
  226. ViewManager.Show<MailView>();
  227. }
  228. private void OnClickHeadBar()
  229. {
  230. ViewManager.Show(ViewName.ROLE_INFO_VIEW);
  231. }
  232. private void CheckFunOpen()
  233. {
  234. _ui.m_btnXiuFang.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(XiuFangView).Name, false);
  235. _ui.m_btnMain.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(StoryChapterListView).Name, false);
  236. _ui.m_btnStudio.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(StudioView).Name, false);
  237. _ui.m_btnHuanZhuang.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(DressUpView).Name, false);
  238. _ui.m_btnZhaiXing.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(LuckyBoxView).Name, false);
  239. _ui.m_btnCiPai.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(CardDetailView).Name, false);
  240. }
  241. private void Update(object param)
  242. {
  243. if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Home))
  244. {
  245. Alert.Show("我会想你的")
  246. .SetLeftButton(true, "继续游戏")
  247. .SetRightButton(true, "退出游戏", (object data) =>
  248. {
  249. Application.Quit();
  250. });
  251. }
  252. }
  253. private void OnNumericChange(EventContext context)
  254. {
  255. if ((int)context.data == NumericType.Lvl)
  256. {
  257. UpdateRoleLvl();
  258. }
  259. }
  260. private void UpdateRoleLvl()
  261. {
  262. _ui.m_headBar.m_txtLvl.text = "" + GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  263. }
  264. protected override void UpdateToCheckGuide(object param)
  265. {
  266. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  267. GuideController.TryGuide(_ui.m_btnZhaiXing.target, ConstGuideId.LUCKY_BOX, 2, "“摘星”里可以通过星辰的力量获得服饰", -1, false);
  268. GuideController.TryCompleteGuide(ConstGuideId.FREEDOM_DRESS, 6);
  269. GuideController.TryGuide(_ui.m_btnHuanZhuang.target, ConstGuideId.FREEDOM_DRESS, 2, "在这里,可以自由搭配服饰和分享哦~", -1, false);
  270. GuideController.TryGuide(_ui.m_btnXiuFang.target, ConstGuideId.CLOTHING_SYNTHETIC, 5, "绣坊里增添了新功能", -1, false);
  271. GuideController.TryCompleteGuide(ConstGuideId.CLOTHING_SYNTHETIC, 11);
  272. GuideController.TryGuide(_ui.m_btnCiPai.target, ConstGuideId.UP_CARD_STAR, 2, "已经收集了足够的材料,可以给词牌升星了", -1, false);
  273. GuideController.TryGuide(_ui.m_btnHuanZhuang.target, ConstGuideId.PHOTOGRAPH, 2, "点这里看看吧", -1, false);
  274. }
  275. }
  276. }