StoryChapterView.cs 36 KB

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