MainUIView.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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. private List<GameObject> _effects = new List<GameObject>();
  49. private List<GoWrapper> _wrappers = new List<GoWrapper>();
  50. private List<GameObject> _effects1 = new List<GameObject>();
  51. private List<GoWrapper> _wrappers1 = new List<GoWrapper>();
  52. private UI_ButtonModle1[] _btns;
  53. public override void Dispose()
  54. {
  55. _valueBarController.Dispose();
  56. _valueBarController = null;
  57. // SceneController.DestroyObjectFromView(_effectObj0);
  58. // SceneController.DestroyObjectFromView(_effectObj1);
  59. // SceneController.DestroyObjectFromView(_effectObj2);
  60. // SceneController.DestroyObjectFromView(_effectObj3);
  61. // SceneController.DestroyObjectFromView(_effectObj4);
  62. // SceneController.DestroyObjectFromView(_effectObj0_1);
  63. // SceneController.DestroyObjectFromView(_effectObj1_1);
  64. // SceneController.DestroyObjectFromView(_effectObj2_1);
  65. // SceneController.DestroyObjectFromView(_effectObj3_1);
  66. // SceneController.DestroyObjectFromView(_effectObj4_1);
  67. for (int i = 0; i < _btns.Length; i++)
  68. {
  69. SceneController.DestroyObjectFromView(_effects[i]);
  70. SceneController.DestroyObjectFromView(_effects[i]);
  71. }
  72. base.Dispose();
  73. }
  74. protected override void Init()
  75. {
  76. base.Init();
  77. packageName = UI_MainUI.PACKAGE_NAME;
  78. _ui = UI_MainUI.Create();
  79. viewCom = _ui.target;
  80. isfullScreen = true;
  81. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneMain"));
  82. }
  83. protected override void OnInit()
  84. {
  85. base.OnInit();
  86. _valueBarController = new ValueBarController(_ui.m_valueBar);
  87. _btnGongGao = _ui.m_list.GetChild("btnGongGao").asButton;
  88. _btnHaoYou = _ui.m_list.GetChild("btnHaoYou").asButton;
  89. _btnYouJian = _ui.m_list.GetChild("btnYouJian").asButton;
  90. _btnRenWu = _ui.m_list.GetChild("btnRenWu").asButton;
  91. _btnPengYouQuan = _ui.m_list.GetChild("btnPengYouQuan").asButton;
  92. _btnStore = _ui.m_list.GetChild("btnStore").asButton;
  93. _btnTianGong = _ui.m_list.GetChild("btnTianGong").asButton;
  94. _btnTuJian = _ui.m_list.GetChild("btnTuJian").asButton;
  95. _btnJInShu = _ui.m_list.GetChild("btnJInShu").asButton;
  96. // _btnGongGao.visible = false;
  97. // _btnHaoYou.visible = false;
  98. // _btnRenWu.visible = false;
  99. _btnPengYouQuan.visible = false;
  100. _btnJInShu.visible = false;
  101. _btnTianGong.visible = false;
  102. _btns = new UI_ButtonModle1[] { _ui.m_btnHuanZhuang, _ui.m_btnZhaiXing, _ui.m_btnDailyLogin, _ui.m_btnXiuFang, _ui.m_btnCiPai, _ui.m_btnStudio, _ui.m_btnField };
  103. _ui.m_btnMain.target.onTouchBegin.Add(OnClickBtnMain);
  104. _ui.m_btnHuanZhuang.target.onTouchBegin.Add(OnClickBtnHuanZhuang);
  105. _ui.m_btnZhaiXing.target.onTouchBegin.Add(OnClickBtnZhaiXing);
  106. _ui.m_btnDailyLogin.target.onTouchBegin.Add(OnClickBtnDailyLogin);
  107. _ui.m_btnXiuFang.target.onTouchBegin.Add(OnClickBtnXiuFang);
  108. _ui.m_btnCiPai.target.onTouchBegin.Add(OnClickBtnCiPai);
  109. _ui.m_btnStudio.target.onTouchBegin.Add(OnClickBtnStudio);
  110. _ui.m_btnField.target.onTouchBegin.Add(OnClickBtnField);
  111. _ui.m_headBar.target.onClick.Add(OnClickHeadBar);
  112. _btnStore.onClick.Add(OnClickBtnStore);
  113. _btnTuJian.onClick.Add(OnClickBtnTuJian);
  114. _btnYouJian.onClick.Add(OnClickBtnYouJian);
  115. _btnHaoYou.onClick.Add(OnClickBtnHaoYou);
  116. _btnGongGao.onClick.Add(OnClickBtnGongGao);
  117. _btnRenWu.onClick.Add(OnClickBtnRenWu);
  118. AddEffect();
  119. EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, OnNumericChange);
  120. }
  121. protected override void OnShown()
  122. {
  123. base.OnShown();
  124. _ui.m_btnChange.selected = true;
  125. _ui.m_headBar.m_txtName.text = RoleDataManager.roleName;
  126. if (_sceneObject == null)
  127. {
  128. _sceneObject = GameObject.Instantiate(_scenePrefab);
  129. }
  130. SceneController.UpdateMainScene(_sceneObject);
  131. UpdateRoleLvl();
  132. _valueBarController.OnShown();
  133. CheckFunOpen();
  134. // UpdateToCheckGuide();
  135. Timers.inst.AddUpdate(Update);
  136. }
  137. protected override void OnHide()
  138. {
  139. base.OnHide();
  140. if (_sceneObject != null)
  141. {
  142. GameObject.Destroy(_sceneObject);
  143. _sceneObject = null;
  144. }
  145. _valueBarController.OnHide();
  146. Timers.inst.Remove(Update);
  147. }
  148. private void AddEffect()
  149. {
  150. string resPath0 = ResPathUtil.GetViewEffectPath("ui_zjm", "ui_xf_tx");
  151. string resPath3 = ResPathUtil.GetViewEffectPath("ui_zjm", "ui_zjm_dj");
  152. for (int i = 0; i < _btns.Length; i++)
  153. {
  154. GameObject gameObject0;
  155. GoWrapper wrapper0;
  156. GameObject gameObject1;
  157. GoWrapper wrapper1;
  158. SceneController.AddObjectToView(null, null, _btns[i].m_holder, resPath0, out gameObject0, out wrapper0);
  159. SceneController.AddObjectToView(null, null, _btns[i].m_holder1, resPath3, out gameObject1, out wrapper1);
  160. _effects.Add(gameObject0);
  161. _wrappers.Add(wrapper0);
  162. _effects1.Add(gameObject1);
  163. _wrappers1.Add(wrapper1);
  164. }
  165. string resPath1 = ResPathUtil.GetViewEffectPath("ui_zjm", "ui_zzl_tx");
  166. SceneController.AddObjectToView(_effectObj4, _wrapper4, _ui.m_btnMain.m_holder, resPath1, out _effectObj4, out _wrapper4);
  167. SceneController.AddObjectToView(_effectObj4_1, _wrapper4_1, _ui.m_btnMain.m_holder1, resPath3, out _effectObj4_1, out _wrapper4_1);
  168. string resPath2 = ResPathUtil.GetViewEffectPath("ui_zjm", "ui_zjm_tx");
  169. SceneController.AddObjectToView(_effectObj5, _wrapper5, _ui.m_headBar.m_holder, resPath2, out _effectObj5, out _wrapper5);
  170. }
  171. private void OnClickBtnMain()
  172. {
  173. if (isOpen) return;
  174. isOpen = true;
  175. _ui.m_btnMain.m_holder1.visible = true;
  176. Timers.inst.Add(effectTime, 1, (param) =>
  177. {
  178. _ui.m_btnMain.m_holder1.visible = false;
  179. // this.Hide();
  180. ViewManager.Show(ViewName.STORY_CHAPTER_LIST_VIEW, null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  181. isOpen = false; ;
  182. });
  183. }
  184. private void OnClickBtnHuanZhuang()
  185. {
  186. if (isOpen) return;
  187. isOpen = true;
  188. _ui.m_btnHuanZhuang.m_holder1.visible = true;
  189. Timers.inst.Add(effectTime, 1, (param) =>
  190. {
  191. _ui.m_btnHuanZhuang.m_holder1.visible = false;
  192. this.Hide();
  193. ViewManager.Show(ViewName.DRESS_UP_VIEW);
  194. isOpen = false;
  195. });
  196. }
  197. private void OnClickBtnZhaiXing()
  198. {
  199. if (isOpen) return;
  200. isOpen = true;
  201. _ui.m_btnZhaiXing.m_holder1.visible = true;
  202. Timers.inst.Add(effectTime, 1, (param) =>
  203. {
  204. _ui.m_btnZhaiXing.m_holder1.visible = false;
  205. ViewManager.Show(ViewName.LUCKY_BOX_VIEW, null, null, false, true);
  206. isOpen = false;
  207. });
  208. }
  209. private void OnClickBtnXiuFang()
  210. {
  211. if (isOpen) return;
  212. isOpen = true;
  213. _ui.m_btnXiuFang.m_holder1.visible = true;
  214. Timers.inst.Add(effectTime, 1, (param) =>
  215. {
  216. _ui.m_btnXiuFang.m_holder1.visible = false;
  217. ViewManager.Show(ViewName.XIU_FANG_VIEW, null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  218. isOpen = false;
  219. });
  220. }
  221. private void OnClickBtnDailyLogin()
  222. {
  223. if (isOpen) return;
  224. isOpen = true;
  225. _ui.m_btnDailyLogin.m_holder1.visible = true;
  226. Timers.inst.Add(effectTime, 1, (param) =>
  227. {
  228. _ui.m_btnDailyLogin.m_holder1.visible = false;
  229. ViewManager.Show<DailyLoginView>(null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  230. isOpen = false;
  231. });
  232. }
  233. private void OnClickBtnCiPai()
  234. {
  235. if (isOpen) return;
  236. isOpen = true;
  237. _ui.m_btnCiPai.m_holder1.visible = true;
  238. Timers.inst.Add(effectTime, 1, (param) =>
  239. {
  240. _ui.m_btnCiPai.m_holder1.visible = false;
  241. ViewManager.Show(ViewName.CARD_DETAIL_VIEW, null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  242. isOpen = false;
  243. });
  244. }
  245. private void OnClickBtnStudio()
  246. {
  247. ViewManager.Show<StudioView>(null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  248. }
  249. private void OnClickBtnField()
  250. {
  251. ViewManager.Show<FieldView>(null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  252. }
  253. private void OnClickBtnStore()
  254. {
  255. ViewManager.Show(ViewName.RECHARGE_STORE_VIEW);
  256. }
  257. private void OnClickBtnTuJian()
  258. {
  259. ViewManager.Show(ViewName.FIELD_GUIDE_VIEW, null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  260. }
  261. private void OnClickBtnYouJian()
  262. {
  263. ViewManager.Show<MailView>();
  264. }
  265. private void OnClickBtnHaoYou()
  266. {
  267. ViewManager.Show<FriendView>(null, new object[] { ViewName.MAINUI_VIEW, this.viewData }, true);
  268. }
  269. private void OnClickBtnGongGao()
  270. {
  271. // /null, new object[] { ViewName.MAINUI_VIEW, this.viewData }
  272. ViewManager.Show<NoticeView>();
  273. }
  274. private void OnClickBtnRenWu()
  275. {
  276. ViewManager.Show<DailyTaskView>();
  277. }
  278. private void OnClickHeadBar()
  279. {
  280. ViewManager.Show(ViewName.ROLE_INFO_VIEW);
  281. }
  282. private void CheckFunOpen()
  283. {
  284. _ui.m_btnXiuFang.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(XiuFangView).Name, false);
  285. _ui.m_btnMain.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(StoryChapterListView).Name, false);
  286. _ui.m_btnStudio.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(StudioView).Name, false);
  287. _ui.m_btnHuanZhuang.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(DressUpView).Name, false);
  288. _ui.m_btnZhaiXing.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(LuckyBoxView).Name, false);
  289. _ui.m_btnCiPai.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(CardDetailView).Name, false);
  290. }
  291. private void Update(object param)
  292. {
  293. if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Home))
  294. {
  295. Alert.Show("我会想你的")
  296. .SetLeftButton(true, "继续游戏")
  297. .SetRightButton(true, "退出游戏", (object data) =>
  298. {
  299. Application.Quit();
  300. });
  301. }
  302. }
  303. private void OnNumericChange(EventContext context)
  304. {
  305. if ((int)context.data == NumericType.Lvl)
  306. {
  307. UpdateRoleLvl();
  308. }
  309. }
  310. private void UpdateRoleLvl()
  311. {
  312. _ui.m_headBar.m_txtLvl.text = "" + GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  313. }
  314. protected override void UpdateToCheckGuide(object param)
  315. {
  316. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  317. GuideController.TryGuide(_ui.m_btnZhaiXing.target, ConstGuideId.LUCKY_BOX, 2, "“摘星”里可以通过星辰的力量获得服饰", -1, false);
  318. GuideController.TryCompleteGuide(ConstGuideId.FREEDOM_DRESS, 6);
  319. GuideController.TryGuide(_ui.m_btnHuanZhuang.target, ConstGuideId.FREEDOM_DRESS, 2, "在这里,可以自由搭配服饰和分享哦~", -1, false);
  320. GuideController.TryGuide(_ui.m_btnXiuFang.target, ConstGuideId.CLOTHING_SYNTHETIC, 5, "绣坊里增添了新功能", -1, true);
  321. GuideController.TryCompleteGuide(ConstGuideId.CLOTHING_SYNTHETIC, 11);
  322. GuideController.TryGuide(_ui.m_btnCiPai.target, ConstGuideId.UP_CARD_STAR, 2, "已经收集了足够的材料,可以给词牌升星了", -1, false);
  323. GuideController.TryGuide(_ui.m_btnHuanZhuang.target, ConstGuideId.PHOTOGRAPH, 2, "点这里看看吧", -1, false);
  324. }
  325. }
  326. }