MainUIView.cs 14 KB

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