StoryChapterView.cs 32 KB

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