| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353 | 
							- using FairyGUI;
 
- using UI.CommonGame;
 
- using UI.Main;
 
- using System.Collections.Generic;
 
- using UnityEngine;
 
- namespace GFGGame
 
- {
 
-     public class StoryChapterView : BaseView
 
-     {
 
-         private UI_StoryChapterUI _ui;
 
-         private int _chapterID;
 
-         private GComponent _compChapter;
 
-         private ValueBarController _valueBarController;
 
-         private GObject _unPasslevelItem;
 
-         private GObject _endLevelItem;
 
-         private GameObject _gameObject;
 
-         private GoWrapper _wrapper;
 
-         public override void Dispose()
 
-         {
 
-             if (_valueBarController != null)
 
-             {
 
-                 _valueBarController.Dispose();
 
-                 _valueBarController = null;
 
-             }
 
-             SceneController.DestroyObjectFromView(_gameObject, _wrapper);
 
-             if (_ui != null)
 
-             {
 
-                 _ui.Dispose();
 
-                 _ui = null;
 
-             }
 
-             base.Dispose();
 
-         }
 
-         protected override void Init()
 
-         {
 
-             base.Init();
 
-             _ui = UI_StoryChapterUI.Create();
 
-             viewCom = _ui.target;
 
-             isfullScreen = true;
 
-         }
 
-         protected override void OnInit()
 
-         {
 
-             base.OnInit();
 
-             _valueBarController = new ValueBarController(_ui.m_valueBar);
 
-             _ui.m_btnBack.onClick.Add(OnClickBtnBack);
 
-             _ui.m_btnHome.onClick.Add(OnClickBtnHome);
 
-             _ui.m_bonusBox1.target.onClick.Add(() =>
 
-             {
 
-                 OnClickBonusBox(_ui.m_bonusBox1, 0);
 
-             });
 
-             _ui.m_bonusBox2.target.onClick.Add(() =>
 
-             {
 
-                 OnClickBonusBox(_ui.m_bonusBox2, 1);
 
-             });
 
-             _ui.m_bonusBox3.target.onClick.Add(() =>
 
-             {
 
-                 OnClickBonusBox(_ui.m_bonusBox3, 2);
 
-             });
 
-         }
 
-         protected override void AddEventListener()
 
-         {
 
-             EventAgent.AddEventListener(ConstMessage.NOTICE_MAINSTORY_BOXBONUS_STATE, UpdateBonusBox);
 
-         }
 
-         protected override void OnShown()
 
-         {
 
-             base.OnShown();
 
-             _ui.target.touchable = false;
 
-             MusicManager.Instance.Play(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));
 
-             _chapterID = (int)viewData;
 
-             MainStoryDataManager.currentChapterCfgId = _chapterID;
 
-             _compChapter = (GComponent)UIPackage.CreateObject("Main", "CompChapter" + _chapterID);
 
-             StoryChapterCfg cfg = StoryChapterCfgArray.Instance.GetCfg(_chapterID);
 
-             _compChapter.GetChild("loaBg").asLoader.url = ResPathUtil.GetBgImgPath(cfg.bgRes);
 
-             _ui.m_chapter.scrollPane.touchEffect = true;
 
-             _ui.m_chapter.AddChild(_compChapter);
 
-             InitChapter();
 
-             _valueBarController.OnShown();
 
-             // _valueBarController.Controller(1);
 
-             _ui.target.touchable = true;
 
-             Timers.inst.AddUpdate(CheckGuide);
 
-         }
 
-         protected override void OnHide()
 
-         {
 
-             base.OnHide();
 
-             _unPasslevelItem = null;
 
-             _endLevelItem = null;
 
-             _ui.m_chapter.RemoveChildren(0, 0, true);
 
-             _valueBarController.OnHide();
 
-             Timers.inst.Remove(CheckGuide);
 
-         }
 
-         protected override void RemoveEventListener()
 
-         {
 
-             base.RemoveEventListener();
 
-             EventAgent.RemoveEventListener(ConstMessage.NOTICE_MAINSTORY_BOXBONUS_STATE, UpdateBonusBox);
 
-         }
 
-         private void OnClickBtnBack()
 
-         {
 
-             ViewManager.GoBackFrom(ViewName.STORY_CHAPTER_VIEW);
 
-         }
 
-         private void OnClickBtnHome()
 
-         {
 
-             GameController.GoBackToMainView();
 
-         }
 
-         private void InitChapter()
 
-         {
 
-             StoryChapterCfg chapterCfg = StoryChapterCfgArray.Instance.GetCfg(_chapterID);
 
-             _ui.m_txtChapterName.text = StoryUtil.GetChapterOrderText(_chapterID) + "·" + chapterCfg.name;
 
-             int starCountChapter = InstanceZonesDataManager.GetChapterStarCount(_chapterID, chapterCfg.type, chapterCfg.subType);
 
-             _ui.m_txtStarCount.text = "" + starCountChapter + "/" + chapterCfg.bonusStar3;
 
-             UpdateBonusBoxName(_ui.m_bonusBox1, "" + chapterCfg.bonusStar1);
 
-             UpdateBonusBoxName(_ui.m_bonusBox2, "" + chapterCfg.bonusStar2);
 
-             UpdateBonusBoxName(_ui.m_bonusBox3, "" + chapterCfg.bonusStar3);
 
-             UpdateBonusBox();
 
-             var list = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(chapterCfg.type, chapterCfg.subType, chapterCfg.id);
 
-             int endLevel = 0;
 
-             for (int i = 0; i < list.Count; i++)
 
-             {
 
-                 StoryLevelCfg levelCfg = list[i];
 
-                 GObject obj = _compChapter.GetChild("g" + levelCfg.order);
 
-                 if (obj != null)
 
-                 {
 
-                     UI_CompStoryLevelItem levelItem = UI_CompStoryLevelItem.Proxy(obj);
 
-                     levelItem.target.data = levelCfg.id;
 
-                     if (MainStoryDataManager.CheckLevelUnlock(levelCfg.id))
 
-                     {
 
-                         levelItem.target.visible = true;
 
-                         levelItem.target.onClick.Clear();
 
-                         levelItem.target.onClick.Add(OnClickLevelItem);
 
-                         string showId = StoryUtil.GetChapterOrder(_chapterID) + "_" + levelCfg.order;
 
-                         levelItem.m_txtOrder.text = showId;
 
-                         if (levelCfg.fightID.Length > 0)
 
-                         {
 
-                             levelItem.m_bg.url = "ui://Main/zx_gka_zb_2";
 
-                             int score = InstanceZonesDataManager.GetScoreHighest(levelCfg.id);
 
-                             if (score <= 0)
 
-                             {
 
-                                 levelItem.m_flower.target.visible = false;
 
-                             }
 
-                             else
 
-                             {
 
-                                 levelItem.m_flower.target.visible = true;
 
-                                 int starCount = InstanceZonesDataManager.GetStarCountHistory(levelCfg.id);
 
-                                 StoryUtil.UpdateStar(starCount, levelItem.m_flower.target);
 
-                             }
 
-                         }
 
-                         else
 
-                         {
 
-                             levelItem.m_bg.url = "ui://Main/zx_gka_zb_1";
 
-                             levelItem.m_flower.target.visible = false;
 
-                         }
 
-                         // levelItem.m_iconUnPass.visible = 
 
-                         levelItem.m_holder.visible = !InstanceZonesDataManager.CheckLevelPass(levelCfg.id);
 
-                         // if (levelItem.m_holder.visible)
 
-                         // {
 
-                         // }
 
-                         if (levelItem.m_holder.visible)
 
-                         {
 
-                             //设置为解锁关卡
 
-                             MainStoryDataManager.currentLevelCfgId = levelCfg.id;
 
-                             _unPasslevelItem = levelItem.target;
 
-                             _gameObject = null;
 
-                             _wrapper = null;
 
-                             string resPath = ResPathUtil.GetViewEffectPath("ui_gk", "ui_gk_sg");
 
-                             SceneController.AddObjectToView(_gameObject, _wrapper, levelItem.m_holder, resPath, out _gameObject, out _wrapper);
 
-                         }
 
-                         if (levelCfg.order > endLevel)
 
-                         {
 
-                             endLevel = levelCfg.order;
 
-                             _endLevelItem = levelItem.target;
 
-                         }
 
-                     }
 
-                     else
 
-                     {
 
-                         levelItem.target.visible = false;
 
-                     }
 
-                     UI_CompStoryLevelItem.ProxyEnd();
 
-                 }
 
-             }
 
-             if (_endLevelItem != null)
 
-             {
 
-                 float tx = _endLevelItem.x + _endLevelItem.width / 2;
 
-                 float ty = _endLevelItem.y + _endLevelItem.height / 2;
 
-                 tx = tx - _ui.m_chapter.width / 2;
 
-                 ty = ty - _ui.m_chapter.height / 2;
 
-                 _ui.m_chapter.scrollPane.SetPosX(tx, false);
 
-                 _ui.m_chapter.scrollPane.SetPosY(ty, false);
 
-             }
 
-         }
 
-         private void OnClickLevelItem(EventContext context)
 
-         {
 
-             UI_CompStoryLevelItem levelItem = UI_CompStoryLevelItem.Proxy(context.sender as GObject);
 
-             int levelCfgId = (int)levelItem.target.data;
 
-             UI_CompStoryLevelItem.ProxyEnd();
 
-             StoryController.ShowLevelView(levelCfgId);
 
-             TryCompleteGuide();
 
-         }
 
-         private void UpdateBonusBoxName(UI_CompBonusBox bonusBox, string name)
 
-         {
 
-             bonusBox.m_txtName.text = name;
 
-         }
 
-         private void UpdateBonusBox()
 
-         {
 
-             UpdateBonusBoxStatus(_ui.m_bonusBox1, 0);
 
-             UpdateBonusBoxStatus(_ui.m_bonusBox2, 1);
 
-             UpdateBonusBoxStatus(_ui.m_bonusBox3, 2);
 
-         }
 
-         private void UpdateBonusBoxStatus(UI_CompBonusBox bonusBox, int index)
 
-         {
 
-             int status = MainStoryDataManager.GetChapterBonusStatus(MainStoryDataManager.currentChapterCfgId, index);
 
-             bonusBox.m_iconActive.visible = status == ConstBonusStatus.CAN_GET;
 
-             bonusBox.m_ComRewardEffect.visible = status == ConstBonusStatus.CAN_GET;
 
-             if (status == ConstBonusStatus.GOT)
 
-             {
 
-                 bonusBox.m_icon.url = "ui://Main/zx_gka_baoxiang_2";
 
-             }
 
-             else
 
-             {
 
-                 bonusBox.m_icon.url = "ui://Main/zx_gka_baoxiang_1";
 
-             }
 
-             bonusBox.target.data = status;
 
-         }
 
-         private async void OnClickBonusBox(UI_CompBonusBox bonusBox, int index)
 
-         {
 
-             int status = (int)bonusBox.target.data;
 
-             if (status == ConstBonusStatus.CAN_GET)
 
-             {
 
-                 bool got = await MainStorySProxy.GetMainStoryBoxBonus(MainStoryDataManager.currentChapterCfgId, index);
 
-                 if (got)
 
-                 {
 
-                     List<ItemData> bonusList = MainStoryDataManager.GetChapterBonus(MainStoryDataManager.currentChapterCfgId, index);
 
-                     if (bonusList != null && bonusList.Count > 0)
 
-                     {
 
-                         BonusController.TryShowBonusList(bonusList);
 
-                     }
 
-                     UpdateBonusBoxStatus(bonusBox, index);
 
-                 }
 
-             }
 
-             // else if (status == ConstBonusStatus.GOT)
 
-             // {
 
-             //     PromptController.Instance.ShowFloatTextPrompt("这个宝箱已经被领取过了");
 
-             // }
 
-             else
 
-             {
 
-                 List<ItemData> rewards = StoryBonusDataCache.GetChapterBonusList(_chapterID, index);
 
-                 int star = StoryBonusDataCache.GetChapterBonusStar(_chapterID, index);
 
-                 ViewManager.Show<RewardPreView>(new object[] { rewards, "宝箱奖励", string.Format("本章达成{0}星可领取", star) });
 
-                 // PromptController.Instance.ShowFloatTextPrompt("关卡总分不足,继续加油吧。");
 
-             }
 
-         }
 
-         private void CheckGuide(object param)
 
-         {
 
-             if (GuideDataManager.IsGuideFinish(ConstGuideId.START_FIGHT) <= 0
 
-             || GuideDataManager.IsGuideFinish(ConstGuideId.FREEDOM_DRESS) <= 0
 
-              || GuideDataManager.IsGuideFinish(ConstGuideId.ENTER_CHAPTER) <= 0
 
-             || GuideDataManager.IsGuideFinish(ConstGuideId.BUY_CLOTHING) <= 0
 
-              || GuideDataManager.IsGuideFinish(ConstGuideId.UP_CARD_LV) <= 0
 
-              || GuideDataManager.IsGuideFinish(ConstGuideId.ENTER_CHAPTER_1) <= 0
 
-              || GuideDataManager.IsGuideFinish(ConstGuideId.ENTER_CHAPTER_2) <= 0
 
-              || GuideDataManager.IsGuideFinish(ConstGuideId.ENTER_CHAPTER_3) <= 0
 
-              || GuideDataManager.IsGuideFinish(ConstGuideId.ENTER_CHAPTER_4) <= 0
 
-              || GuideDataManager.IsGuideFinish(ConstGuideId.ENTER_CHAPTER_5) <= 0
 
-              || GuideDataManager.IsGuideFinish(ConstGuideId.UP_CARD_STAR) <= 0
 
-              || GuideDataManager.IsGuideFinish(ConstGuideId.ARENA_OPEN) <= 0
 
-              || GuideDataManager.IsGuideFinish(ConstGuideId.CLOTHING_DECOMPOSE) <= 0)
 
-             {
 
-                 UpdateToCheckGuide(null);
 
-             }
 
-             else
 
-             {
 
-                 Timers.inst.Remove(CheckGuide);
 
-             }
 
-         }
 
-         protected override void UpdateToCheckGuide(object param)
 
-         {
 
-             if (!ViewManager.CheckIsTopView(this.viewCom)) return;
 
-             GComponent unPasslevelCom = _unPasslevelItem == null ? null : _unPasslevelItem.asCom;
 
-             bool isGuide0 = GuideController.TryGuide(unPasslevelCom, ConstGuideId.START_FIGHT, 1, "尝试换上一套衣服吧。");
 
-             bool isGuide1 = GuideController.TryGuide(_ui.m_btnHome, ConstGuideId.FREEDOM_DRESS, 1, "获得的服饰随时可以查看和试穿。");
 
-             bool isGuide2 = GuideController.TryGuide(unPasslevelCom, ConstGuideId.ENTER_CHAPTER, 5, "来继续我们的旅程吧。");
 
-             GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER, 5);
 
-             bool isGuide3 = GuideController.TryGuide(unPasslevelCom, ConstGuideId.ENTER_CHAPTER_1, 4, "来继续我们的旅程吧。");
 
-             GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER_1, 4);
 
