MainUIView.cs 14 KB

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