MainUIView.cs 19 KB

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