MainUIView.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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. _btnHaoYou.onClick.Add(OnClickBtnHaoYou);
  103. _btnGongGao.onClick.Add(OnClickBtnGongGao);
  104. AddEffect();
  105. EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, OnNumericChange);
  106. }
  107. protected override void OnShown()
  108. {
  109. base.OnShown();
  110. _ui.m_btnChange.selected = true;
  111. _ui.m_headBar.m_txtName.text = RoleDataManager.roleName;
  112. if (_sceneObject == null)
  113. {
  114. _sceneObject = GameObject.Instantiate(_scenePrefab);
  115. }
  116. SceneController.UpdateMainScene(_sceneObject);
  117. UpdateRoleLvl();
  118. _valueBarController.OnShown();
  119. CheckFunOpen();
  120. // UpdateToCheckGuide();
  121. Timers.inst.AddUpdate(Update);
  122. }
  123. protected override void OnHide()
  124. {
  125. base.OnHide();
  126. if (_sceneObject != null)
  127. {
  128. GameObject.Destroy(_sceneObject);
  129. _sceneObject = null;
  130. }
  131. _valueBarController.OnHide();
  132. Timers.inst.Remove(Update);
  133. }
  134. private void AddEffect()
  135. {
  136. string resPath0 = ResPathUtil.GetViewEffectPath("ui_zjm", "ui_xf_tx");
  137. SceneController.AddObjectToView(_effectObj0, _wrapper0, _ui.m_btnXiuFang.m_holder, resPath0, out _effectObj0, out _wrapper0);
  138. SceneController.AddObjectToView(_effectObj1, _wrapper1, _ui.m_btnHuanZhuang.m_holder, resPath0, out _effectObj1, out _wrapper1);
  139. SceneController.AddObjectToView(_effectObj2, _wrapper2, _ui.m_btnZhaiXing.m_holder, resPath0, out _effectObj2, out _wrapper2);
  140. SceneController.AddObjectToView(_effectObj3, _wrapper3, _ui.m_btnCiPai.m_holder, resPath0, out _effectObj3, out _wrapper3);
  141. string resPath1 = ResPathUtil.GetViewEffectPath("ui_zjm", "ui_zzl_tx");
  142. SceneController.AddObjectToView(_effectObj4, _wrapper4, _ui.m_btnMain.m_holder, resPath1, out _effectObj4, out _wrapper4);
  143. string resPath3 = ResPathUtil.GetViewEffectPath("ui_zjm", "ui_zjm_dj");
  144. SceneController.AddObjectToView(_effectObj0_1, _wrapper0_1, _ui.m_btnXiuFang.m_holder1, resPath3, out _effectObj0_1, out _wrapper0_1);
  145. SceneController.AddObjectToView(_effectObj1_1, _wrapper1_1, _ui.m_btnHuanZhuang.m_holder1, resPath3, out _effectObj1_1, out _wrapper1_1);
  146. SceneController.AddObjectToView(_effectObj2_1, _wrapper2_1, _ui.m_btnZhaiXing.m_holder1, resPath3, out _effectObj2_1, out _wrapper2_1);
  147. SceneController.AddObjectToView(_effectObj3_1, _wrapper3_1, _ui.m_btnCiPai.m_holder1, resPath3, out _effectObj3_1, out _wrapper3_1);
  148. SceneController.AddObjectToView(_effectObj4_1, _wrapper4_1, _ui.m_btnMain.m_holder1, resPath3, out _effectObj4_1, out _wrapper4_1);
  149. string resPath2 = ResPathUtil.GetViewEffectPath("ui_zjm", "ui_zjm_tx");
  150. SceneController.AddObjectToView(_effectObj5, _wrapper5, _ui.m_headBar.m_holder, resPath2, out _effectObj5, out _wrapper5);
  151. }
  152. private void OnClickBtnMain()
  153. {
  154. if (isOpen) return;
  155. isOpen = true;
  156. _ui.m_btnMain.m_holder1.visible = true;
  157. Timers.inst.Add(effectTime, 1, (param) =>
  158. {
  159. _ui.m_btnMain.m_holder1.visible = false;
  160. // this.Hide();
  161. ViewManager.Show(ViewName.STORY_CHAPTER_LIST_VIEW, null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  162. isOpen = false; ;
  163. });
  164. }
  165. private void OnClickBtnHuanZhuang()
  166. {
  167. if (isOpen) return;
  168. isOpen = true;
  169. _ui.m_btnHuanZhuang.m_holder1.visible = true;
  170. Timers.inst.Add(effectTime, 1, (param) =>
  171. {
  172. _ui.m_btnHuanZhuang.m_holder1.visible = false;
  173. this.Hide();
  174. ViewManager.Show(ViewName.DRESS_UP_VIEW);
  175. isOpen = false;
  176. });
  177. }
  178. private void OnClickBtnZhaiXing()
  179. {
  180. if (isOpen) return;
  181. isOpen = true;
  182. _ui.m_btnZhaiXing.m_holder1.visible = true;
  183. Timers.inst.Add(effectTime, 1, (param) =>
  184. {
  185. _ui.m_btnZhaiXing.m_holder1.visible = false;
  186. ViewManager.Show(ViewName.LUCKY_BOX_VIEW, null, null, false, true);
  187. isOpen = false;
  188. });
  189. }
  190. private void OnClickBtnXiuFang()
  191. {
  192. if (isOpen) return;
  193. isOpen = true;
  194. _ui.m_btnXiuFang.m_holder1.visible = true;
  195. Timers.inst.Add(effectTime, 1, (param) =>
  196. {
  197. _ui.m_btnXiuFang.m_holder1.visible = false;
  198. ViewManager.Show(ViewName.XIU_FANG_VIEW, null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  199. isOpen = false;
  200. });
  201. }
  202. private void OnClickBtnCiPai()
  203. {
  204. if (isOpen) return;
  205. isOpen = true;
  206. _ui.m_btnCiPai.m_holder1.visible = true;
  207. Timers.inst.Add(effectTime, 1, (param) =>
  208. {
  209. _ui.m_btnCiPai.m_holder1.visible = false;
  210. ViewManager.Show(ViewName.CARD_DETAIL_VIEW, null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  211. isOpen = false;
  212. });
  213. }
  214. private void OnClickBtnStudio()
  215. {
  216. ViewManager.Show<StudioView>(null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  217. }
  218. private void OnClickBtnStore()
  219. {
  220. ViewManager.Show(ViewName.RECHARGE_STORE_VIEW);
  221. }
  222. private void OnClickBtnTuJian()
  223. {
  224. ViewManager.Show(ViewName.FIELD_GUIDE_VIEW, null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  225. }
  226. private void OnClickBtnYouJian()
  227. {
  228. ViewManager.Show<MailView>();
  229. }
  230. private void OnClickBtnHaoYou()
  231. {
  232. ViewManager.Show<FriendView>(null, new object[] { ViewName.MAINUI_VIEW, this.viewData }, true);
  233. }
  234. private void OnClickBtnGongGao()
  235. {
  236. // /null, new object[] { ViewName.MAINUI_VIEW, this.viewData }
  237. ViewManager.Show<NoticeView>();
  238. }
  239. private void OnClickHeadBar()
  240. {
  241. ViewManager.Show(ViewName.ROLE_INFO_VIEW);
  242. }
  243. private void CheckFunOpen()
  244. {
  245. _ui.m_btnXiuFang.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(XiuFangView).Name, false);
  246. _ui.m_btnMain.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(StoryChapterListView).Name, false);
  247. _ui.m_btnStudio.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(StudioView).Name, false);
  248. _ui.m_btnHuanZhuang.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(DressUpView).Name, false);
  249. _ui.m_btnZhaiXing.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(LuckyBoxView).Name, false);
  250. _ui.m_btnCiPai.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(CardDetailView).Name, false);
  251. }
  252. private void Update(object param)
  253. {
  254. if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Home))
  255. {
  256. Alert.Show("我会想你的")
  257. .SetLeftButton(true, "继续游戏")
  258. .SetRightButton(true, "退出游戏", (object data) =>
  259. {
  260. Application.Quit();
  261. });
  262. }
  263. }
  264. private void OnNumericChange(EventContext context)
  265. {
  266. if ((int)context.data == NumericType.Lvl)
  267. {
  268. UpdateRoleLvl();
  269. }
  270. }
  271. private void UpdateRoleLvl()
  272. {
  273. _ui.m_headBar.m_txtLvl.text = "" + GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  274. }
  275. protected override void UpdateToCheckGuide(object param)
  276. {
  277. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  278. GuideController.TryGuide(_ui.m_btnZhaiXing.target, ConstGuideId.LUCKY_BOX, 2, "“摘星”里可以通过星辰的力量获得服饰", -1, false);
  279. GuideController.TryCompleteGuide(ConstGuideId.FREEDOM_DRESS, 6);
  280. GuideController.TryGuide(_ui.m_btnHuanZhuang.target, ConstGuideId.FREEDOM_DRESS, 2, "在这里,可以自由搭配服饰和分享哦~", -1, false);
  281. GuideController.TryGuide(_ui.m_btnXiuFang.target, ConstGuideId.CLOTHING_SYNTHETIC, 5, "绣坊里增添了新功能", -1, true);
  282. GuideController.TryCompleteGuide(ConstGuideId.CLOTHING_SYNTHETIC, 11);
  283. GuideController.TryGuide(_ui.m_btnCiPai.target, ConstGuideId.UP_CARD_STAR, 2, "已经收集了足够的材料,可以给词牌升星了", -1, false);
  284. GuideController.TryGuide(_ui.m_btnHuanZhuang.target, ConstGuideId.PHOTOGRAPH, 2, "点这里看看吧", -1, false);
  285. }
  286. }
  287. }