StoryChapterView.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. using FairyGUI;
  2. using UI.CommonGame;
  3. using UI.Main;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using System.Collections;
  7. using ET;
  8. namespace GFGGame
  9. {
  10. public class StoryChapterView : BaseWindow
  11. {
  12. private UI_StoryChapterUI _ui;
  13. private int _chapterID;
  14. private GComponent _compChapter;
  15. private ValueBarController _valueBarController;
  16. private GObject _unPasslevelItem;
  17. private GObject _endLevelItem;
  18. private EffectUI _effectUI1;
  19. private EffectUI _effectUI2;
  20. private EffectUI _effectUI3;
  21. private EffectUI _effectUI4;
  22. private EffectUI _effectUI5;
  23. private EffectUI _effectUI6;
  24. private EffectUI _effectUI7;
  25. private GComponent _comEff;
  26. private GComponent _effFirst;
  27. //当前章节索引
  28. private int newIndex;
  29. //y轴移动索引
  30. private float indexY;
  31. private GameObject gamey;
  32. //特效类型数组,这里后面可以二维数组,放向左和向右的
  33. private string[] effArray = new string[2] { "ZJ_JuQing", "ZJ_ZD" };
  34. private int currentDifficulty;
  35. public override void Dispose()
  36. {
  37. EffectUIPool.Recycle(_effectUI1);
  38. _effectUI1 = null;
  39. EffectUIPool.Recycle(_effectUI2);
  40. _effectUI2 = null;
  41. EffectUIPool.Recycle(_effectUI3);
  42. _effectUI3 = null;
  43. EffectUIPool.Recycle(_effectUI4);
  44. _effectUI4 = null;
  45. EffectUIPool.Recycle(_effectUI5);
  46. _effectUI5 = null;
  47. EffectUIPool.Recycle(_effectUI6);
  48. _effectUI6 = null;
  49. EffectUIPool.Recycle(_effectUI7);
  50. _effectUI7 = null;
  51. if (_comEff != null)
  52. {
  53. _comEff.RemoveFromParent();
  54. _comEff.Dispose();
  55. }
  56. if (_effFirst != null)
  57. {
  58. _effFirst.RemoveFromParent();
  59. _effFirst.Dispose();
  60. }
  61. if (_valueBarController != null)
  62. {
  63. _valueBarController.Dispose();
  64. _valueBarController = null;
  65. }
  66. if (_ui != null)
  67. {
  68. _ui.Dispose();
  69. _ui = null;
  70. }
  71. base.Dispose();
  72. }
  73. protected override void Init()
  74. {
  75. base.Init();
  76. _ui = UI_StoryChapterUI.Create();
  77. viewCom = _ui.target;
  78. isfullScreen = true;
  79. isReturnView = true;
  80. }
  81. protected override void OnInit()
  82. {
  83. base.OnInit();
  84. _valueBarController = new ValueBarController(_ui.m_valueBar);
  85. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  86. _ui.m_btnHome.onClick.Add(OnClickBtnHome);
  87. _ui.m_switchChapter.onClick.Add(OnClickSwitchBack);
  88. _ui.m_chapter.m_compChapterScroll.m_imgBegin.onClick.Add(OnClickNext);
  89. _ui.m_suitIcon.onClick.Add(OnClickGotoView);
  90. _ui.m_bonusBox1.target.onClick.Add(() =>
  91. {
  92. OnClickBonusBox(_ui.m_bonusBox1, 0);
  93. });
  94. _ui.m_bonusBox2.target.onClick.Add(() =>
  95. {
  96. OnClickBonusBox(_ui.m_bonusBox2, 1);
  97. });
  98. _ui.m_bonusBox3.target.onClick.Add(() =>
  99. {
  100. OnClickBonusBox(_ui.m_bonusBox3, 2);
  101. });
  102. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("zxian_bg3");
  103. //_comEff = new GComponent();
  104. //_comEff = UIPackage.CreateObject(UI_MainUI.PACKAGE_NAME, "ComEff").asCom;
  105. //_effectUI1 = EffectUIPool.CreateEffectUI(_comEff.GetChild("holder").asGraph, "ui_gk", "ui_gk_sg");
  106. _effFirst = new GComponent();
  107. _effFirst = UIPackage.CreateObject(UI_MainUI.PACKAGE_NAME, "ComEff").asCom;
  108. _effectUI3 = EffectUIPool.CreateEffectUI(_ui.m_bgEffect, "ui_zj", "ZX_BG_TX");
  109. _effectUI4 = EffectUIPool.CreateEffectUI(_ui.m_chapter.m_compChapterScroll.m_nextEffect, "ui_zj", "ZX_Next_Boat");
  110. _effectUI5 = EffectUIPool.CreateEffectUI(_ui.m_bonusBox1.m_effect, "ui_zj", "Claimed");
  111. _effectUI6 = EffectUIPool.CreateEffectUI(_ui.m_bonusBox2.m_effect, "ui_zj", "Claimed");
  112. _effectUI7 = EffectUIPool.CreateEffectUI(_ui.m_bonusBox3.m_effect, "ui_zj", "Claimed");
  113. }
  114. protected override void AddEventListener()
  115. {
  116. EventAgent.AddEventListener(ConstMessage.NOTICE_MAINSTORY_BOXBONUS_STATE, UpdateBonusBox);
  117. }
  118. protected override void OnShown()
  119. {
  120. base.OnShown();
  121. GRoot.inst.touchable = false;
  122. SuitFosterProxy.SendGetSuitInfos().Coroutine();
  123. MusicManager.Instance.PlayCroutine(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));
  124. if ((this.viewData as object[]) != null)
  125. {
  126. _chapterID = (int)(this.viewData as object[])[0];
  127. currentDifficulty = (int)(this.viewData as object[])[1];
  128. if (!backRefresh && MainStoryDataManager.currentChapterCfgId != _chapterID)
  129. {
  130. _chapterID = MainStoryDataManager.currentChapterCfgId;
  131. }
  132. else
  133. {
  134. MainStoryDataManager.currentChapterCfgId = _chapterID;
  135. }
  136. }
  137. else
  138. {
  139. _chapterID = (int)this.viewData;
  140. }
  141. _valueBarController.OnShown();
  142. _ui.m_t0.SetHook("canHit", () => { GRoot.inst.touchable = true; });
  143. _ui.m_t0.Play();
  144. Timers.inst.AddUpdate(CheckGuide);
  145. UpdateView();
  146. //
  147. }
  148. protected override void OnHide()
  149. {
  150. base.OnHide();
  151. _unPasslevelItem = null;
  152. _endLevelItem = null;
  153. // _ui.m_chapter.RemoveChildren(0, 0, true);
  154. GRoot.inst.touchable = true;
  155. _valueBarController.OnHide();
  156. Timers.inst.Remove(SetContainerY);
  157. Timers.inst.Remove(CheckGuide);
  158. }
  159. protected override void RemoveEventListener()
  160. {
  161. base.RemoveEventListener();
  162. EventAgent.RemoveEventListener(ConstMessage.NOTICE_MAINSTORY_BOXBONUS_STATE, UpdateBonusBox);
  163. }
  164. private void OnClickBtnBack()
  165. {
  166. ViewManager.GoBackFrom(typeof(StoryChapterView).FullName);
  167. //GameController.GoBackToMainView();
  168. }
  169. private void UpdateView()
  170. {
  171. //由于这里会切换特效,所以切换界面时进行清空
  172. EffectUIPool.Recycle(_effectUI2);
  173. _effectUI2 = null;
  174. if (_effFirst != null)
  175. {
  176. _effFirst.RemoveFromParent();
  177. }
  178. StoryChapterCfg chapterCfg = StoryChapterCfgArray.Instance.GetCfg(_chapterID);
  179. newIndex = StoryUtil.GetChapterOrder(chapterCfg.id);
  180. indexY = 111.0f * Mathf.Max(0, (float)StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(chapterCfg.type, chapterCfg.subType, chapterCfg.id).Count - 5);
  181. gamey = GameObject.Find("Stage/GRoot/Window - StoryChapterUI/ContentPane/CompChapter/Container/Container");
  182. _ui.m_chapter.m_compChapterScroll.m_imgBegin.visible = false;
  183. _ui.m_chapter.m_compChapterScroll.m_nextEffect.visible = false;
  184. _ui.m_targetSuit.visible = false;
  185. Timers.inst.StartCoroutine(InitChapter());
  186. //Timers.inst.Add(0.2f, 1, SetContainerY);
  187. _ui.m_chapter.m_compChapterScroll.target.y = 1;
  188. //招财进宝活动
  189. if (chapterCfg.subType == 2)
  190. {
  191. UI_ComponentValueBar valueBar = UI_ComponentValueBar.Proxy(_ui.m_valueBar);
  192. valueBar.m_c1.selectedIndex = 12;
  193. UI_ComponentValueBar.ProxyEnd();
  194. _valueBarController.UpdateList(new List<int>() { ConstItemID.DIAMOND_PURPLE, ConstItemID.DIAMOND_RED });
  195. _ui.m_selectChapter.visible = false;
  196. _ui.m_switchChapter.visible = false;
  197. _ui.m_bonusBox.visible = false;
  198. _ui.m_ActivityZCJB.visible = true;
  199. long timeActivity = ActivityGlobalDataManager.Instance.GetActivityInfoOneByType(17).EndTime - TimeHelper.ServerNow();
  200. _ui.m_ZCJBTimeText.text = timeActivity > TimeUtil.SECOND_PER_DAY * 1000 ? TimeUtil.FormattingTimeTo_DDHHmm(timeActivity) : TimeUtil.FormattingTimeTo_HHmmss(timeActivity);
  201. }
  202. else
  203. {
  204. UI_ComponentValueBar valueBar = UI_ComponentValueBar.Proxy(_ui.m_valueBar);
  205. valueBar.m_c1.selectedIndex = 1;
  206. UI_ComponentValueBar.ProxyEnd();
  207. _ui.m_selectChapter.visible = true;
  208. _ui.m_switchChapter.visible = true;
  209. _ui.m_bonusBox.visible = true;
  210. _ui.m_ActivityZCJB.visible = false;
  211. }
  212. }
  213. private void OnClickSwitchBack()
  214. {
  215. Timers.inst.Remove(SetContainerY);
  216. ViewManager.Show<StoryChapterListView>(new object[] { Mathf.Max(0, currentDifficulty), newIndex });
  217. }
  218. private void OnClickGotoView()
  219. {
  220. StoryChapterCfg chapterSuitCfg = StoryChapterCfgArray.Instance.GetCfg(_chapterID);
  221. ViewManager.Show<ClothingSyntheticView>(new object[] { chapterSuitCfg.suitId, 0, _chapterID }, false, false);
  222. }
  223. private void OnClickBtnHome()
  224. {
  225. GameController.GoBackToMainView();
  226. }
  227. private void OnClickNext()
  228. {
  229. StoryChapterCfg chapterSuitCfg = StoryChapterCfgArray.Instance.GetCfg(_chapterID);
  230. if (MainStoryDataManager.CheckChapterUnlock(_chapterID + 1) && StoryController.CheckSuitGot(chapterSuitCfg.suitId))
  231. {
  232. Timers.inst.Remove(SetContainerY);
  233. _chapterID += 1;
  234. MainStoryDataManager.currentChapterCfgId = _chapterID;
  235. //ViewManager.Show<StoryChapterView>(new object[] { (_chapterID+1), currentDifficulty });
  236. UpdateView();
  237. }
  238. else
  239. {
  240. StoryChapterCfg chapterCfg = StoryChapterCfgArray.Instance.GetCfg(_chapterID + 1);
  241. if (!StoryController.CheckSuitGot(chapterSuitCfg.suitId))
  242. {
  243. PromptController.Instance.ShowFloatTextPrompt("需集齐所需套装");
  244. }
  245. else if (GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) < chapterCfg.lvl)
  246. {
  247. PromptController.Instance.ShowFloatTextPrompt(string.Format("角色等级达到{0}级开启", chapterCfg.lvl));
  248. }
  249. }
  250. }
  251. private IEnumerator InitChapter()
  252. {
  253. StoryChapterCfg chapterCfg = StoryChapterCfgArray.Instance.GetCfg(_chapterID);
  254. _ui.m_txtChapterName0.text = chapterCfg.name.Length > 0 ? chapterCfg.name[0].ToString() : "";
  255. _ui.m_txtChapterName1.text = chapterCfg.name.Length > 1 ? chapterCfg.name[1].ToString() : "";
  256. _ui.m_txtChapterName2.text = chapterCfg.name.Length > 2 ? chapterCfg.name[2].ToString() : "";
  257. _ui.m_txtChapterName3.text = chapterCfg.name.Length > 3 ? chapterCfg.name[3].ToString() : "";
  258. _ui.m_txtChapterName4.text = chapterCfg.name.Length > 4 ? chapterCfg.name[4].ToString() : "";
  259. int order = StoryUtil.GetChapterOrder(chapterCfg.id);
  260. _ui.m_txtChapter.text = order < 10 ? "0" + order : order.ToString();
  261. int starCountChapter = InstanceZonesDataManager.GetChapterStarCount(_chapterID, chapterCfg.type, chapterCfg.subType);
  262. _ui.m_txtStarCount.text = "" + starCountChapter + "/" + chapterCfg.bonusStar3;
  263. UpdateBonusBoxName(_ui.m_bonusBox1, "" + chapterCfg.bonusStar1);
  264. UpdateBonusBoxName(_ui.m_bonusBox2, "" + chapterCfg.bonusStar2);
  265. UpdateBonusBoxName(_ui.m_bonusBox3, "" + chapterCfg.bonusStar3);
  266. UpdateBonusBox();
  267. var list = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(chapterCfg.type, chapterCfg.subType, chapterCfg.id);
  268. int endLevel = 0;
  269. int UnlockCount = 0;
  270. _compChapter = _ui.m_chapter.m_compChapterScroll.target;
  271. float starPosY = _ui.m_chapter.m_compChapterScroll.m_imgBegin.y;
  272. int lineGap = 4500 / list.Count;
  273. StoryLevelCfg lastLevelCfg = list[list.Count - 1];
  274. StoryChapterCfg LastChapterCfg = StoryChapterCfgArray.Instance.GetCfg(_chapterID + 1);
  275. if (lastLevelCfg != null && InstanceZonesDataManager.CheckLevelPass(lastLevelCfg.id) && LastChapterCfg != null)
  276. {
  277. _ui.m_chapter.m_compChapterScroll.m_imgBegin.visible = true;
  278. _ui.m_chapter.m_compChapterScroll.m_nextEffect.visible = true;
  279. if (chapterCfg.suitId > 0 && chapterCfg.subType == 0)
  280. {
  281. _ui.m_targetSuit.visible = true;
  282. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(chapterCfg.suitId);
  283. _ui.m_suitIcon.url = ResPathUtil.GetIconPath(suitCfg.res, "png");
  284. _ui.m_suitText.text = suitCfg.name;
  285. int count;
  286. int totalCount;
  287. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(chapterCfg.suitId, out count, out totalCount);
  288. _ui.m_suitNum.text = count + "/" + totalCount;
  289. }
  290. else
  291. {
  292. _ui.m_targetSuit.visible = false;
  293. }
  294. }
  295. //根据困难程度选择显示图片
  296. currentDifficulty = chapterCfg.subType;
  297. if (currentDifficulty == 1)
  298. {
  299. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("zhangjie_bg");
  300. }
  301. else
  302. {
  303. currentDifficulty = 0;
  304. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("bg_zhuxian");
  305. }
  306. //_comEff.visible = false;
  307. //_effFirst.visible = false;
  308. for (int i = 0; i < 20; i++)
  309. {
  310. GObject obj = _ui.m_chapter.m_compChapterScroll.target.GetChild("g" + (19 - i + 1));
  311. obj.SetPosition(obj.x, starPosY - lineGap * i - 300, 0); ;
  312. StoryLevelCfg levelCfg = i < list.Count ? list[i] : null;
  313. UI_CompStoryLevelItem levelItem = UI_CompStoryLevelItem.Proxy(obj);
  314. levelItem.m_fightBg.visible = true;
  315. levelItem.m_loaDialogBg.visible = true;
  316. if (levelCfg != null && MainStoryDataManager.CheckLevelUnlock(levelCfg.id))
  317. {
  318. UnlockCount++;
  319. levelItem.target.data = levelCfg.id;
  320. levelItem.target.visible = true;
  321. levelItem.target.onClick.Clear();
  322. levelItem.target.onClick.Add(OnClickLevelItem);
  323. string showId = StoryUtil.GetChapterOrder(_chapterID) + "-" + levelCfg.order;
  324. levelItem.m_txtDialogOrder.text = showId;
  325. levelItem.m_txtFightOrder.text = showId;
  326. if (levelCfg.fightID.Length > 0)
  327. {
  328. levelItem.m_c1.selectedIndex = 1;
  329. int score = InstanceZonesDataManager.GetScoreHighest(levelCfg.id);
  330. if (score <= 0)
  331. {
  332. levelItem.m_flower.target.visible = false;
  333. }
  334. else
  335. {
  336. levelItem.m_flower.target.visible = true;
  337. int starCount = InstanceZonesDataManager.GetStarCountHistory(levelCfg.id);
  338. StoryUtil.UpdateStar(starCount, levelItem.m_flower.target, Mathf.Max(0, currentDifficulty));
  339. }
  340. }
  341. else
  342. {
  343. levelItem.m_c1.selectedIndex = 0;
  344. levelItem.m_flower.target.visible = false;
  345. levelItem.m_txtName.text = levelCfg.name;
  346. levelItem.m_comDialogBg.m_loabg.url = ResPathUtil.GetBgImgPath(chapterCfg.bgRes);
  347. levelItem.m_comDialogBg.m_loaIcon.url = ResPathUtil.GetChapterGuideIconPath(chapterCfg.bgRes);
  348. levelItem.m_comDialogBg.m_c1.selectedIndex = Random.Range(0, 10);
  349. }
  350. //根据困难程度选择显示图片
  351. if (currentDifficulty == 1)
  352. {
  353. levelItem.m_loaDialogBg.url = "ui://Main/zxian_btn_jq_jy";
  354. levelItem.m_fightBg.url = "ui://Main/zxian_btn_zd_jy";
  355. levelItem.m_txtFightOrder.text = string.Format("{0}", StringUtil.GetColorText(showId.ToString(), "#E3F8FF"));
  356. levelItem.m_fightIconA.alpha = 0;
  357. levelItem.m_fightIconB.alpha = 0;
  358. _ui.m_txtBg.url = "ui://Main/zxian_chapter_dec_jy";
  359. _ui.m_txtChapterName0.strokeColor = new Color(0.592f, 0.773f, 0.961f, 1.000f);
  360. _ui.m_txtChapterName1.strokeColor = new Color(0.592f, 0.773f, 0.961f, 1.000f);
  361. _ui.m_txtChapterName2.strokeColor = new Color(0.592f, 0.773f, 0.961f, 1.000f);
  362. _ui.m_txtChapterName3.strokeColor = new Color(0.592f, 0.773f, 0.961f, 1.000f);
  363. _ui.m_txtChapterName4.strokeColor = new Color(0.592f, 0.773f, 0.961f, 1.000f);
  364. _ui.m_txtChapter.strokeColor = new Color(0.592f, 0.773f, 0.961f, 1.000f);
  365. }
  366. else
  367. {
  368. levelItem.m_loaDialogBg.url = "ui://Main/zxian_btn_jq";
  369. levelItem.m_fightBg.url = "ui://Main/zxian_btn_zd";
  370. levelItem.m_txtFightOrder.text = string.Format("{0}", StringUtil.GetColorText(showId.ToString(), "#FFEABF"));
  371. levelItem.m_fightIconA.alpha = 0;
  372. levelItem.m_fightIconB.alpha = 0;
  373. _ui.m_txtBg.url = "ui://Main/zxian_chapter_dec";
  374. _ui.m_txtChapterName0.strokeColor = new Color(1.000f, 0.686f, 0.318f, 1.000f);
  375. _ui.m_txtChapterName1.strokeColor = new Color(1.000f, 0.686f, 0.318f, 1.000f);
  376. _ui.m_txtChapterName2.strokeColor = new Color(1.000f, 0.686f, 0.318f, 1.000f);
  377. _ui.m_txtChapterName3.strokeColor = new Color(1.000f, 0.686f, 0.318f, 1.000f);
  378. _ui.m_txtChapterName4.strokeColor = new Color(1.000f, 0.686f, 0.318f, 1.000f);
  379. _ui.m_txtChapter.strokeColor = new Color(1.000f, 0.686f, 0.318f, 1.000f);
  380. }
  381. levelItem.m_holder.visible = !InstanceZonesDataManager.CheckLevelPass(levelCfg.id);
  382. if (!InstanceZonesDataManager.CheckLevelPass(levelCfg.id))
  383. {
  384. //设置为解锁关卡
  385. MainStoryDataManager.currentLevelCfgId = levelCfg.id;
  386. _unPasslevelItem = levelItem.target;
  387. //levelItem.target.AddChild(_comEff);
  388. //_comEff.visible = true;
  389. //设置解锁特效
  390. string effName;
  391. if (currentDifficulty == 1)
  392. {
  393. effName = effArray[levelItem.m_c1.selectedIndex] + "_Bule";
  394. }
  395. else
  396. {
  397. effName = effArray[levelItem.m_c1.selectedIndex];
  398. }
  399. if (levelItem.m_c1.selectedIndex == 0)
  400. {
  401. if (levelItem.m_c2.selectedIndex == 0)
  402. {
  403. _effectUI2 = EffectUIPool.CreateEffectUI(_effFirst.GetChild("effect_jq_left").asGraph, "ui_zj", effName);
  404. _effFirst.GetChild("effect_jq_left").rotationY = 180;
  405. }
  406. else
  407. {
  408. _effectUI2 = EffectUIPool.CreateEffectUI(_effFirst.GetChild("effect_jq").asGraph, "ui_zj", effName);
  409. _effFirst.GetChild("effect_jq").rotationY = 0;
  410. }
  411. }
  412. else
  413. {
  414. _effectUI2 = EffectUIPool.CreateEffectUI(_effFirst.GetChild("effect_zd").asGraph, "ui_zj", effName);
  415. if (levelItem.m_c2.selectedIndex == 0)
  416. {
  417. _effFirst.GetChild("effect_zd").rotationY = 0;
  418. }
  419. else
  420. {
  421. _effFirst.GetChild("effect_zd").rotationY = 180;
  422. }
  423. }
  424. levelItem.target.AddChild(_effFirst);
  425. levelItem.m_fightBg.visible = false;
  426. levelItem.m_loaDialogBg.visible = false;
  427. levelItem.m_t0.Play();
  428. _effFirst.visible = true;
  429. //Timers.inst.Add(1.7f, 1, HideEffect, obj);
  430. }
  431. if (levelCfg.order > endLevel)
  432. {
  433. endLevel = levelCfg.order;
  434. _endLevelItem = levelItem.target;
  435. }
  436. }
  437. else
  438. {
  439. levelItem.target.visible = false;
  440. }
  441. UI_CompStoryLevelItem.ProxyEnd();
  442. }
  443. yield return new WaitForEndOfFrame();
  444. _ui.m_chapter.m_compChapterScroll.target.y = 0; //Mathf.Max(0, _ui.m_chapter.target.height - _ui.m_chapter.m_compChapterScroll.target.height);
  445. if (gamey != null)
  446. gamey.transform.position = new Vector3(0, indexY, 0);
  447. }
  448. private void SetContainerY(object param = null)
  449. {
  450. _ui.m_chapter.m_compChapterScroll.target.y = 1; //Mathf.Max(0, _ui.m_chapter.target.height - _ui.m_chapter.m_compChapterScroll.target.height - 1);
  451. }
  452. private void HideEffect(object param = null)
  453. {
  454. //_effFirst.visible = false;
  455. }
  456. private void OnClickLevelItem(EventContext context)
  457. {
  458. UI_CompStoryLevelItem levelItem = UI_CompStoryLevelItem.Proxy(context.sender as GObject);
  459. int levelCfgId = (int)levelItem.target.data;
  460. UI_CompStoryLevelItem.ProxyEnd();
  461. StoryController.ShowLevelView(levelCfgId);
  462. TryCompleteGuide();
  463. }
  464. private void UpdateBonusBoxName(UI_CompBonusBox bonusBox, string name)
  465. {
  466. bonusBox.m_txtName.text = name;
  467. }
  468. private void UpdateBonusBox()
  469. {
  470. UpdateBonusBoxStatus(_ui.m_bonusBox1, 0);
  471. UpdateBonusBoxStatus(_ui.m_bonusBox2, 1);
  472. UpdateBonusBoxStatus(_ui.m_bonusBox3, 2);
  473. }
  474. private void UpdateBonusBoxStatus(UI_CompBonusBox bonusBox, int index)
  475. {
  476. int status = MainStoryDataManager.GetChapterBonusStatus(_chapterID, index);
  477. bonusBox.m_iconActive.visible = status == ConstBonusStatus.CAN_GET;
  478. bonusBox.m_effect.visible = status == ConstBonusStatus.CAN_GET;
  479. // bonusBox.m_ComRewardEffect.visible = status == ConstBonusStatus.CAN_GET;
  480. if (status == ConstBonusStatus.GOT)
  481. {
  482. bonusBox.m_icon.url = "ui://Main/tgjljinnang_off";
  483. }
  484. else
  485. {
  486. bonusBox.m_icon.url = "ui://Main/tgjljinnang_no";
  487. }
  488. bonusBox.target.data = status;
  489. }
  490. private async void OnClickBonusBox(UI_CompBonusBox bonusBox, int index)
  491. {
  492. int status = (int)bonusBox.target.data;
  493. if (status == ConstBonusStatus.CAN_GET)
  494. {
  495. bool got = await MainStorySProxy.GetMainStoryBoxBonus(_chapterID, index);
  496. if (got)
  497. {
  498. List<ItemData> bonusList = MainStoryDataManager.GetChapterBonus(_chapterID, index);
  499. if (bonusList != null && bonusList.Count > 0)
  500. {
  501. BonusController.TryShowBonusList(bonusList);
  502. }
  503. UpdateBonusBoxStatus(bonusBox, index);
  504. }
  505. }
  506. // else if (status == ConstBonusStatus.GOT)
  507. // {
  508. // PromptController.Instance.ShowFloatTextPrompt("这个宝箱已经被领取过了");
  509. // }
  510. else
  511. {
  512. List<ItemData> rewards = StoryBonusDataCache.GetChapterBonusList(_chapterID, index);
  513. int star = StoryBonusDataCache.GetChapterBonusStar(_chapterID, index);
  514. ViewManager.Show<RewardPreView>(new object[] { rewards, "宝箱奖励", string.Format("本章达成{0}星可领取", star) });
  515. // PromptController.Instance.ShowFloatTextPrompt("关卡总分不足,继续加油吧。");
  516. }
  517. }
  518. private void CheckGuide(object param)
  519. {
  520. if (GuideDataManager.IsGuideFinish(ConstGuideId.START_FIGHT) <= 0
  521. || GuideDataManager.IsGuideFinish(ConstGuideId.FREEDOM_DRESS) <= 0
  522. || GuideDataManager.IsGuideFinish(ConstGuideId.ENTER_CHAPTER) <= 0
  523. || GuideDataManager.IsGuideFinish(ConstGuideId.BUY_CLOTHING) <= 0
  524. || GuideDataManager.IsGuideFinish(ConstGuideId.UP_CARD_LV) <= 0
  525. || GuideDataManager.IsGuideFinish(ConstGuideId.ENTER_CHAPTER_1) <= 0
  526. || GuideDataManager.IsGuideFinish(ConstGuideId.ENTER_CHAPTER_2) <= 0
  527. //|| GuideDataManager.IsGuideFinish(ConstGuideId.ENTER_CHAPTER_3) <= 0
  528. || GuideDataManager.IsGuideFinish(ConstGuideId.ENTER_CHAPTER_4) <= 0
  529. || GuideDataManager.IsGuideFinish(ConstGuideId.ENTER_CHAPTER_5) <= 0
  530. || GuideDataManager.IsGuideFinish(ConstGuideId.UP_CARD_STAR) <= 0
  531. || GuideDataManager.IsGuideFinish(ConstGuideId.ARENA_OPEN) <= 0
  532. || GuideDataManager.IsGuideFinish("ClothingSelectView") <= 0
  533. || GuideDataManager.IsGuideFinish(ConstGuideId.STUDIO_FILING) <=0
  534. || GuideDataManager.IsGuideFinish("TimeTracingShowView") <=0)
  535. //|| GuideDataManager.IsGuideFinish(ConstGuideId.CLOTHING_DECOMPOSE) <= 0)
  536. {
  537. UpdateToCheckGuide(null);
  538. }
  539. else
  540. {
  541. Timers.inst.Remove(CheckGuide);
  542. }
  543. }
  544. protected override void UpdateToCheckGuide(object param)
  545. {
  546. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  547. GComponent unPasslevelCom = _unPasslevelItem == null ? null : _unPasslevelItem.asCom;
  548. bool isGuide0 = GuideController.TryGuide(unPasslevelCom, ConstGuideId.START_FIGHT, 1, "尝试换上一套衣服吧。");
  549. bool isGuide1 = GuideController.TryGuide(_ui.m_btnHome, ConstGuideId.FREEDOM_DRESS, 1, "获得的服饰随时可以查看和试穿。");
  550. bool isGuide2 = GuideController.TryGuide(unPasslevelCom, ConstGuideId.ENTER_CHAPTER, 4, "来继续我们的旅程吧。");
  551. GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER, 4);
  552. bool isGuide3 = GuideController.TryGuide(unPasslevelCom, ConstGuideId.ENTER_CHAPTER_1, 3, "来继续我们的旅程吧。");
  553. GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER_1, 3);
  554. bool isGuide4 = GuideController.TryGuide(unPasslevelCom, ConstGuideId.BUY_CLOTHING, 1, "停电了室内温度升高,点击换身轻薄的服饰吧。");
  555. bool isGuide5 = GuideController.TryGuide(_ui.m_btnHome, ConstGuideId.UP_CARD_LV, 1, "点击返回主界面。");
  556. //bool isGuide6 = GuideController.TryGuide(_ui.m_btnHome, ConstGuideId.CLOTHING_DECOMPOSE, 1, "点击返回主界面。");
  557. bool isGuide7 = GuideController.TryGuide(unPasslevelCom, ConstGuideId.ENTER_CHAPTER_2, 3, "来继续我们的旅程吧。");
  558. GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER_2, 3);
  559. //bool isGuide8 = GuideController.TryGuide(unPasslevelCom, ConstGuideId.ENTER_CHAPTER_3, 3, "来继续我们的旅程吧。");
  560. //GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER_3, 3);
  561. bool isGuide10 = GuideController.TryGuide(unPasslevelCom, ConstGuideId.ENTER_CHAPTER_4, 2, "来继续我们的旅程吧。");
  562. GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER_4, 2);
  563. bool isGuide11 = GuideController.TryGuide(unPasslevelCom, ConstGuideId.ENTER_CHAPTER_5, 3, "来继续我们的旅程吧。");
  564. GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER_5, 3);
  565. bool isGuide9 = GuideController.TryGuide(_ui.m_btnHome, ConstGuideId.UP_CARD_STAR, 1, "点击返回主界面。");
  566. bool isGuide12 = GuideController.TryGuide(_ui.m_btnHome, ConstGuideId.ARENA_OPEN, 1, "点击返回主界面。");
  567. bool isGuide13 = GuideController.TryGuide(_ui.m_btnHome, "ClothingSelectView", 1, "点击返回主界面。");
  568. bool isGuide14 = GuideController.TryGuide(_ui.m_btnHome, ConstGuideId.STUDIO_FILING, 1, "点击返回主界面。");
  569. bool isGuide15 = GuideController.TryGuide(_ui.m_btnHome, "TimeTracingShowView", 1, "点击返回主界面。");
  570. //&& !isGuide6 && !isGuide8
  571. _ui.m_chapter.target.scrollPane.touchEffect = !isGuide0 && !isGuide1 && !isGuide2 && !isGuide3 && !isGuide4 && !isGuide5 && !isGuide7 && !isGuide9 && !isGuide10;
  572. }
  573. protected override void TryCompleteGuide()
  574. {
  575. base.TryCompleteGuide();
  576. // GuideCfg cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.ENTER_CHAPTER);
  577. GuideController.TryCompleteGuideIndex(ConstGuideId.ENTER_CHAPTER, 4);
  578. GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER, 4);
  579. // GuideCfg cfg1 = GuideCfgArray.Instance.GetCfg(ConstGuideId.ENTER_CHAPTER_1);
  580. GuideController.TryCompleteGuideIndex(ConstGuideId.ENTER_CHAPTER_1, 3);
  581. GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER_1, 3);
  582. // GuideCfg cfg2 = GuideCfgArray.Instance.GetCfg(ConstGuideId.ENTER_CHAPTER_2);
  583. GuideController.TryCompleteGuideIndex(ConstGuideId.ENTER_CHAPTER_2, 3);
  584. GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER_2, 3);
  585. // GuideCfg cfg3 = GuideCfgArray.Instance.GetCfg(ConstGuideId.ENTER_CHAPTER_3);
  586. //GuideController.TryCompleteGuideIndex(ConstGuideId.ENTER_CHAPTER_3, 3);
  587. //GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER_3, 3);
  588. // GuideCfg cfg4 = GuideCfgArray.Instance.GetCfg(ConstGuideId.ENTER_CHAPTER_4);
  589. GuideController.TryCompleteGuideIndex(ConstGuideId.ENTER_CHAPTER_4, 2);
  590. GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER_4, 2);
  591. // GuideCfg cfg5 = GuideCfgArray.Instance.GetCfg(ConstGuideId.ENTER_CHAPTER_5);
  592. //GuideController.TryCompleteGuideIndex(ConstGuideId.ENTER_CHAPTER_5, 4);
  593. GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER_5, 3);
  594. }
  595. }
  596. }