123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- 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();
- }
- protected override void OnHide()
- {
- itemList.Clear();
- base.OnHide();
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- EventAgent.AddEventListener(ConstMessage.COLLEGE_UPGRADE, Update);
- EventAgent.AddEventListener(ConstMessage.COLLEGE_UPGRADE, LevelUpSuccessTip);
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- 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(partIndexCommon, 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(partIndexCommon, 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_desc2Text.text = string.Format("当 前:{0}基础属性+{1}%", partName, AddNum.ToString());
- _ui.m_desc3Text.text = string.Format("下一级:{0}基础属性+{1}%", partName, nextPartData.AddNum);
- if(status != 3)
- {
- _ui.m_c2.selectedIndex = collegeBoostNextCfg.consumeArr.Length;
- for (int i=0;i< collegeBoostNextCfg.consumeArr.Length;i++)
- {
- UI_ComItem000 item = UI_ComItem000.Proxy(itemList[i]);
- int id = collegeBoostNextCfg.consumeArr[i][0];
- int count = collegeBoostNextCfg.consumeArr[i][1];
- ItemData itemDate = ItemUtil.createItemData(id, count);
- ItemView itemView = new ItemView(item.target);
- itemView.SetData(itemDate);
- UI_ComItem000.ProxyEnd();
- }
- }
- }
- private void InitDate()
- {
- if (_partIndex != 99)
- {
- maxRank = CollectPartDataManager.Instance.MaxNormalRank;
- partIndexCommon = 0;
- }
- else
- {
- maxRank = CollectPartDataManager.Instance.MaxSpecialRank;
- partIndexCommon = 99;
- }
- for (int i = 0; i < 3; i++)
- {
- GObject item = _ui.target.GetChild(string.Format("item{0}", i));
- itemList.Add(item);
- }
- }
- private async void OnClickUpgrade()
- {
- var result = await CollegeSProxy.ReqCollectUpgrade(nextPartData.PartID, nextPartData.LevelID,nextPartData.LevelNum);
- }
- private void LevelUpSuccessTip()
- {
- string exitTip = "恭喜!升级成功!";
- AlertUI.Show(exitTip)
- .SetLeftButton(false, "取消", (object data) =>
- {
- })
- .SetRightButton(true, "确定", (object data) =>
- {
- });
- }
- private void OnClickLevelUp()
- {
- //晋升先到答题界面,全答对了,晋升
- ViewManager.Show<ClothingAnsweringView>( new object[] { _partIndex, nextPartData.LevelID, nextPartData.LevelNum });
- }
- private void OnClickBtnBack()
- {
- ViewManager.GoBackFrom(typeof(ClothingUpgradeView).FullName);
- }
- }
- }
|