123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322 |
- using FairyGUI;
- using UI.Main;
- using System.Collections.Generic;
- using UI.CommonGame;
- using System;
- using ET;
- namespace GFGGame
- {
- public class StoryLevelInfoView : BaseWindow
- {
- private UI_StoryLevelInfoUI _ui;
- private int _levelID;
- private int _type;
- private int _storyType;
- private List<ItemData> _bonusList = new List<ItemData>();
- protected override void OnInit()
- {
- base.OnInit();
- _ui = UI_StoryLevelInfoUI.Create();
- this.viewCom = _ui.target;
- this.viewCom.Center();
- this.modal = true;
- viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
- _ui.m_listBonus.itemRenderer = UpdateBonusItem;
- // _ui.m_listBonus.onClickItem.Add(OnClickListBonusItem);
- _ui.m_btnStart.onClick.Add(OnClickBtnStart);
- _ui.m_btnFightOnce.onClick.Add(OnClickBtnFightOnce);
- _ui.m_btnFightTimes.onClick.Add(OnClickBtnFightTimes);
- _ui.m_btnGuide.onClick.Add(this.Hide);
- _ui.m_listTag.itemRenderer = RenderListTagItem;
- }
- protected override void OnShown()
- {
- base.OnShown();
- ViewManager.SetMaskAlpha(0.8f);
- _levelID = (int)viewData;
- StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(_levelID);
- _type = levelCfg.type;
- _storyType = levelCfg.subType;
- _ui.m_btnStart.touchable = true;
- UpdateView();
- EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, UpdateBtnFightTimes);
- }
- protected override void OnHide()
- {
- base.OnHide();
- ViewManager.SetMaskAlpha(0.6f);
- EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateBtnFightTimes);
- }
- private void OnClickBtnStart()
- {
- // int time = InstanceZonesDataManager.GetCanFightTime(_levelID);
- InstanceZonesDataManager.GetCanFightTime(_type, _storyType, _levelID, out int times, out string title);
- if (times > 0)
- {
- ViewManager.Show(ViewName.DRESS_UP_FIGHT_VIEW, _levelID, null, true);
- }
- else
- {
- var levelCfg = StoryLevelCfgArray.Instance.GetCfg(_levelID);
- if (RoleDataManager.power < levelCfg.power)
- {
- ItemUtil.AddPower("体力不足", OnClickBtnStart);
- }
- else
- {
- if (levelCfg.type == ConstInstanceZonesType.Studio)
- {
- ViewManager.Show<StudioBuyNumView>(levelCfg.chapterId);
- }
- else
- {
- PromptController.Instance.ShowFloatTextPrompt("挑战次数不足");
- }
- }
- }
- }
- private void OnClickBtnFightOnce()
- {
- // int time = InstanceZonesDataManager.GetCanFightTime(_levelID);
- int starCount = InstanceZonesDataManager.GetStarCountHistory(_levelID);
- StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(_levelID);
- StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
- if (starCount < fightCfg.quickFightStart)
- {
- PromptController.Instance.ShowFloatTextPrompt("挑战星数不足");
- return;
- }
- InstanceZonesDataManager.GetCanFightTime(_type, _storyType, _levelID, out int times, out string title);
- if (times > 0)
- {
- ViewManager.Show(ViewName.STORY_FIGHT_QUICKLY_VIEW, 1, new object[] { typeof(StoryLevelInfoView).Name, this.viewData });
- this.Hide();
- }
- else
- {
- // var levelCfg = StoryLevelCfgArray.Instance.GetCfg(_levelID);
- if (RoleDataManager.power < levelCfg.power)
- {
- ItemUtil.AddPower("体力不足", OnClickBtnStart);
- }
- else
- {
- if (levelCfg.type == ConstInstanceZonesType.Studio)
- {
- ViewManager.Show<StudioBuyNumView>(levelCfg.chapterId);
- }
- else
- {
- PromptController.Instance.ShowFloatTextPrompt("挑战次数不足");
- }
- }
- }
- }
- private void OnClickBtnFightTimes()
- {
- int starCount = InstanceZonesDataManager.GetStarCountHistory(_levelID);
- StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(_levelID);
- StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
- if (starCount < fightCfg.quickFightStart)
- {
- PromptController.Instance.ShowFloatTextPrompt("挑战星数不足");
- return;
- }
- InstanceZonesDataManager.GetCanFightTime(_type, _storyType, _levelID, out int times, out string title);
- if (_type == ConstInstanceZonesType.Story && _storyType == ConstInstanceZonesSubType.Normal)
- {
- if (times < GameConst.MAX_COUNT_FIGHT_QUICKLY)
- {
- ItemUtil.AddPower("体力不足", OnClickBtnFightTimes);
- }
- else
- {
- ViewManager.Show(ViewName.STORY_FIGHT_QUICKLY_VIEW, times, new object[] { typeof(StoryLevelInfoView).Name, this.viewData });
- this.Hide();
- }
- }
- else
- {
- ViewManager.Show(ViewName.STORY_FIGHT_QUICKLY_VIEW, times, new object[] { typeof(StoryLevelInfoView).Name, this.viewData });
- this.Hide();
- }
- }
- private void UpdateBonusItem(int index, GObject item)
- {
- ItemData itemData = _bonusList[index] as ItemData;
- UI_ComItem listItem = UI_ComItem.Proxy(item);
- if (item.data == null)
- {
- item.data = new ItemView(item as GComponent);
- }
- (item.data as ItemView).SetData(itemData);
- List<ItemData> bonusOnceData = StoryBonusDataCache.GetBonusData(_levelID).bonusOnce;
- (item.data as ItemView).LoaShouTongRewardVisble = !InstanceZonesDataManager.CheckLevelPass(_levelID) && index < bonusOnceData.Count;
- }
- private void UpdateBtnFightTimes()
- {
- if (_ui.m_groupPass.visible)
- {
- InstanceZonesDataManager.GetCanFightTime(_type, _storyType, _levelID, out int times, out string title);
- _ui.m_btnFightTimes.title = title;
- _ui.m_btnFightTimes.visible = times > 0;
- if (_type == ConstInstanceZonesType.Story && _storyType == ConstInstanceZonesSubType.Normal)
- {
- _ui.m_btnFightTimes.visible = true;
- }
- }
- }
- private void UpdateView()
- {
- StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(_levelID);
- StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
- var title = levelCfg.name;
- switch (levelCfg.type)
- {
- case ConstInstanceZonesType.Story:
- title = MainStoryDataManager.CurrentChapterOrder + "-" + InstanceZonesDataManager.currentLevelOrder + " " + levelCfg.name;
- break;
- }
- _ui.m_txtTitle.text = title;
- _ui.m_txtLevelDesc.text = levelCfg.desc;
- _ui.m_txtPowerDesc.SetVar("power", "" + levelCfg.power).FlushVars();
- _ui.m_scoreType.url = "ui://CommonGame/kp_sx_" + fightCfg.scoreType;
- if (fightCfg.targetName != null && fightCfg.targetName.Length > 0)
- {
- _ui.m_txtTargetName.text = "挑战对手·" + fightCfg.targetName;
- _ui.m_loaderHead.url = ResPathUtil.GetNpcHeadPath(fightCfg.targetRes);
- }
- else
- {
- _ui.m_txtTargetName.text = RoleDataManager.roleName;
- _ui.m_loaderHead.url = ResPathUtil.GetNpcHeadPath("self");
- }
- _bonusList.Clear();
- if (InstanceZonesDataManager.CheckLevelPass(_levelID))
- {
- _bonusList = StoryBonusDataCache.GetBonusList(_levelID, false, true);
- _ui.m_groupPass.visible = true;
- _ui.m_groupUnpass.visible = false;
- UpdateBtnFightTimes();
- }
- else
- {
- _bonusList = StoryBonusDataCache.GetBonusList(_levelID, true);
- _ui.m_groupPass.visible = false;
- _ui.m_groupUnpass.visible = true;
- _ui.m_txtUnpassTips.SetVar("count", NumberUtil.GetChiniseNumberText(fightCfg.quickFightStart)).FlushVars();
- }
- _ui.m_listBonus.numItems = _bonusList.Count;
- // if (_ui.m_listBonus.numItems > 4)
- // {
- // _ui.m_listBonus.columnGap = 40;
- // }
- // else
- // {
- // _ui.m_listBonus.columnGap = 60;
- // }
- int score = InstanceZonesDataManager.GetScoreHighest(_levelID);
- if (score > 0)
- {
- string scoreStr = "" + score;
- if (score <= fightCfg.score1)
- {
- scoreStr = "[color=#A28D77]失败 " + scoreStr + "[/color]";
- }
- _ui.m_txtHighestScore.text = scoreStr;
- _ui.m_flower.target.visible = true;
- int starCount = InstanceZonesDataManager.GetStarCountHistory(_levelID);
- StoryUtil.UpdateStar(starCount, _ui.m_flower.target);
- }
- else
- {
- _ui.m_txtHighestScore.text = "--";
- _ui.m_flower.target.visible = false;
- }
- _ui.m_ctrlNeed.selectedIndex = 0;
- if (fightCfg.needItemId != 0)
- {
- _ui.m_ctrlNeed.selectedIndex = 1;
- ItemCfg cfg = ItemCfgArray.Instance.GetCfg(fightCfg.needItemId);
- _ui.m_txtNeed.text = cfg.name;
- }
- else if (fightCfg.needSuitId != 0)
- {
- _ui.m_ctrlNeed.selectedIndex = 1;
- SuitCfg cfg = SuitCfgArray.Instance.GetCfg(fightCfg.needSuitId);
- _ui.m_txtNeed.text = cfg.name;
- }
- else if (fightCfg.needTagsArr.Length > 0)
- {
- _ui.m_ctrlNeed.selectedIndex = 2;
- _ui.m_listTag.numItems = fightCfg.needTagsArr.Length;
- }
- }
- private void RenderListTagItem(int index, GObject obj)
- {
- UI_ListTagItem item = UI_ListTagItem.Proxy(obj);
- StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(_levelID);
- StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
- string[] tag = fightCfg.needTagsArr[index].Split('_');
- item.m_loaTag.url = ResPathUtil.GetCommonGameResPath("fzd_bqbq_" + tag[0]);
- item.m_txtTag.text = tag[1];
- }
- protected override void UpdateToCheckGuide(object param)
- {
- if (!ViewManager.CheckIsTopView(this.viewCom)) return;
- GuideController.TryGuide(_ui.m_btnStart, ConstGuideId.SINGLE_FIGHT, 2, "点击开启换装");
- // if (GuideController.TryGuide(_ui.m_txtNeed, ConstGuideId.CLOTHING_SYNTHETIC, 2, "这次必需品,要通过合成获得"))
- // {
- // _ui.m_btnStart.touchable = false;
- // }
- // GuideController.TryGuide(null, ConstGuideId.CLOTHING_SYNTHETIC, 3, "点击空白处关闭", -1, true, (int)(this.viewCom.y + _ui.m_txtPowerDesc.y), 0, 0, false);
- GuideController.TryGuide(_ui.m_listTag, ConstGuideId.OPEN_TAGS, 1, "选择相应的关卡标签,可提高分数", -1, true, (int)(this.viewCom.y + _ui.m_listBonus.y), 0, 0, false);
- GuideController.TryCompleteGuide(ConstGuideId.OPEN_TAGS, 1);
- GuideController.TryGuide(_ui.m_btnStart, ConstGuideId.BUY_CLOTHING, 2, "");
- }
- protected override void TryCompleteGuide()
- {
- GuideCfg cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.CLOTHING_SYNTHETIC);
- GuideController.TryCompleteGuideIndex(cfg.id, 3);
- }
- }
- }
|