123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- using System;
- using System.Collections.Generic;
- using ET;
- using FairyGUI;
- using UI.CommonGame;
- using UI.ClothingUpgrade;
- using UnityEngine;
- namespace GFGGame
- {
- public class ClothingUpgradeView : BaseWindow
- {
- private UI_ClothingUpgradeUI _ui;
- private int _partIndex;
- private int partIndexCommon;
- private int maxRank;
- private int level;
- private int levelNum;
- private float AddNum;
- private int status = 0;
- private CollegeBoostCfg collegegBoostCfg;
- private CollegeBoostCfg collegeBoostNextCfg;
- private List<GObject> itemList = new List<GObject>();
- private CollectPartData nextPartData = new CollectPartData();
- public override void Dispose()
- {
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_ClothingSelectUI.PACKAGE_NAME;
- _ui = UI_ClothingUpgradeUI.Create();
- this.viewCom = _ui.target;
- isfullScreen = true;
- modal = true;
- _ui.m_btnBack.onClick.Add(OnClickBtnBack);
- _ui.m_upgradeBtn.onClick.Add(OnClickUpgrade);
- _ui.m_levelUpBtn.onClick.Add(OnClickLevelUp);
- }
- protected override void OnShown()
- {
- base.OnShown();
- if (this.viewData != null)
- {
- _partIndex = (int)(this.viewData as object[])[0];
- }
- _ui.m_bg.url = ResPathUtil.GetBgImgPath("gyp_bg");
- InitDate();
- //更新数据
- Update();
- Timers.inst.AddUpdate(CheckGuide);
- }
- protected override void OnHide()
- {
- itemList.Clear();
- base.OnHide();
- Timers.inst.Remove(CheckGuide);
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, Update);
- EventAgent.AddEventListener(ConstMessage.COLLEGE_UPGRADE, Update);
- EventAgent.AddEventListener(ConstMessage.COLLEGE_UPGRADE, LevelUpSuccessTip);
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- EventAgent.RemoveEventListener(ConstMessage.ITEM_CHANGED, Update);
- EventAgent.RemoveEventListener(ConstMessage.COLLEGE_UPGRADE, Update);
- EventAgent.RemoveEventListener(ConstMessage.COLLEGE_UPGRADE, LevelUpSuccessTip);
- }
- private void Update()
- {
- UpdateData();
- UpdateView();
- }
- private void UpdateData()
- {
- level = CollectPartDataManager.Instance.CollectPartDataDic[_partIndex][0];
- levelNum = CollectPartDataManager.Instance.CollectPartDataDic[_partIndex][1];
- if (levelNum > 0)
- {
- //当前数据
- collegegBoostCfg = CollegeBoostCfgArray.Instance.GetCfgBytypePartsAndtypePhaseAndlayer(_partIndex, level, levelNum);
- AddNum = (float)collegegBoostCfg.value / CollectPartDataManager.Instance.AddtitionRatio;
- //下一级数据
- levelNum = CollectPartDataManager.Instance.CollectPartDataDic[_partIndex][1];
- nextPartData.PartID = _partIndex;
- if (levelNum + 1 > CollectPartDataManager.Instance.MaxLevel)
- {
- nextPartData.LevelID = level + 1;
- nextPartData.LevelNum = 1;
- status = 2;
- }
- else
- {
- nextPartData.LevelID = level;
- nextPartData.LevelNum = levelNum + 1;
- status = 1;
- }
- }
- else
- {
- AddNum = 0;
- levelNum = 0;
- nextPartData.PartID = _partIndex;
- nextPartData.LevelID = level;
- nextPartData.LevelNum = levelNum + 1;
- status = 1;
- }
- collegeBoostNextCfg = CollegeBoostCfgArray.Instance.GetCfgBytypePartsAndtypePhaseAndlayer(_partIndex, nextPartData.LevelID, nextPartData.LevelNum);
- if(collegeBoostNextCfg == null || collegeBoostNextCfg.value == 0)
- {
- nextPartData.AddNum = 0;
- status = 3;
- }
- else
- {
- nextPartData.AddNum = (float)collegeBoostNextCfg.value / CollectPartDataManager.Instance.AddtitionRatio;
- }
-
- }
- private void UpdateView()
- {
- _ui.m_c1.selectedIndex = status;
-
- string name = CollegeRankCfgArray.Instance.GetCfgByRankPartsIdAndSecondLevelRank(partIndexCommon, level).gradeName;
- string partName = CollectPartDataManager.Instance.partNameDic[_partIndex];
- _ui.m_desc1Text.text = string.Format("{0}{1}级", name,levelNum);
- _ui.m_desc2.text = string.Format("当 前:{0}", partName);
- _ui.m_desc2Text.text = string.Format("基础属性+{0}%", AddNum.ToString());
- _ui.m_desc3.text = string.Format("下一级:{0}", partName);
- _ui.m_desc3Text.text = string.Format("基础属性+{0}%", nextPartData.AddNum);
- if(status != 3)
- {
- _ui.m_c2.selectedIndex = collegeBoostNextCfg.consumeArr.Length;
- for (int i=0;i< collegeBoostNextCfg.consumeArr.Length;i++)
- {
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(collegeBoostNextCfg.consumeArr[i][0]);
- UI_ComItem item = UI_ComItem.Proxy(itemList[i]);
- item.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
- //item.m_txtCount.SetVar("count", itemData.num.ToString()).FlushVars();
- ItemData itemCount;
- long count;
- if(itemCfg.itemType == ConstItemType.DRESS_UP)
- {
- count = ItemDataManager.GetItemNum(collegeBoostNextCfg.consumeArr[i][0]);
- }
- else
- {
- if (BagDataManager.Instance.GetBagData().TryGetValue(collegeBoostNextCfg.consumeArr[i][0], out itemCount))
- {
- count = itemCount.num;
- }
- else
- {
- count = 0;
- }
- }
- item.m_txtCount.text = count.ToString() + "/" + collegeBoostNextCfg.consumeArr[i][1].ToString();
- item.m_QualityType.selectedIndex = itemCfg.rarity - 1;
- item.m_ShowName.selectedIndex = 1;
- item.m_txtName.text = itemCfg.name;
- if (item.target.data == null)
- {
- item.target.onClick.Add(OnClickListDressUpItem);
- }
- item.target.data = collegeBoostNextCfg.consumeArr[i][0];
- UI_ComItem.ProxyEnd();
- }
- }
- }
- private void InitDate()
- {
- if (_partIndex != 99)
- {
- maxRank = CollectPartDataManager.Instance.MaxNormalRank;
- partIndexCommon = 0;
- }
- else
- {
- maxRank = CollectPartDataManager.Instance.MaxSpecialRank;
- partIndexCommon = _partIndex;
- }
- for (int i = 0; i < 3; i++)
- {
- GObject item = _ui.target.GetChild(string.Format("item{0}", i));
- itemList.Add(item);
- }
- }
- private void OnClickListDressUpItem(EventContext eventContext)
- {
- int id = (int)(eventContext.sender as GObject).data;
- object[] sourceDatas = new object[]
- { id, new object[] { typeof(BagView).FullName, this.viewData } };
- GoodsItemTipsController.ShowItemTips(id, sourceDatas);
- }
- private async void OnClickUpgrade()
- {
- var result = await CollegeSProxy.ReqCollectUpgrade(nextPartData.PartID, nextPartData.LevelID,nextPartData.LevelNum);
- }
- private void LevelUpSuccessTip()
- {
- PromptController.Instance.ShowFloatTextPrompt("升级成功!");
- }
- private void OnClickLevelUp()
- {
- //晋升先到答题界面,全答对了,晋升
- ViewManager.Show<ClothingAnsweringView>( new object[] { _partIndex, nextPartData.LevelID, nextPartData.LevelNum });
- }
- private void OnClickBtnBack()
- {
- ViewManager.GoBackFrom(typeof(ClothingUpgradeView).FullName);
- }
- private void CheckGuide(object param)
- {
- GRoot.inst.touchable = true;
- if (GuideDataManager.IsGuideFinish("ClothingSelectView") <= 0)
- UpdateCheckGuide(null);
- else
- Timers.inst.Remove(CheckGuide);
- }
- protected void UpdateCheckGuide(object param)
- {
- if (!ViewManager.CheckIsTopView(this.viewCom)) return;
- GuideController.TryGuide(null, "ClothingSelectView", 6, "升级部位获得加成。", -1, true, _ui.target.height - 600);
- GuideController.TryCompleteGuide("ClothingSelectView", 6);
- }
- }
- }
|