StoryChapterView.cs 32 KB

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