-             bool isGuide4 = GuideController.TryGuide(unPasslevelCom, ConstGuideId.BUY_CLOTHING, 1, "衣服被弄脏了,到机场更衣室换身衣服吧。");
 
-             bool isGuide5 = GuideController.TryGuide(_ui.m_btnHome, ConstGuideId.UP_CARD_LV, 1, "点击返回主界面。");
 
-             bool isGuide6 = GuideController.TryGuide(_ui.m_btnHome, ConstGuideId.CLOTHING_DECOMPOSE, 1, "点击返回主界面。");
 
-             bool isGuide7 = GuideController.TryGuide(unPasslevelCom, ConstGuideId.ENTER_CHAPTER_2, 4, "来继续我们的旅程吧。");
 
-             GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER_2, 4);
 
-             bool isGuide8 = GuideController.TryGuide(unPasslevelCom, ConstGuideId.ENTER_CHAPTER_3, 3, "来继续我们的旅程吧。");
 
-             GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER_3, 3);
 
-             bool isGuide10 = GuideController.TryGuide(unPasslevelCom, ConstGuideId.ENTER_CHAPTER_4, 4, "来继续我们的旅程吧。");
 
-             GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER_4, 4);
 
-             bool isGuide11 = GuideController.TryGuide(unPasslevelCom, ConstGuideId.ENTER_CHAPTER_5, 4, "来继续我们的旅程吧。");
 
