StoryChapterView.cs 30 KB

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