| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443 |
- using FairyGUI;
- using UI.Main;
- using System.Collections.Generic;
- using UI.CommonGame;
- using System;
- using cfg.GfgCfg;
- using ET;
- using UI_ListRewardItem = UI.Main.UI_ListRewardItem;
- using UnityEngine;
- namespace GFGGame
- {
- public class StoryLevelInfoView : BaseWindow
- {
- private const int _quicklyStarCount = 2;//达到2星可快速挑战
- private UI_StoryLevelInfoUI _ui;
- private int _levelID;
- private int _needItemId;
- private int _needItemCount;
- private int _type;
- private int _storyType;
- private List<ItemData> _bonusList = new List<ItemData>();
- public override void Dispose()
- {
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- 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_btnAdditionDesc.onClick.Add(OnBtnAdditionDescClick);
- _ui.m_btnGuide.onClick.Add(this.Hide);
- _ui.m_listTag.itemRenderer = RenderListTagItem;
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, UpdateBtnFightTimes);
- EventAgent.AddEventListener(ConstMessage.NOTICE_LIMIT_CHANGED, UpdateBtnFightTimes);
- }
- protected override void OnShown()
- {
- base.OnShown();
- ViewManager.SetMaskAlpha(0.8f);
- _levelID = (int)(viewData as object[])[0];
- _needItemId = (int)(viewData as object[])[1];
- _needItemCount = (int)(viewData as object[])[2];
- StoryLevelCfg levelCfg = CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(_levelID);
- _type = levelCfg.Type;
- _storyType = levelCfg.SubType;
- _ui.m_btnStart.touchable = true;
- UpdateView();
- Timers.inst.AddUpdate(CheckGuide);
- }
- protected override void OnHide()
- {
- base.OnHide();
- ViewManager.SetMaskAlpha(0.6f);
- Timers.inst.Remove(CheckGuide);
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateBtnFightTimes);
- EventAgent.RemoveEventListener(ConstMessage.NOTICE_LIMIT_CHANGED, UpdateVisitNum);
- EventAgent.RemoveEventListener(ConstMessage.NOTICE_LIMIT_CHANGED, UpdateBtnFightTimes);
- }
- private void OnClickBtnStart()
- {
- // int time = InstanceZonesDataManager.GetCanFightTime(_levelID);
- InstanceZonesDataManager.GetCanFightTime(_type, _storyType, _levelID, out int times, out string title);
- if (times > 0)
- {
- DressUpFightType dressUpFightType = new DressUpFightType();
- dressUpFightType.levelID = _levelID;
- dressUpFightType.teaPartID = 0;
- ViewManager.Show<DressUpFightView>(dressUpFightType,true,false);
- this.Hide();
- }
- else
- {
- var levelCfg = CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(_levelID);
- if (RoleDataManager.power < levelCfg.Power)
- {
- ItemUtil.AddPower(OnClickBtnStart);
- }
- else
- {
- if (levelCfg.Type == ConstInstanceZonesType.Studio && levelCfg.ChapterId != StudioDataManager.Instance.GetLuckyBoxActivityID())
- {
- var studioCfg = CommonDataManager.Tables.TblStudioCfg.GetOrDefault(levelCfg.ChapterId);
- ViewManager.Show<StudioBuyNumView>(studioCfg.Limit);
- }
- else
- {
- PromptController.Instance.ShowFloatTextPrompt("挑战次数不足");
- }
- }
- }
- }
- private void OnClickBtnFightOnce()
- {
- // int time = InstanceZonesDataManager.GetCanFightTime(_levelID);
- int starCount = InstanceZonesDataManager.GetStarCountHistory(_levelID);
- StoryLevelCfg levelCfg = CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(_levelID);
- StoryFightCfg fightCfg = CommonDataManager.Tables.TblStoryFightCfg.GetOrDefault(int.Parse(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<StoryFightQuicklyView>(new object[] { 1, _needItemId, _needItemCount });
- this.Hide();
- }
- else
- {
- if (RoleDataManager.power < levelCfg.Power)
- {
- ItemUtil.AddPower(OnClickBtnFightOnce);
- }
- else
- {
- if (levelCfg.Type == ConstInstanceZonesType.Studio && levelCfg.ChapterId != StudioDataManager.Instance.GetLuckyBoxActivityID())
- {
- var studioCfg = CommonDataManager.Tables.TblStudioCfg.GetOrDefault(levelCfg.ChapterId);
- ViewManager.Show<StudioBuyNumView>(studioCfg.Limit);
- }
- else
- {
- PromptController.Instance.ShowFloatTextPrompt("挑战次数不足");
- }
- }
- }
- }
- private void OnClickBtnFightTimes()
- {
- //只要按钮显示说明一定可以速刷多次
- InstanceZonesDataManager.GetCanFightTime(_type, _storyType, _levelID, out int times, out string title);
- ViewManager.Show<StoryFightQuicklyView>(new object[] { times, _needItemId, _needItemCount });
- this.Hide();
- }
- private void UpdateBonusItem(int index, GObject item)
- {
- ItemData itemData = _bonusList[index] as ItemData;
- UI_ListRewardItem listItem = UI_ListRewardItem.Proxy(item);
- ItemCfg cfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(itemData.id);
- listItem.m_txtName.text = cfg.Name;
- listItem.m_txtOwner.text = string.Format("已拥有:{0}", ItemDataManager.GetItemNum(itemData.id));
- if (item.data == null)
- {
- item.data = new ItemView(listItem.m_comItem as GComponent);
- }
- (item.data as ItemView).SetData(itemData);
- //(item.data as ItemView).ShowTxtCount = false;
- List<ItemData> bonusOnceData = StoryBonusDataCache.GetBonusData(_levelID).bonusOnce;
- (item.data as ItemView).ImgShouTongVisable = !InstanceZonesDataManager.CheckLevelPass(_levelID) && index < bonusOnceData.Count;
- UI_ListRewardItem.ProxyEnd();
- }
- private void UpdateBtnFightTimes()
- {
- InstanceZonesDataManager.GetCanFightTime(_type, _storyType, _levelID, out int times, out string title);
- _ui.m_btnFightTimes.title = title;
- _ui.m_btnFightTimes.visible = times > 1;
- }
- private void UpdateView()
- {
- StoryLevelCfg levelCfg = CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(_levelID);
- StoryFightCfg fightCfg = CommonDataManager.Tables.TblStoryFightCfg.GetOrDefault(int.Parse(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;
- ItemUtil.UpdateItemNeedNum(_ui.m_comCostCurrent, ConstItemID.POWER, levelCfg.Power);
- _ui.m_comCostCurrent.visible = levelCfg.Power > 0;
- //招财进宝活动
- if(levelCfg.SubType == 1 && levelCfg.Type == 6)
- {
- _ui.m_ctrlNeed.selectedIndex = 0;
- EventAgent.AddEventListener(ConstMessage.NOTICE_LIMIT_CHANGED, UpdateVisitNum);
- _ui.m_comCostCurrent.visible = true;
- _ui.m_btnBg.url = "ui://Main/zcjb_zdgktc";
- UI_ComCostCurrency com = UI_ComCostCurrency.Proxy(_ui.m_comCostCurrent);
- com.m_c1.selectedIndex = 2;
- UpdateVisitNum();
- UI_ComCostCurrency.ProxyEnd();
- }
- else if(levelCfg.SubType == 1 && levelCfg.Type == 1)
- {
- _ui.m_ctrlNeed.selectedIndex = 0;
- EventAgent.AddEventListener(ConstMessage.NOTICE_LIMIT_CHANGED, UpdateVisitNum);
- _ui.m_comCostCurrent.visible = true;
- _ui.m_btnBg.url = "ui://Main/zx_jq_dituditu";
- UI_ComCostCurrency com = UI_ComCostCurrency.Proxy(_ui.m_comCostCurrent);
- com.m_c1.selectedIndex = 3;
- UpdateVisitNum();
- UI_ComCostCurrency.ProxyEnd();
- }
- else
- {
- _ui.m_btnBg.url = "ui://Main/zx_jq_dituditu";
- }
- // _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 = InstanceZonesDataManager.GetStarCountHistory(_levelID) >= _quicklyStarCount;
- _ui.m_groupUnpass.visible = InstanceZonesDataManager.GetStarCountHistory(_levelID) < _quicklyStarCount;
- 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 = CommonDataManager.Tables.TblItemCfg.GetOrDefault(fightCfg.NeedItemId);
- _ui.m_txtNeed.text = cfg.Name;
- }
- else if (fightCfg.NeedSuitId != 0)
- {
- _ui.m_ctrlNeed.selectedIndex = 1;
- SuitCfg cfg = CommonDataManager.Tables.TblSuitCfg.GetOrDefault(fightCfg.NeedSuitId);
- _ui.m_txtNeed.text = cfg.Name;
- }
- else if (fightCfg.NeedTags.Count > 0)
- {
- _ui.m_ctrlNeed.selectedIndex = 2;
- _ui.m_listTag.numItems = fightCfg.NeedTags.Count;
- }
- else if ((levelCfg.Type == ConstInstanceZonesType.Studio && levelCfg.SubType == ConstInstanceZonesSubType.Hard3) || levelCfg.Type == ConstInstanceZonesType.PureFight)
- {
- _ui.m_ctrlNeed.selectedIndex = 3;
- _ui.m_grpAdditionDesc.visible = false;
- // 如果是活动界面,不显示收集进度
- if (StudioDataManager.Instance.IsluckyBoxFilingChapter() || levelCfg.Type == ConstInstanceZonesType.PureFight)
- {
- _ui.m_btnAdditionDesc.visible = false;
- }
- else
- {
- StudioCfg filingCfg = CommonDataManager.Tables.TblStudioCfg.GetOrDefault(StudioDataManager.Instance.filingChapterId);
- SuitCfg suitCfg = CommonDataManager.Tables.TblSuitCfg.GetOrDefault(filingCfg.SuitId);
- DressUpMenuSuitDataManager.GetSuitProgressBySuitId(filingCfg.SuitId, out int count, out int totalCount);
- _ui.m_txtAdditionDesc.text = string.Format("{0}套装收集进度:{1}/{2}", suitCfg.Name, count, totalCount);
- _ui.m_btnAdditionDesc.visible = true;
- }
- float addition = 0;
- if (levelCfg.Type == ConstInstanceZonesType.PureFight)
- {
- StudioDataManager.Instance.filingChapterId = levelCfg.ChapterId;
- addition = StudioDataManager.Instance.GetAddition(ConstInstanceZonesType.PureFight);
- }
- else
- addition = StudioDataManager.Instance.GetAddition();
- addition = addition / 10000 * 100;
- _ui.m_txtAddition.text = string.Format("{0}%加成", addition);
- }
- //招财进宝活动
- if (levelCfg.SubType == 1 && levelCfg.Type == 6)
- {
- _ui.m_ctrlNeed.selectedIndex = 0;
- }
- }
- private void RenderListTagItem(int index, GObject obj)
- {
- UI_ComTag item = UI_ComTag.Proxy(obj);
- StoryLevelCfg levelCfg = CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(_levelID);
- StoryFightCfg fightCfg = CommonDataManager.Tables.TblStoryFightCfg.GetOrDefault(int.Parse(levelCfg.FightID));
- string tag = fightCfg.NeedTags[index];
- int tagType = CommonDataManager.Tables.TblTagCfg.GetOrDefault(tag).Type;
- item.m_txtTag.text = tag;
- item.m_loaTag.url = ResPathUtil.GetCommonGameResPath("fzd_bqbq_" + tagType);
- UI_ComTag.ProxyEnd();
- }
- private void OnBtnAdditionDescClick()
- {
- _ui.m_grpAdditionDesc.visible = !_ui.m_grpAdditionDesc.visible;
- }
- //招财进宝活动
- private void UpdateVisitNum()
- {
- UI_ComCostCurrency com = UI_ComCostCurrency.Proxy(_ui.m_comCostCurrent);
- RoleLimitData limitData;
- int limitID;
- if (_type == 1 && _storyType == 1)
- {
- limitData = RoleLimitDataManager.GetLimitData(50);
- limitID = 50;
- }
- else
- {
- limitData = RoleLimitDataManager.GetLimitData( CommonDataManager.Tables.TblActivityFightCfg.GetOrDefault(ActivityDataManager.Instance.activityZCJBId).Limit);
- limitID = CommonDataManager.Tables.TblActivityFightCfg.GetOrDefault(ActivityDataManager.Instance.activityZCJBId).Limit;
- }
- int time = limitData.TotalPlayMax - limitData.PlayTimes;
- com.m_limitNum.text = string.Format("今日免费次数:{0}/{1}", limitData.TotalPlayMax - limitData.PlayTimes, limitData.MaxStorageCount);
- if(com.m_addBtn.data == null)
- {
- com.m_addBtn.onClick.Add(OnClickAddBtn);
- }
- com.m_addBtn.data = limitID;
- UI_ComCostCurrency.ProxyEnd();
- }
- private void OnClickAddBtn(EventContext context)
- {
- // GObject obj, int type
- GObject sender = context.sender as GObject;
- int id = (int)sender.data;
- string name = CommonDataManager.Tables.TblItemCfg.GetOrDefault( CommonDataManager.Tables.TblLimitCfg.GetOrDefault(id).MoneyId).Name;
- string desc = string.Format("是否花费{0}{1}购买{2}次过关次数?", CommonDataManager.Tables.TblLimitCfg.GetOrDefault(id).MoneyNum[0],name, 1);
- ViewManager.Show<ZCJBBuyTipsView>(new object[] { desc, id });
- }
- //******************//
- private void CheckGuide(object param)
- {
- if (
- GuideDataManager.IsGuideFinish(ConstGuideId.START_FIGHT) <= 0
- || GuideDataManager.IsGuideFinish(ConstGuideId.STUDIO_PORCELAIN) <= 0
- || GuideDataManager.IsGuideFinish(ConstGuideId.STUDIO_PROPERTY) <= 0
- || GuideDataManager.IsGuideFinish(ConstGuideId.BUY_CLOTHING) <= 0)
- {
- UpdateToCheckGuide(null);
- }
- else
- {
- Timers.inst.Remove(CheckGuide);
- }
- }
- protected override void UpdateToCheckGuide(object param)
- {
- if (!ViewManager.CheckIsTopView(this.viewCom)) return;
- GuideController.TryGuide(_ui.m_btnStart, ConstGuideId.START_FIGHT, 2, "点击开启换装。");
- GuideController.TryGuide(_ui.m_btnStart, ConstGuideId.BUY_CLOTHING, 2, "");
- // GuideController.TryGuide(_ui.m_listTag, ConstGuideId.OPEN_TAGS, 1, "选择相应的关卡标签,可提高分数。", -1, true, _ui.m_btnStart.LocalToGlobal(Vector2.zero).y + _ui.m_btnStart.height + 400, true);
- // GuideController.TryCompleteGuide(ConstGuideId.OPEN_TAGS, 1);
- GuideController.TryGuide(_ui.m_btnStart, ConstGuideId.STUDIO_PORCELAIN, 6, "");
- GuideController.TryGuide(_ui.m_btnStart, ConstGuideId.STUDIO_PROPERTY, 5, "");
- GuideController.TryGuide(_ui.m_btnStart, ConstGuideId.ENTER_CHAPTER_2, 7, "", -1, true, 0, false, false, true);
- }
- protected override void TryCompleteGuide()
- {
- // GuideCfg cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.CLOTHING_SYNTHETIC);
- //GuideController.TryCompleteGuideIndex(ConstGuideId.CLOTHING_SYNTHETIC, 3);
- GuideController.TryCompleteGuideIndex(ConstGuideId.ENTER_CHAPTER_2, 7);
- GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER_2, 7);
- }
- }
- }
|