MainUIView.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. using FairyGUI;
  2. using UI.Main;
  3. using UI.CommonGame;
  4. using UnityEngine;
  5. using System.Collections.Generic;
  6. using ET;
  7. using static UnityEditor.Progress;
  8. namespace GFGGame
  9. {
  10. public class MainUIView : BaseView
  11. {
  12. private UI_MainUI _ui;
  13. private GameObject _scenePrefab;
  14. private GameObject _sceneObject;
  15. private ValueBarController _valueBarController;
  16. private float effectTime = 0.7f;
  17. private bool isOpen = false;
  18. private GButton _btnGongGao;
  19. private GButton _btnHaoYou;
  20. private GButton _btnYouJian;
  21. private GButton _btnRenWu;
  22. private GButton _btnPengYouQuan;
  23. private GButton _btnJInShu;
  24. private GButton _btnTianGong;
  25. private GButton _btnStore;
  26. private GButton _btnTuJian;
  27. private GButton _btnStudio;
  28. private GButton _btnField;
  29. private GameObject _effectObj4;
  30. private GoWrapper _wrapper4;
  31. private GameObject _effectObj4_1;
  32. private GoWrapper _wrapper4_1;
  33. private GameObject _effectObj5;
  34. private GoWrapper _wrapper5;
  35. private List<GameObject> _effects = new List<GameObject>();
  36. private List<GoWrapper> _wrappers = new List<GoWrapper>();
  37. private List<GameObject> _effects1 = new List<GameObject>();
  38. private List<GoWrapper> _wrappers1 = new List<GoWrapper>();
  39. private UI_ButtonModle1[] _btns;
  40. public override void Dispose()
  41. {
  42. _valueBarController.Dispose();
  43. _valueBarController = null;
  44. for (int i = 0; i < _btns.Length; i++)
  45. {
  46. SceneController.DestroyObjectFromView(_effects[i]);
  47. SceneController.DestroyObjectFromView(_effects[i]);
  48. }
  49. if (_sceneObject != null)
  50. {
  51. GameObject.Destroy(_sceneObject);
  52. _sceneObject = null;
  53. }
  54. base.Dispose();
  55. }
  56. protected override void Init()
  57. {
  58. base.Init();
  59. packageName = UI_MainUI.PACKAGE_NAME;
  60. _ui = UI_MainUI.Create();
  61. viewCom = _ui.target;
  62. isfullScreen = true;
  63. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneMain"));
  64. }
  65. protected override void OnInit()
  66. {
  67. base.OnInit();
  68. _valueBarController = new ValueBarController(_ui.m_valueBar);
  69. _btnGongGao = _ui.m_list.GetChild("btnGongGao").asButton;
  70. _btnHaoYou = _ui.m_list.GetChild("btnHaoYou").asButton;
  71. _btnYouJian = _ui.m_list.GetChild("btnYouJian").asButton;
  72. _btnRenWu = _ui.m_list.GetChild("btnRenWu").asButton;
  73. _btnPengYouQuan = _ui.m_list.GetChild("btnPengYouQuan").asButton;
  74. _btnStore = _ui.m_list.GetChild("btnStore").asButton;
  75. _btnTianGong = _ui.m_list.GetChild("btnTianGong").asButton;
  76. _btnTuJian = _ui.m_list.GetChild("btnTuJian").asButton;
  77. _btnJInShu = _ui.m_list.GetChild("btnJInShu").asButton;
  78. _btnStudio = _ui.m_list.GetChild("btnStudio").asButton;
  79. _btnField = _ui.m_list.GetChild("btnField").asButton;
  80. // _btnGongGao.visible = false;
  81. _btnHaoYou.visible = false;
  82. // _btnRenWu.visible = false;
  83. _btnPengYouQuan.visible = false;
  84. _btnJInShu.visible = false;
  85. _btnTianGong.visible = false;
  86. _btns = new UI_ButtonModle1[] { _ui.m_btnHuanZhuang, _ui.m_btnZhaiXing, _ui.m_btnXiuFang, _ui.m_btnCiPai, _ui.m_btnStudio, _ui.m_btnField };
  87. _ui.m_btnMain.target.onTouchBegin.Add(OnClickBtnMain);
  88. _ui.m_btnHuanZhuang.target.onTouchBegin.Add(OnClickBtnHuanZhuang);
  89. _ui.m_btnZhaiXing.target.onTouchBegin.Add(OnClickBtnZhaiXing);
  90. _ui.m_btnDailyLogin.target.onTouchBegin.Add(OnClickBtnDailyLogin);
  91. _ui.m_btnXiuFang.target.onTouchBegin.Add(OnClickBtnXiuFang);
  92. _ui.m_btnCiPai.target.onTouchBegin.Add(OnClickBtnCiPai);
  93. _ui.m_btnStudio.target.onTouchBegin.Add(OnClickBtnStudio);
  94. _ui.m_btnField.target.onTouchBegin.Add(OnClickBtnField);
  95. _ui.m_headBar.target.onClick.Add(OnClickHeadBar);
  96. _btnStore.onClick.Add(OnClickBtnStore);
  97. _btnTuJian.onClick.Add(OnClickBtnTuJian);
  98. _btnYouJian.onClick.Add(OnClickBtnYouJian);
  99. _btnHaoYou.onClick.Add(OnClickBtnHaoYou);
  100. _btnGongGao.onClick.Add(OnClickBtnGongGao);
  101. _btnRenWu.onClick.Add(OnClickBtnRenWu);
  102. _btnStudio.onClick.Add(OnClickBtnStudio);
  103. _btnField.onClick.Add(OnClickBtnField);
  104. AddEffect();
  105. // StorageSProxy.ReqSetClientValue(ConstStorageId.STORAGE_GUIDE + 4, 0).Coroutine();
  106. }
  107. protected override void AddEventListener()
  108. {
  109. base.AddEventListener();
  110. EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, OnNumericChange);
  111. EventAgent.AddEventListener(ConstMessage.STORY_LEVEL_CHANGE, CheckFunOpen);
  112. EventAgent.AddEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  113. }
  114. protected override void OnShown()
  115. {
  116. base.OnShown();
  117. _ui.m_btnChange.selected = true;
  118. _ui.m_headBar.m_txtName.text = RoleDataManager.roleName;
  119. if (_sceneObject == null)
  120. {
  121. _sceneObject = GameObject.Instantiate(_scenePrefab);
  122. }
  123. CheckFunOpen();
  124. UpdateRedDot();
  125. SceneController.UpdateMainScene(_sceneObject);
  126. UpdateRoleLvl();
  127. _valueBarController.OnShown();
  128. long lastTime = GameGlobal.lastLoginTime;// GameGlobal.myNumericComponent.GetAsInt(NumericType.OnlineTimeSecs);
  129. if (!TimeUtil.CheckIsSameTime(lastTime * 1000, TimeHelper.ClientNow()) && ActivityDataManager.Instance.dailyLoginBonusStatus == ConstBonusStatus.CAN_GET && GuideDataManager.currentGuideId <= 0)
  130. {
  131. ViewManager.Show<DailyLoginView>();
  132. GameGlobal.lastLoginTime = GameGlobal.myNumericComponent.GetAsInt(NumericType.OnlineTimeSecs);
  133. }
  134. Timers.inst.AddUpdate(CheckGuide);
  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. Timers.inst.Remove(CheckGuide);
  148. }
  149. protected override void RemoveEventListener()
  150. {
  151. base.RemoveEventListener();
  152. EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, OnNumericChange);
  153. EventAgent.RemoveEventListener(ConstMessage.STORY_LEVEL_CHANGE, CheckFunOpen);
  154. EventAgent.AddEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  155. }
  156. private void AddEffect()
  157. {
  158. string resPath0 = ResPathUtil.GetViewEffectPath("ui_zjm", "ui_xf_tx");
  159. string resPath3 = ResPathUtil.GetViewEffectPath("ui_zjm", "ui_zjm_dj");
  160. for (int i = 0; i < _btns.Length; i++)
  161. {
  162. GameObject gameObject0;
  163. GoWrapper wrapper0;
  164. GameObject gameObject1;
  165. GoWrapper wrapper1;
  166. SceneController.AddObjectToView(null, null, _btns[i].m_holder, resPath0, out gameObject0, out wrapper0);
  167. SceneController.AddObjectToView(null, null, _btns[i].m_holder1, resPath3, out gameObject1, out wrapper1);
  168. _effects.Add(gameObject0);
  169. _wrappers.Add(wrapper0);
  170. _effects1.Add(gameObject1);
  171. _wrappers1.Add(wrapper1);
  172. }
  173. string resPath1 = ResPathUtil.GetViewEffectPath("ui_zjm", "ui_zzl_tx");
  174. SceneController.AddObjectToView(_effectObj4, _wrapper4, _ui.m_btnMain.m_holder, resPath1, out _effectObj4, out _wrapper4);
  175. SceneController.AddObjectToView(_effectObj4_1, _wrapper4_1, _ui.m_btnMain.m_holder1, resPath3, out _effectObj4_1, out _wrapper4_1);
  176. string resPath2 = ResPathUtil.GetViewEffectPath("ui_zjm", "ui_zjm_tx");
  177. SceneController.AddObjectToView(_effectObj5, _wrapper5, _ui.m_headBar.m_holder, resPath2, out _effectObj5, out _wrapper5);
  178. }
  179. private void OnClickBtnMain()
  180. {
  181. LogServerHelper.SendNodeLog((int)PlayParticipationEnum.CHUN_ZHONG_LOU, 1);
  182. if (isOpen) return;
  183. isOpen = true;
  184. _ui.m_btnMain.m_holder1.visible = true;
  185. Timers.inst.Add(effectTime, 1, (param) =>
  186. {
  187. _ui.m_btnMain.m_holder1.visible = false;
  188. // this.Hide();
  189. ViewManager.Show(ViewName.STORY_CHAPTER_LIST_VIEW, null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  190. isOpen = false; ;
  191. });
  192. }
  193. private void OnClickBtnHuanZhuang()
  194. {
  195. if (isOpen) return;
  196. isOpen = true;
  197. _ui.m_btnHuanZhuang.m_holder1.visible = true;
  198. Timers.inst.Add(effectTime, 1, (param) =>
  199. {
  200. _ui.m_btnHuanZhuang.m_holder1.visible = false;
  201. this.Hide();
  202. ViewManager.Show(ViewName.DRESS_UP_VIEW);
  203. isOpen = false;
  204. });
  205. }
  206. private void OnClickBtnZhaiXing()
  207. {
  208. LogServerHelper.SendNodeLog((int)PlayParticipationEnum.ZAI_XING, 1);
  209. if (isOpen) return;
  210. isOpen = true;
  211. _ui.m_btnZhaiXing.m_holder1.visible = true;
  212. Timers.inst.Add(effectTime, 1, (param) =>
  213. {
  214. _ui.m_btnZhaiXing.m_holder1.visible = false;
  215. ViewManager.Show(ViewName.LUCKY_BOX_VIEW, null, null, false, true);
  216. isOpen = false;
  217. });
  218. }
  219. private void OnClickBtnXiuFang()
  220. {
  221. if (isOpen) return;
  222. isOpen = true;
  223. _ui.m_btnXiuFang.m_holder1.visible = true;
  224. Timers.inst.Add(effectTime, 1, (param) =>
  225. {
  226. _ui.m_btnXiuFang.m_holder1.visible = false;
  227. ViewManager.Show(ViewName.XIU_FANG_VIEW, null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  228. isOpen = false;
  229. });
  230. }
  231. private void OnClickBtnDailyLogin()
  232. {
  233. // if (isOpen) return;
  234. // isOpen = true;
  235. _ui.m_btnDailyLogin.m_holder.visible = true;
  236. // Timers.inst.Add(effectTime, 1, (param) =>
  237. // {
  238. // _ui.m_btnDailyLogin.m_holder.visible = false;
  239. // List<string> list = new List<string>();
  240. // list.Add("StudioView");
  241. // list.Add("XiuFangView");
  242. // ViewManager.Show<FunctionOpenView>(list);
  243. LogServerHelper.SendNodeLog((int)PlayParticipationEnum.MEI_RI_DNEG_LU, 1);
  244. ViewManager.Show<DailyLoginView>(null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  245. // isOpen = false;
  246. // });
  247. }
  248. private void OnClickBtnCiPai()
  249. {
  250. LogServerHelper.SendNodeLog((int)PlayParticipationEnum.CI_PAI, 1);
  251. if (isOpen) return;
  252. isOpen = true;
  253. _ui.m_btnCiPai.m_holder1.visible = true;
  254. Timers.inst.Add(effectTime, 1, (param) =>
  255. {
  256. _ui.m_btnCiPai.m_holder1.visible = false;
  257. ViewManager.Show(ViewName.CARD_DETAIL_VIEW, null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  258. isOpen = false;
  259. });
  260. }
  261. private void OnClickBtnStudio()
  262. {
  263. ViewManager.Show<StudioView>(null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  264. }
  265. private void OnClickBtnField()
  266. {
  267. LogServerHelper.SendNodeLog((int)PlayParticipationEnum.TIAN_YE_DIAO_CHA, 1);
  268. ViewManager.Show<FieldView>(null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  269. }
  270. private void OnClickBtnStore()
  271. {
  272. LogServerHelper.SendNodeLog((int)PlayParticipationEnum.SHANG_CHENG, 1);
  273. ViewManager.Show(ViewName.RECHARGE_STORE_VIEW);
  274. }
  275. private void OnClickBtnTuJian()
  276. {
  277. LogServerHelper.SendNodeLog((int)PlayParticipationEnum.TU_JIAN, 1);
  278. ViewManager.Show(ViewName.FIELD_GUIDE_VIEW, null, new object[] { ViewName.MAINUI_VIEW, this.viewData });
  279. }
  280. private void OnClickBtnYouJian()
  281. {
  282. ViewManager.Show<MailView>();
  283. }
  284. private void OnClickBtnHaoYou()
  285. {
  286. ViewManager.Show<FriendView>(null, new object[] { ViewName.MAINUI_VIEW, this.viewData }, true);
  287. }
  288. private void OnClickBtnGongGao()
  289. {
  290. // /null, new object[] { ViewName.MAINUI_VIEW, this.viewData }
  291. ViewManager.Show<NoticeView>();
  292. }
  293. private void OnClickBtnRenWu()
  294. {
  295. LogServerHelper.SendNodeLog((int)PlayParticipationEnum.MEI_RI_REN_WU, 1);
  296. ViewManager.Show<DailyTaskView>();
  297. }
  298. private void OnClickHeadBar()
  299. {
  300. GUIUtility.systemCopyBuffer = RoleDataManager.roleName;
  301. ViewManager.Show(ViewName.ROLE_INFO_VIEW);
  302. }
  303. private void Update(object param)
  304. {
  305. ShowExitAlert();
  306. }
  307. private void ShowExitAlert()
  308. {
  309. if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Home))
  310. {
  311. AlertSystem.Show("我会想你的")
  312. .SetLeftButton(true, "继续游戏")
  313. .SetRightButton(true, "退出游戏", (object data) =>
  314. {
  315. Application.Quit();
  316. });
  317. }
  318. }
  319. private void OnNumericChange(EventContext context)
  320. {
  321. if ((int)context.data == NumericType.Lvl)
  322. {
  323. UpdateRoleLvl();
  324. CheckFunOpen();
  325. }
  326. }
  327. private void UpdateRoleLvl()
  328. {
  329. _ui.m_headBar.m_txtLvl.text = "" + GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  330. }
  331. private void CheckFunOpen()
  332. {
  333. _ui.m_btnXiuFang.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(XiuFangView).Name, false);
  334. _ui.m_btnMain.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(StoryChapterListView).Name, false);
  335. // _ui.m_btnStudio.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(StudioView).Name, false);
  336. _ui.m_btnHuanZhuang.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(DressUpView).Name, false);
  337. _ui.m_btnZhaiXing.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(LuckyBoxView).Name, false);
  338. _ui.m_btnCiPai.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(CardDetailView).Name, false);
  339. _ui.m_btnDailyLogin.target.visible = !(!FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(DailyLoginView).Name, false)
  340. || (ActivityDataManager.Instance.dailyLoginId >= 7 && ActivityDataManager.Instance.dailyLoginBonusStatus == ConstBonusStatus.GOT));
  341. // _ui.m_btnField.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(FieldView).Name, false);
  342. _ui.m_btnHuanZhuang.target.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(DressUpView).Name, false);
  343. _btnGongGao.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(NoticeView).Name, false);
  344. // _btnHaoYou.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(FriendView).Name, false);
  345. _btnYouJian.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(MailView).Name, false);
  346. _btnStore.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(RechargeStoreView).Name, false);
  347. _btnTuJian.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(FieldGuideView).Name, false);
  348. _btnStudio.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(StudioView).Name, false);
  349. _btnField.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(FieldView).Name, false);
  350. // _btnTianGong.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(CardDetailView).Name, false);
  351. // _btnPengYouQuan.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(CardDetailView).Name, false);
  352. // _btnJInShu.visible = FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(CardDetailView).Name, false);
  353. }
  354. private void UpdateRedDot()
  355. {
  356. RedDotController.Instance.SetComRedDot(_btnGongGao, RedDotDataManager.Instance.GetNoticeRed());
  357. RedDotController.Instance.SetComRedDot(_btnRenWu, RedDotDataManager.Instance.GetTaskRed());
  358. RedDotController.Instance.SetComRedDot(_ui.m_btnDailyLogin.target, RedDotDataManager.Instance.GetDailyLoginRed());
  359. RedDotController.Instance.SetComRedDot(_btnYouJian, RedDotDataManager.Instance.GetMailRed());
  360. RedDotController.Instance.SetComRedDot(_btnTuJian, RedDotDataManager.Instance.GetFieldGuideRed());
  361. }
  362. private void CheckGuide(object param)
  363. {
  364. if (GuideDataManager.IsGuideFinish(ConstGuideId.LUCKY_BOX) <= 0
  365. || GuideDataManager.IsGuideFinish(ConstGuideId.FREEDOM_DRESS) <= 0
  366. || GuideDataManager.IsGuideFinish(ConstGuideId.CLOTHING_DECOMPOSE) <= 0
  367. || GuideDataManager.IsGuideFinish(ConstGuideId.CLOTHING_SYNTHETIC) <= 0
  368. || GuideDataManager.IsGuideFinish(ConstGuideId.UP_CARD_LV) <= 0
  369. || GuideDataManager.IsGuideFinish(ConstGuideId.STUDIO_OPEN) <= 0
  370. || GuideDataManager.IsGuideFinish(ConstGuideId.SUIT_LIST_VIEW) <= 0)
  371. {
  372. UpdateToCheckGuide(null);
  373. }
  374. else
  375. {
  376. Timers.inst.Remove(CheckGuide);
  377. }
  378. }
  379. protected override void UpdateToCheckGuide(object param)
  380. {
  381. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  382. GuideController.TryGuide(_ui.m_btnZhaiXing.target, ConstGuideId.LUCKY_BOX, 2, "“摘星”里可以通过星辰的力量获得服饰", -1, false);
  383. GuideController.TryCompleteGuide(ConstGuideId.FREEDOM_DRESS, 6);
  384. GuideController.TryGuide(_ui.m_btnHuanZhuang.target, ConstGuideId.FREEDOM_DRESS, 2, "在这里,可以自由搭配服饰和分享哦~", -1, false);
  385. GuideController.TryGuide(_ui.m_btnXiuFang.target, ConstGuideId.CLOTHING_DECOMPOSE, 2, "绣坊里增添了新功能", -1, false);
  386. GuideController.TryGuide(_ui.m_btnXiuFang.target, ConstGuideId.CLOTHING_SYNTHETIC, 1, "进入绣坊界面", -1, false);
  387. GuideController.TryCompleteGuide(ConstGuideId.CLOTHING_SYNTHETIC, 7);
  388. GuideController.TryGuide(_ui.m_btnCiPai.target, ConstGuideId.UP_CARD_LV, 2, "获得了一张“词牌”,点击查看", -1, false, 0, 0, 0, true, true);
  389. GuideController.TryGuide(_btnStudio, ConstGuideId.STUDIO_OPEN, 1, "工作室开门啦,进去看看~~");
  390. GuideController.TryGuide(_ui.m_btnXiuFang.target, ConstGuideId.SUIT_LIST_VIEW, 1, "获得“天衣”服饰后,可进行养护和焕新,到绣坊看看");
  391. GuideController.TryCompleteGuide(ConstGuideId.STUDIO_OPEN, 2);
  392. }
  393. }
  394. }