123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- using FairyGUI;
- using System.Collections;
- using System.Collections.Generic;
- using ET;
- using UI.FieldWork;
- using UI.CommonGame;
- using UnityEngine;
- namespace GFGGame
- {
- public class FieldWorkLevelView : BaseWindow
- {
- private UI_FieldWorkLevelUI _ui;
- private CimbingTowerLevelCfg[] LevelList;
- private GameObject gamey;
- private float indexY;
- private EffectUI _effectUI1;
- private GComponent objGuide;
- public override void Dispose()
- {
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- if (_effectUI1 != null)
- {
- EffectUIPool.Recycle(_effectUI1);
- _effectUI1 = null;
- }
- base.Dispose();
- }
- protected override void Init()
- {
- base.Init();
- packageName = UI_FieldWorkLevelUI.PACKAGE_NAME;
- _ui = UI_FieldWorkLevelUI.Create();
- viewCom = _ui.target;
- isfullScreen = true;
- isReturnView = true;
- _ui.m_BtnBack.onClick.Add(OnClickBtnBack);
- _ui.m_shopBtn.target.onClick.Add(OnClickBtnShop);
- _ui.m_resetBtn.target.onClick.Add(OnClickBtnReSet);
- _ui.m_passBtn.target.onClick.Add(OnClickBtnSkip);
- _ui.m_listTag.itemRenderer = RenderListTagItem;
- _ui.m_ruleBtn.onClick.Add(RuleController.ShowRuleView);
- _ui.m_ruleBtn.data = 300035;
- _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_bgEffect, "ui_zj", "Tydc_All/Tydc_All");
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- EventAgent.AddEventListener(ConstMessage.FieldWork_STARTCHANGE, StartCalculateScore);
- EventAgent.AddEventListener(ConstMessage.FieldWork_StateCHANGE, UpdateLevel);
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- EventAgent.RemoveEventListener(ConstMessage.FieldWork_STARTCHANGE, StartCalculateScore);
- EventAgent.RemoveEventListener(ConstMessage.FieldWork_StateCHANGE, UpdateLevel);
- }
- protected override void OnShown()
- {
- base.OnShown();
- gamey = GameObject.Find("Stage/GRoot/Window - FieldWorkLevelUI/ContentPane/CompChapter/Container/Container");
- objGuide = _ui.m_chapter.m_compChapterScroll.target.GetChild("g0").asCom;
- _ui.m_Bg.url = ResPathUtil.GetBgImgPath("bg_tydc");
- _ui.m_shopBtn.target.visible = false;
- LevelList = CimbingTowerLevelCfgArray.Instance.dataArray;
- _ui.m_listTag.numItems = FieldWorkDataManager.Instance.Tag.Count;
- UpdateLevel();
- Timers.inst.AddUpdate(CheckGuide);
- }
- private IEnumerator InitChapter()
- {
- yield return new WaitForSeconds(0.1f);
- if (gamey != null)
- {
- //gamey.transform.position = new Vector3(0, indexY, 0);
- }
- }
- private void UpdateLevel()
- {
- for (int i = 0; i < LevelList.Length; i++)
- {
- GObject obj = _ui.m_chapter.m_compChapterScroll.target.GetChild("g" + i);
- UI_CompStoryLevelItem levelItem = UI_CompStoryLevelItem.Proxy(obj);
- if(i == LevelList.Length-1)
- {
- levelItem.m_c1.selectedIndex = 2;
- }
- CimbingTowerLevelCfg levelCfg = LevelList[i];
- if(FieldWorkDataManager.Instance.CheckLevelPass(levelCfg.id) || i == 0)
- {
- levelItem.m_lock.visible = false;
- }
- else
- {
- levelItem.m_lock.visible = true;
- }
- levelItem.target.visible = true;
- levelItem.m_txtFightOrder.text = levelCfg.name;
- levelItem.m_levelIcon.text = FieldWorkDataManager.Instance.nameList[i];
- levelItem.target.data = levelCfg.id;
- levelItem.target.onClick.Add(OnClickLevelItem);
- UI_CompStoryLevelItem.ProxyEnd();
- }
- //Timers.inst.StartCoroutine(InitChapter());
- int isPassCount = 0;
- foreach(var item in FieldWorkDataManager.Instance.CimbingTowerLevelInfoList)
- {
- if(item.Value.IsPass)
- {
- isPassCount++;
- }
- }
- int levelCount = CimbingTowerLevelCfgArray.Instance.dataArray.Length - isPassCount;
- float height = _ui.m_chapter.target.height;
- float value = 300 / (_ui.m_chapter.target.height / 1080.0f);
- indexY = value * Mathf.Max(0, (float)levelCount);
- _ui.m_chapter.target.scrollPane.posY = indexY;
- }
- private void OnClickLevelItem(EventContext context)
- {
- UI_CompStoryLevelItem levelItem = UI_CompStoryLevelItem.Proxy(context.sender as GObject);
- int levelCfgId = (int)levelItem.target.data;
- if(levelItem.m_lock.visible)
- {
- PromptController.Instance.ShowFloatTextPrompt("请通过前置关卡");
- return;
- }
- else
- {
- if(FieldWorkDataManager.Instance.CimbingTowerLevelInfoList.ContainsKey(levelCfgId))
- {
- if(FieldWorkDataManager.Instance.CimbingTowerLevelInfoList[levelCfgId].IsPass)
- {
- PromptController.Instance.ShowFloatTextPrompt("关卡已通过!");
- return;
- }
- }
- }
- UI_CompStoryLevelItem.ProxyEnd();
- ViewManager.Show<FieldWorkLevelInfoView>(new object[] { levelCfgId });
- }
- private void RenderListTagItem(int index, GObject obj)
- {
- UI_ComTag item = UI_ComTag.Proxy(obj);
- string tag = FieldWorkDataManager.Instance.Tag[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();
- }
- protected override void OnHide()
- {
- base.OnHide();
- GRoot.inst.touchable = true;
- }
- private void StartCalculateScore()
- {
- ViewManager.Show<StoryFightSingleView>(null, true);
- ViewManager.DeleteViewStackCountDown(null, 1);
- }
- private void OnClickBtnBack()
- {
- ViewManager.GoBackFrom(typeof(FieldWorkLevelView).FullName);
- }
- private void OnClickBtnShop()
- {
- ViewManager.Show<StoreView>(new object[] { ConstStoreTabId.STORE_EXCHANGE, 3 });
- }
- private void OnClickBtnReSet()
- {
- if (GuideDataManager.IsGuideFinish(ConstGuideId.FIELD) <= 0)
- {
- return;
- }
- if (FieldWorkDataManager.Instance.CimbingTowerLevelInfoList.Count == 0)
- {
- PromptController.Instance.ShowFloatTextPrompt("本周暂未参与该玩法,无法使用此功能!");
- return;
- }
- AlertUI.Show("重置后当前关卡进度将被清空,每周可使用一次,是否重置?")
- .SetLeftButton(true, "否").SetRightButton(true, "是", async (object data) =>
- {
- bool result = await FieldWorkSproxy.ReqFieldWorkReset();
- if (result)
- {
- UpdateLevel();
- PromptController.Instance.ShowFloatTextPrompt("重置成功!");
- }
- else
- {
- //PromptController.Instance.ShowFloatTextPrompt("没有重置次数!");
- }
- });
- }
- private void OnClickBtnSkip()
- {
- int normal = CimbingTowerCfgArray.Instance.dataArray[0].ClearanceLimit;
- int vip = CimbingTowerCfgArray.Instance.dataArray[0].VipClearanceLimit;
- if (RoleDataManager.CheckIsMonthCardOpenByType(1) || RoleDataManager.CheckIsMonthCardOpenByType(1))
- {
- int isPassCount = 0;
- foreach (var item in FieldWorkDataManager.Instance.CimbingTowerLevelInfoList)
- {
- if (item.Value.IsPass)
- {
- isPassCount++;
- }
- }
- if (isPassCount >= FieldWorkDataManager.Instance.MaxLevelId)
- {
- PromptController.Instance.ShowFloatTextPrompt("通关数量已超过最大可通关数量!");
- return;
- }
- }
- else
- {
- if(FieldWorkDataManager.Instance.MaxLevelId != 0)
- {
- AlertUI.Show("一键通关不消耗服装和词牌的使用次数,每周可使用一次,是否快速通关?")
- .SetLeftButton(true, "否").SetRightButton(true, "是", async (object data) =>
- {
- bool result = await FieldWorkSproxy.ReqFieldWorkOneClickPass();
- if (result)
- {
- UpdateLevel();
- PromptController.Instance.ShowFloatTextPrompt("跳过成功!");
- }
- });
- }
- else
- {
- PromptController.Instance.ShowFloatTextPrompt("暂未满足通关要求,无法使用此功能!");
- }
- }
- }
- private void CheckGuide(object param)
- {
- if (GuideDataManager.IsGuideFinish(ConstGuideId.FIELD) <= 0)
- {
- UpdateToCheckGuide(null);
- }
- else
- {
- Timers.inst.Remove(CheckGuide);
- }
- }
- protected override void UpdateToCheckGuide(object param)
- {
- if (!ViewManager.CheckIsTopView(this.viewCom)) return;
- GuideController.TryGuide(_ui.m_listTag, ConstGuideId.FIELD, 2, "每周主题标签将会获得额外的属性加成!");
- GuideController.TryGuide(objGuide, ConstGuideId.FIELD, 3, "点击开始挑战!");
- GuideController.TryGuide(_ui.m_resetBtn.target, ConstGuideId.FIELD, 16, "每周一5:00可以获得一次重置的机会,若遇到困难时可以考虑重置后再试试哦!", -1, true, _ui.target.height - 600);
- GuideController.TryCompleteGuide(ConstGuideId.FIELD, 16);
- }
- }
- }
|