-             GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER_5, 4);
 
-             bool isGuide9 = GuideController.TryGuide(_ui.m_btnHome, ConstGuideId.UP_CARD_STAR, 1, "点击返回主界面。");
 
-             bool isGuide12 = GuideController.TryGuide(_ui.m_btnHome, ConstGuideId.ARENA_OPEN, 1, "点击返回主界面。");
 
-             _ui.m_chapter.scrollPane.touchEffect = !isGuide0 && !isGuide1 && !isGuide2 && !isGuide3 && !isGuide4 && !isGuide5 && !isGuide6 && !isGuide7 && !isGuide8 && !isGuide9 && !isGuide10;
 
-         }
 
-         protected override void TryCompleteGuide()
 
-         {
 
-             base.TryCompleteGuide();
 
-             // GuideCfg cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.ENTER_CHAPTER);
 
-             GuideController.TryCompleteGuideIndex(ConstGuideId.ENTER_CHAPTER, 5);
 
-             GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER, 5);
 
-             // GuideCfg cfg1 = GuideCfgArray.Instance.GetCfg(ConstGuideId.ENTER_CHAPTER_1);
 
-             GuideController.TryCompleteGuideIndex(ConstGuideId.ENTER_CHAPTER_1, 4);
 
-             GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER_1, 4);
 
-             // GuideCfg cfg2 = GuideCfgArray.Instance.GetCfg(ConstGuideId.ENTER_CHAPTER_2);
 
-             GuideController.TryCompleteGuideIndex(ConstGuideId.ENTER_CHAPTER_2, 4);
 
-             GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER_2, 4);
 
-             // GuideCfg cfg3 = GuideCfgArray.Instance.GetCfg(ConstGuideId.ENTER_CHAPTER_3);
 
-             GuideController.TryCompleteGuideIndex(ConstGuideId.ENTER_CHAPTER_3, 3);
 
-             GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER_3, 3);
 
-             // GuideCfg cfg4 = GuideCfgArray.Instance.GetCfg(ConstGuideId.ENTER_CHAPTER_4);
 
-             GuideController.TryCompleteGuideIndex(ConstGuideId.ENTER_CHAPTER_4, 4);
 
-             GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER_4, 4);
 
-             // GuideCfg cfg5 = GuideCfgArray.Instance.GetCfg(ConstGuideId.ENTER_CHAPTER_5);
 
-             GuideController.TryCompleteGuideIndex(ConstGuideId.ENTER_CHAPTER_5, 4);
 
-             GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER_5, 4);
 
-         }
 
-     }
 
- }
 
 
  |