| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using cfg.GfgCfg;
- using ET;
- using FairyGUI;
- using UI.CommonGame;
- using UI.TimeTracing;
- using UnityEngine;
- namespace GFGGame
- {
- public class TimeTracingLevelView : BaseWindow
- {
- private UI_TimeTracingLevelUI _ui;
- private ValueBarController _valueBarController;
- private int SuitID;
- private int levelId;
- private int _chapterID;
- long num = 0;
- List<CompositebonusCfg> datas;
- public override void Dispose()
- {
- if (_valueBarController != null)
- {
- _valueBarController.Dispose();
- _valueBarController = null;
- }
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_TimeTracingLevelUI.PACKAGE_NAME;
- _ui = UI_TimeTracingLevelUI.Create();
- this.viewCom = _ui.target;
- isfullScreen = true;
- isReturnView = true;
- _ui.m_btnBack.onClick.Add(OnClickBtnBack);
- _ui.m_rankBtn.onClick.Add(OnClickRankBtn);
- _ui.m_suitBg.onClick.Add(OnClickMakeSuitBtn);
- }
- protected override void OnShown()
- {
- base.OnShown();
- if ((this.viewData as object[]) != null)
- {
- _chapterID = (int)(this.viewData as object[])[0];
- SuitID = (int)(this.viewData as object[])[1];
- }
- else
- {
- _chapterID = (int)this.viewData;
- }
- _ui.m_bg.url = ResPathUtil.GetBgImgPath("chahuibg");
- UpdateView();
- UpdateSuitNum();
- UpdateFirst();
- UpdateproBar();
- Timers.inst.AddUpdate(CheckGuide);
- }
- protected override void OnHide()
- {
- _valueBarController.OnHide();
- base.OnHide();
- Timers.inst.Remove(CheckGuide);
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- EventAgent.AddEventListener(ConstMessage.TIMETRACINGREDUPDATE, UpdateView);
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- EventAgent.RemoveEventListener(ConstMessage.TIMETRACINGREDUPDATE, UpdateView);
- }
- private void UpdateView()
- {
- MainStoryDataManager.currentChapterCfgId = _chapterID;
- _valueBarController = new ValueBarController(_ui.m_moneyList);
- _valueBarController.OnShown();
- ActivityFightCfg chapterCfg = CommonDataManager.Tables.TblActivityFightCfg.GetOrDefault(_chapterID);
- var list = CommonDataManager.Tables.TblStoryLevelCfg.DataList
- .Where(a => a.Type == chapterCfg.Type &&
- a.SubType == chapterCfg.SubType &&
- a.ChapterId == chapterCfg.Id).ToList();
- for (int i = 0; i < 5; i++)
- {
- int j = i + 1;
- GObject obj = _ui.target.GetChild("level" + j.ToString());
- StoryLevelCfg levelCfg = i < list.Count ? list[i] : null;
- UI_TimeTracingLevelItem levelItem = UI_TimeTracingLevelItem.Proxy(obj);
- if (i == 0 || InstanceZonesDataManager.CheckLevelPass(levelCfg.Id - 1))
- {
- levelItem.target.data = levelCfg;
- levelItem.target.visible = true;
- levelItem.m_levelName.text = levelCfg.Name;
- Dictionary<int, LevelRoleInfoProto> itemInfo;
- if (TimeTracingDataManager._LevelMaxInfoDic.TryGetValue(_chapterID, out itemInfo))
- {
- if (itemInfo.Count <= i)
- {
- levelItem.m_player.target.visible = false;
- }
- else
- {
- levelItem.m_player.target.visible = true;
- levelItem.m_player.m_name.text = itemInfo[levelCfg.Id].RoleName;
- ItemCfg headCfg =
- CommonDataManager.Tables.TblItemCfg.GetOrDefault(itemInfo[levelCfg.Id].HeadItemId);
- ItemCfg headBorderCfg =
- CommonDataManager.Tables.TblItemCfg.GetOrDefault(itemInfo[levelCfg.Id]
- .HeadBorderItemId);
- levelItem.m_player.m_headFrame.url = ResPathUtil.GetHeadBorderPath(headBorderCfg.Res);
- levelItem.m_player.m_head.url = ResPathUtil.GetHeadPath(headCfg.Res);
- RedDotController.Instance.SetComRedDot(levelItem.target,
- TimeTracingDataManager.Instance.GetLevelRewardStatus(levelCfg.Id), "", -30, 10);
- }
- }
- else
- {
- levelItem.m_player.target.visible = false;
- }
- levelItem.target.onClick.Clear();
- levelItem.target.onClick.Add(OnClickLevelItem);
- }
- else
- {
- levelItem.target.visible = false;
- }
- if (!InstanceZonesDataManager.CheckLevelPass(levelCfg.Id))
- {
- //设置为解锁关卡
- RedDotController.Instance.SetComRedDot(levelItem.target,
- TimeTracingDataManager.Instance.GetLevelRewardStatus(levelCfg.Id), "", -30, 10);
- MainStoryDataManager.currentLevelCfgId = levelCfg.Id;
- levelItem.m_player.target.visible = false;
- }
- UI_TimeTracingLevelItem.ProxyEnd();
- }
- _valueBarController.UpdateList(new List<int>() { ConstItemID.DIAMOND_PURPLE, ConstItemID.DIAMOND_RED });
- }
- private void UpdateSuitNum()
- {
- SuitCfg suitCfg = CommonDataManager.Tables.TblSuitCfg.GetOrDefault(SuitID);
- _ui.m_suitIcon.url = ResPathUtil.GetIconPath(suitCfg.Res, "png");
- int count;
- int totalCount;
- DressUpMenuSuitDataManager.GetSuitProgressBySuitId(SuitID, out count, out totalCount);
- _ui.m_suitNum.text = count + "/" + totalCount;
- }
- private void UpdateFirst()
- {
- if (TimeTracingDataManager.Instance.SuitRankDatasDic[0].Count == 0)
- {
- _ui.m_playerName.text = "";
- _ui.m_headFrame.url = "";
- _ui.m_headIcon.url = "";
- }
- else
- {
- _ui.m_playerName.text = TimeTracingDataManager.Instance.SuitRankDatasDic[0][0].RoleName;
- ItemCfg headCfg =
- CommonDataManager.Tables.TblItemCfg.GetOrDefault(
- TimeTracingDataManager.Instance.SuitRankDatasDic[0][0].HeadItemId);
- ItemCfg headBorderCfg =
- CommonDataManager.Tables.TblItemCfg.GetOrDefault(
- TimeTracingDataManager.Instance.SuitRankDatasDic[0][0].HeadBorderItemId);
- _ui.m_headFrame.url = ResPathUtil.GetHeadBorderPath(headBorderCfg.Res);
- _ui.m_headIcon.url = ResPathUtil.GetHeadPath(headCfg.Res);
- }
- }
- private void UpdateproBar()
- {
- int consumeID = 0;
- datas = CommonDataManager.Tables.TblCompositebonusCfg.DataList.Where(a => a.ChapterId == _chapterID)
- .ToList();
- consumeID = datas[0].Params1[0];
- ItemData item;
- if (BagDataManager.Instance.GetBagData().TryGetValue(consumeID, out item))
- {
- _ui.m_countNum.text = item.num.ToString();
- num = item.num;
- }
- else
- {
- num = 0;
- _ui.m_countNum.text = "0";
- }
- _ui.m_proBar.max = datas[datas.Count - 1].Count;
- _ui.m_proBar.value = num;
- UpdateproBarItem();
- }
- private void UpdateproBarItem()
- {
- for (int i = 0; i < datas.Count; i++)
- {
- GComponent comProBonus = _ui.target.GetChild("barItem" + i).asCom;
- if (i == datas.Count - 1)
- {
- comProBonus.x = ((float)datas[i].Count / (float)datas[datas.Count - 1].Count) * _ui.m_proBar.width -
- 30;
- }
- else
- {
- comProBonus.x = ((float)datas[i].Count / (float)datas[datas.Count - 1].Count) * _ui.m_proBar.width -
- 15;
- }
- UI_proBarItem item = UI_proBarItem.Proxy(comProBonus);
- //if (num >= datas[i].count)
- //{
- // return;
- //}
- //else
- //{
- //}
- item.m_c1.selectedIndex =
- TimeTracingDataManager.Instance.GetChapterRewardIDStatus(datas[i].Id, datas[i].Params1[0]);
- RedDotController.Instance.SetComRedDot(item.target,
- TimeTracingDataManager.Instance.GetChapterRewardIDStatus(datas[i].Id, datas[i].Params1[0]) == 1,
- "", -10, 25);
- ItemCfg itemcfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(datas[i].Bonus[0].ItemId);
- if (itemcfg.ItemType == ConstItemType.HEAD)
- {
- item.m_icon.url = ResPathUtil.GetHeadBorderPath(itemcfg.Res);
- }
- else
- {
- item.m_icon.url = ResPathUtil.GetIconPath(itemcfg.Res, "png");
- }
- item.m_count.text = datas[i].Count.ToString();
- if (item.target.data == null)
- {
- item.target.onClick.Add(OnBtnGetProBonus);
- }
- item.target.data = datas[i];
- UI_proBarItem.ProxyEnd();
- }
- }
- private async void OnBtnGetProBonus(EventContext context)
- {
- GObject obj = context.sender as GObject;
- CompositebonusCfg compositeCfg = obj.data as CompositebonusCfg;
- if (num < compositeCfg.Count ||
- TimeTracingDataManager.Instance.GetChapterRewardIDStatus(compositeCfg.Id, compositeCfg.Params1[0]) !=
- 1)
- {
- GoodsItemTipsController.ShowItemTips(compositeCfg.Bonus[0].ItemId);
- return;
- }
- await TimeTracingSProxy.ReqGetSuitReward(compositeCfg.Id);
- UpdateproBarItem();
- }
- private async void OnClickRankBtn()
- {
- await TimeTracingSProxy.ReqGetSuitFriendRank(SuitID);
- ViewManager.Show<TimeTracingSuitRankView>(new object[] { SuitID });
- }
- private void OnClickMakeSuitBtn()
- {
- ViewManager.Show<ClothingSyntheticView>(new object[] { SuitID, 0, _chapterID }, false, false);
- }
- private void OnClickLevelItem(EventContext context)
- {
- GObject obj = context.sender as GObject;
- StoryLevelCfg storyLevelCfg = (StoryLevelCfg)obj.data;
- MainStoryDataManager.currentLevelCfgId = storyLevelCfg.Id;
- InstanceZonesController.ShowLevelView(storyLevelCfg.Id,
- StudioDataManager.Instance.OnFinishTimeTracingLevel);
- }
- private void OnClickBtnBack()
- {
- ViewManager.GoBackFrom(typeof(TimeTracingLevelView).FullName);
- }
- private void CheckGuide(object param)
- {
- GRoot.inst.touchable = true;
- if (GuideDataManager.IsGuideFinish("TimeTracingShowView") <= 0)
- UpdateCheckGuide(null);
- else
- Timers.inst.Remove(CheckGuide);
- }
- protected void UpdateCheckGuide(object param)
- {
- if (!ViewManager.CheckIsTopView(this.viewCom)) return;
- GuideController.TryGuide(_ui.m_level1.target, "TimeTracingShowView", 5, "挑战。", -1, true, 0, false, false,
- true);
- GuideController.TryGuide(_ui.m_btnBack, "TimeTracingShowView", 6, "返回。", -1, true, 0, false, false, true);
- }
- }
- }
|