using FairyGUI; using UI.Main; using System.Collections.Generic; using UI.CommonGame; using System; 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 _bonusList = new List(); 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); } 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 = StoryLevelCfgArray.Instance.GetCfg(_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); } 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(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, new object[] { 1, _needItemId, _needItemCount }, new object[] { typeof(StoryLevelInfoView).FullName, this.viewData }); this.Hide(); } else { if (RoleDataManager.power < levelCfg.power) { ItemUtil.AddPower("体力不足", OnClickBtnFightOnce); } else { if (levelCfg.type == ConstInstanceZonesType.Studio) { ViewManager.Show(levelCfg.chapterId); } else { PromptController.Instance.ShowFloatTextPrompt("挑战次数不足"); } } } } private void OnClickBtnFightTimes() { //只要按钮显示说明一定可以速刷多次 InstanceZonesDataManager.GetCanFightTime(_type, _storyType, _levelID, out int times, out string title); ViewManager.Show(ViewName.STORY_FIGHT_QUICKLY_VIEW, new object[] { times, _needItemId, _needItemCount }, new object[] { typeof(StoryLevelInfoView).FullName, this.viewData }); this.Hide(); } private void UpdateBonusItem(int index, GObject item) { ItemData itemData = _bonusList[index] as ItemData; UI_ListRewardItem listItem = UI_ListRewardItem.Proxy(item); ItemCfg cfg = ItemCfgArray.Instance.GetCfg(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 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 = 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; ItemUtil.SetItemNeedNum(_ui.m_comCostCurrent, ConstItemID.POWER, levelCfg.power); _ui.m_comCostCurrent.visible = levelCfg.power > 0; // _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 = 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; } else if (levelCfg.type == ConstInstanceZonesType.Studio && levelCfg.subType == ConstInstanceZonesSubType.Hard3) { _ui.m_ctrlNeed.selectedIndex = 3; StudioCfg filingCfg = StudioCfgArray.Instance.GetCfg(StudioDataManager.Instance.filingChapterId); SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(filingCfg.suitId); float addition = StudioDataManager.Instance.GetAdditionBySuitId(filingCfg.suitId); addition = addition / 10000 * 100; _ui.m_txtAddition.text = string.Format("{0}%加成", addition); 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_grpAdditionDesc.visible = false; } } private void RenderListTagItem(int index, GObject obj) { UI_ComTag item = UI_ComTag.Proxy(obj); StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(_levelID); StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID); string tag = fightCfg.needTagsArr[index]; int tagType = TagCfgArray.Instance.GetCfg(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 CheckGuide(object param) { if ( GuideDataManager.IsGuideFinish(ConstGuideId.START_FIGHT) <= 0 || GuideDataManager.IsGuideFinish(ConstGuideId.OPEN_TAGS) <= 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); } protected override void TryCompleteGuide() { GuideCfg cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.CLOTHING_SYNTHETIC); GuideController.TryCompleteGuideIndex(cfg.id, 3); } } }