StoryChapterView.cs 28 KB

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