639 lines
22 KiB
C#
639 lines
22 KiB
C#
using cfg.ActorCfg;
|
|
using cfg.VihecleCultivateCfg;
|
|
using Framework;
|
|
using Gameplay.Net;
|
|
using System.Collections.Generic;
|
|
using Gameplay;
|
|
using PhxhSDK;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using Utils;
|
|
using Button = UnityEngine.UI.Button;
|
|
using DataVehicleUpgradeBonus = cfg.VihecleCultivateCfg.DataVehicleUpgradeBonus;
|
|
using Image = UnityEngine.UI.Image;
|
|
|
|
|
|
public class UI_VehicleLevelUpController : UIWindow
|
|
{
|
|
//UI GameObj
|
|
///Auto Gen Start///
|
|
public Image Image_BG;
|
|
public Button Button_Back;
|
|
public TMP_Text Text_Back;
|
|
public Button Button_Home;
|
|
public Image Image_Intensity;
|
|
public TMP_Text Text_IntensityLv;
|
|
public TMP_Text Text_Before;
|
|
public Image Image_Triangle;
|
|
public TMP_Text Text_After;
|
|
public Image Image_InfoBG;
|
|
public Image Image_HP;
|
|
public TMP_Text Text_HP;
|
|
public TMP_Text Text_HP_Up;
|
|
public Image Image_YellowBar_Hp;
|
|
public Image Image_YellowBar02_Hp;
|
|
public TMP_Text Text_HP_Value;
|
|
public Button Button_Plus_Hp;
|
|
public Button Button_Minus_Hp;
|
|
public Image Image_Minus_Hp;
|
|
public Image Image_MinusDark_Hp;
|
|
public Image Image_Plus_Hp;
|
|
public Image Image_PlusDark_Hp;
|
|
public Image Image_Attack;
|
|
public TMP_Text Text_Attack;
|
|
public TMP_Text Text_Attack_Up;
|
|
public Image Image_YellowBar_Attack;
|
|
public Image Image_YellowBar02_Attack;
|
|
public TMP_Text Text_Attack_Value;
|
|
public Button Button_Minus_Attack;
|
|
public Button Button_Plus_Attack;
|
|
public Image Image_Minus_Attack;
|
|
public Image Image_MinusDark_Attack;
|
|
public Image Image_Plus_Attack;
|
|
public Image Image_PlusDark_Attack;
|
|
public Image Image_Defance;
|
|
public TMP_Text Text_Defance;
|
|
public TMP_Text Text_Defance_Up;
|
|
public Image Image_YellowBar_Denfence;
|
|
public Image Image_YellowBar02_Denfence;
|
|
public TMP_Text Text_Defance_Value;
|
|
public Image Image_Minus_Denfence;
|
|
public Image Image_MinusDark_Denfence;
|
|
public Image Image_Plus_Denfence;
|
|
public Image Image_PlusDark_Denfence;
|
|
public Button Button_Minus_Denfence;
|
|
public Button Button_Plus_Denfence;
|
|
public Button Button_Reset;
|
|
public Image Image_IntensityLV;
|
|
public TMP_Text Text_Level;
|
|
public TMP_Text Text_Info;
|
|
public TMP_Text Text_Unlock;
|
|
|
|
public Image Image_VehiclePoster;
|
|
public Button Button_Cannot;
|
|
public TMP_Text Text_Cannot_Confirm;
|
|
public Button Button_Confirm;
|
|
public TMP_Text Text_Confirm;
|
|
public Button Button_Cancel;
|
|
public Image Image_Red;
|
|
public Image Image_Green02;
|
|
|
|
///Auto Gen End///
|
|
|
|
|
|
private VehicleCultivateData mVehicleData;
|
|
private VehicleCultivateData mNextVehicleData;
|
|
|
|
private int hpLvUpTime;
|
|
private int attackLvUpTime;
|
|
private int defenseLvUpTime;
|
|
|
|
private PhxhScrollView mCurScrollView;
|
|
private List<DataVehicleUpgradeBonus> mBonusTabList;
|
|
|
|
Dictionary<GameObject, DataVehicleUpgradeBonus> mUIBonusDic ;
|
|
|
|
private VehicleUpgrade mVehicleLvUpTab;
|
|
private const int Material_count= 3;
|
|
|
|
// Use this for initialization
|
|
public override void OnAwake()
|
|
{
|
|
//bind UI GameObj
|
|
UI_VehicleLevelUpBinder.GetComponents(this);
|
|
ResetData();
|
|
mBonusTabList = new List<DataVehicleUpgradeBonus>();
|
|
mCurScrollView = GetComponent<PhxhScrollView>("Image_BG/Image_InfoBG/ScrollView");
|
|
mUIBonusDic= new Dictionary<GameObject, DataVehicleUpgradeBonus>();
|
|
mVehicleLvUpTab = TableManager.Instance.Tables.VehicleUpgrade;
|
|
|
|
BindButton(Button_Reset, ResetClick);
|
|
BindButton(Button_Cancel, ResetClick);
|
|
BindButton(Button_Confirm, OnButtonConfirmClick);
|
|
BindButton(Button_Plus_Hp, OnButton_Plus_HpClick);
|
|
BindButton(Button_Minus_Hp, OnButton_Minus_HpClick);
|
|
BindButton(Button_Plus_Denfence, OnButton_Plus_DenfenceClick);
|
|
BindButton(Button_Minus_Denfence, OnButton_Minus_DenfenceClick);
|
|
BindButton(Button_Plus_Attack, OnButton_Plus_AttackClick);
|
|
BindButton(Button_Minus_Attack, OnButton_Minus_AttackClick);
|
|
BindButton(Button_Back, OnButton_CancelClick);
|
|
BindButton(Button_Home, OnClickHome);
|
|
}
|
|
private void OnClickHome()
|
|
{
|
|
UIManager.Instance.CloseAllNormalExcept(UINameConst.UI_MainPanel);
|
|
}
|
|
private void ResetData()
|
|
{
|
|
hpLvUpTime = 0;
|
|
attackLvUpTime = 0;
|
|
defenseLvUpTime = 0;
|
|
}
|
|
private void GetBonusTabList()
|
|
{
|
|
mBonusTabList.Clear();
|
|
VehicleUpgradeBonusAttri bonusTab = TableManager.Instance.Tables.VehicleUpgradeBonusAttri;
|
|
for (int i = 0; i < bonusTab.DataList.Count; i++)
|
|
{
|
|
if (bonusTab.DataList[i].ID==mVehicleData.Cfg.ID)
|
|
{
|
|
mBonusTabList.Add(bonusTab.DataList[i]);
|
|
}
|
|
}
|
|
}
|
|
private void RefreshBtn()
|
|
{
|
|
RefreshAttackBtn();
|
|
RefreshDefenseBtn();
|
|
RefreshHpBtn();
|
|
}
|
|
private void OnButton_CancelClick()
|
|
{
|
|
CloseWindow();
|
|
}
|
|
private void RegisterEvent()
|
|
{
|
|
EventManager.Instance.Register(EventManager.EventName.VehecleUpgrade, OnVehecleUpgradeClick);
|
|
}
|
|
|
|
private void UnRegisterEvent()
|
|
{
|
|
EventManager.Instance.Unregister(EventManager.EventName.VehecleUpgrade, OnVehecleUpgradeClick);
|
|
}
|
|
|
|
private void OnVehecleUpgradeClick()
|
|
{
|
|
mVehicleData = VehicleCultivateDataManager.GetSingleton().GetVehicleCultivateData(mVehicleData.nID);
|
|
ResetData();
|
|
RefreshNextVehicleData(mVehicleData.UpgradeCount);
|
|
RefreshLevelAbout();
|
|
RefreshMaterial();
|
|
mCurScrollView.UpdateData(true);
|
|
RefreshBtn();
|
|
}
|
|
|
|
private void OnButton_Minus_AttackClick()
|
|
{
|
|
if(attackLvUpTime<=0)
|
|
{
|
|
UITipsManager.ShowTips(CommonUtils.GetLocalizeText("vehicleCultivate_AttackLevelminTip"));
|
|
return;
|
|
}
|
|
attackLvUpTime--;
|
|
RefreshNowAttack();
|
|
RefreshAttackBtn();
|
|
RefreshMaterial();
|
|
RefreshLevel();
|
|
}
|
|
private void RefreshAttackBtn()
|
|
{
|
|
Image_MinusDark_Attack.gameObject.SetActive(attackLvUpTime <= 0);
|
|
Image_Minus_Attack.gameObject.SetActive(attackLvUpTime > 0);
|
|
Image_PlusDark_Attack.gameObject.SetActive(IsPowMaxAttack());
|
|
Image_Plus_Attack.gameObject.SetActive(!IsPowMaxAttack());
|
|
}
|
|
private void RefreshHpBtn()
|
|
{
|
|
Image_MinusDark_Hp.gameObject.SetActive(hpLvUpTime <= 0);
|
|
Image_Minus_Hp.gameObject.SetActive(hpLvUpTime > 0);
|
|
Image_PlusDark_Hp.gameObject.SetActive(IsPowMaxHp());
|
|
Image_Plus_Hp.gameObject.SetActive(!IsPowMaxHp());
|
|
}
|
|
private void RefreshDefenseBtn()
|
|
{
|
|
Image_MinusDark_Denfence.gameObject.SetActive(defenseLvUpTime <= 0);
|
|
Image_Minus_Denfence.gameObject.SetActive(defenseLvUpTime > 0);
|
|
Image_PlusDark_Denfence.gameObject.SetActive(IsPowMaxDefense());
|
|
Image_Plus_Denfence.gameObject.SetActive(!IsPowMaxDefense());
|
|
}
|
|
|
|
public bool IsPowMaxAttack()
|
|
{
|
|
DataVehicleUpgrade dataVehicleUpgrade = mVehicleLvUpTab.Get((int)mVehicleData.nID, cfg.ActorCfg.VihecleUpgradeType.Damage);
|
|
|
|
return (attackLvUpTime + mVehicleData.UpgradeCount[(int)cfg.ActorCfg.VihecleUpgradeType.Damage]) >= dataVehicleUpgrade.MaxCount;
|
|
|
|
}
|
|
public bool IsPowMaxHp()
|
|
{
|
|
DataVehicleUpgrade dataVehicleUpgrade = mVehicleLvUpTab.Get((int)mVehicleData.nID, cfg.ActorCfg.VihecleUpgradeType.HP);
|
|
|
|
return (hpLvUpTime + mVehicleData.UpgradeCount[(int)cfg.ActorCfg.VihecleUpgradeType.HP]) >= dataVehicleUpgrade.MaxCount;
|
|
|
|
}
|
|
public bool IsPowMaxDefense()
|
|
{
|
|
DataVehicleUpgrade dataVehicleUpgrade = mVehicleLvUpTab.Get((int)mVehicleData.nID, cfg.ActorCfg.VihecleUpgradeType.Defense);
|
|
|
|
return (defenseLvUpTime + mVehicleData.UpgradeCount[(int)cfg.ActorCfg.VihecleUpgradeType.Defense]) >= dataVehicleUpgrade.MaxCount;
|
|
|
|
}
|
|
private void OnButton_Plus_AttackClick()
|
|
{
|
|
if (IsPowMaxAttack())
|
|
{
|
|
UITipsManager.ShowTips(CommonUtils.GetLocalizeText("vehicleCultivate_AttackLevelmaxTip"));
|
|
return;
|
|
}
|
|
attackLvUpTime++;
|
|
RefreshNowAttack();
|
|
RefreshAttackBtn();
|
|
RefreshMaterial();
|
|
}
|
|
|
|
private void OnButton_Minus_DenfenceClick()
|
|
{
|
|
if (defenseLvUpTime<=0)
|
|
{
|
|
UITipsManager.ShowTips(CommonUtils.GetLocalizeText("vehicleCultivate_DefenseLevelminTip"));
|
|
return;
|
|
}
|
|
defenseLvUpTime--;
|
|
RefreshNowDenfense();
|
|
RefreshDefenseBtn();
|
|
RefreshMaterial();
|
|
RefreshLevel();
|
|
}
|
|
|
|
private void OnButton_Plus_DenfenceClick()
|
|
{
|
|
if (IsPowMaxDefense())
|
|
{
|
|
UITipsManager.ShowTips(CommonUtils.GetLocalizeText("vehicleCultivate_DefenseLevelminTip"));
|
|
return;
|
|
}
|
|
defenseLvUpTime++;
|
|
RefreshNowDenfense();
|
|
RefreshDefenseBtn();
|
|
RefreshMaterial();
|
|
RefreshLevel();
|
|
|
|
}
|
|
|
|
private void OnButton_Minus_HpClick()
|
|
{
|
|
if (hpLvUpTime <= 0)
|
|
{
|
|
UITipsManager.ShowTips(CommonUtils.GetLocalizeText("vehicleCultivate_hpLevelminTip"));
|
|
return;
|
|
}
|
|
hpLvUpTime--;
|
|
RefreshNowHp();
|
|
RefreshHpBtn();
|
|
RefreshMaterial();
|
|
RefreshLevel();
|
|
|
|
}
|
|
|
|
private void OnButton_Plus_HpClick()
|
|
{
|
|
if (IsPowMaxHp())
|
|
{
|
|
UITipsManager.ShowTips(CommonUtils.GetLocalizeText("vehicleCultivate_hpLevelmaxTip"));
|
|
return;
|
|
}
|
|
hpLvUpTime++;
|
|
RefreshNowHp();
|
|
RefreshHpBtn();
|
|
RefreshMaterial();
|
|
RefreshLevel();
|
|
|
|
}
|
|
|
|
private void ResetClick()
|
|
{
|
|
hpLvUpTime = 0;
|
|
attackLvUpTime = 0;
|
|
defenseLvUpTime = 0;
|
|
RefreshDefenseBtn();
|
|
RefreshHpBtn();
|
|
RefreshAttackBtn();
|
|
RefreshNowHp();
|
|
RefreshNowAttack();
|
|
RefreshNowDenfense();
|
|
RefreshMaterialCount();
|
|
|
|
}
|
|
|
|
private void OnButtonConfirmClick()
|
|
{
|
|
List<uint> utype = new List<uint>();
|
|
List<uint> uCount = new List<uint>();
|
|
|
|
if (hpLvUpTime != 0)
|
|
{
|
|
utype.Add((uint)cfg.ActorCfg.VihecleUpgradeType.HP);
|
|
uCount.Add((uint)hpLvUpTime);
|
|
DebugUtil.Log("cfg.ActorCfg.VihecleUpgradeType.HP " + hpLvUpTime+" 原 " + mVehicleData.UpgradeCount[(int)cfg.ActorCfg.VihecleUpgradeType.HP] );
|
|
}
|
|
if (attackLvUpTime != 0)
|
|
{
|
|
utype.Add((uint)cfg.ActorCfg.VihecleUpgradeType.Damage);
|
|
uCount.Add((uint)attackLvUpTime);
|
|
DebugUtil.Log("cfg.ActorCfg.VihecleUpgradeType.Damage " + attackLvUpTime + " 原 " + mVehicleData.UpgradeCount[(int)cfg.ActorCfg.VihecleUpgradeType.Damage]);
|
|
|
|
}
|
|
if (defenseLvUpTime != 0)
|
|
{
|
|
utype.Add((uint)cfg.ActorCfg.VihecleUpgradeType.Defense);
|
|
uCount.Add((uint)defenseLvUpTime);
|
|
DebugUtil.Log("cfg.ActorCfg.VihecleUpgradeType.denfense " + defenseLvUpTime + " 原 " + mVehicleData.UpgradeCount[(int)cfg.ActorCfg.VihecleUpgradeType.Defense]);
|
|
|
|
}
|
|
if((hpLvUpTime+attackLvUpTime+defenseLvUpTime)!=0)
|
|
{
|
|
NetHelper.VehicleUpgrade((uint)mVehicleData.Cfg.ID, utype.ToArray(), uCount.ToArray());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//invoke when open window
|
|
protected override void OnOpenWindow(object data )
|
|
{
|
|
mVehicleData=data as VehicleCultivateData;
|
|
GetBonusTabList();
|
|
|
|
RefreshNextVehicleData(mVehicleData.UpgradeCount);
|
|
RefreshLevelAbout();
|
|
RefreshMaterial();
|
|
SetScrollView();
|
|
RegisterEvent();
|
|
RefreshBtn();
|
|
CommonUtils.SetImageBlur(GetComponent<Image>("blurObj"));
|
|
|
|
|
|
}
|
|
void RefreshLevel()
|
|
{
|
|
Text_Before.text = mVehicleData.SumPowerLevel().ToString();
|
|
Text_After.text = (mNextVehicleData.SumPowerLevel()+hpLvUpTime+attackLvUpTime+defenseLvUpTime).ToString();
|
|
}
|
|
void RefreshLevelAbout()
|
|
{
|
|
RefreshLevel();
|
|
RefreshNowAttack();
|
|
RefreshNowDenfense();
|
|
RefreshNowHp();
|
|
}
|
|
void RefreshNextVehicleData(ushort[]upgrade)
|
|
{
|
|
mNextVehicleData= new VehicleCultivateData(mVehicleData.nID,upgrade);
|
|
}
|
|
void RefreshNowHp()
|
|
{
|
|
float powerUpAmout = VehicleUpgradeTableHelper.Get((int)mVehicleData.Cfg.ID, cfg.ActorCfg.VihecleUpgradeType.HP).PowerUpAmount;
|
|
float addedValue = powerUpAmout * hpLvUpTime;
|
|
int nowHp = mVehicleData.Hp();
|
|
Image_YellowBar02_Hp.fillAmount = (float)nowHp / (float)mVehicleData.GetMaxHp();
|
|
Image_YellowBar_Hp.fillAmount = (float)(nowHp+addedValue) / (float)mVehicleData.GetMaxHp();
|
|
Text_HP_Value.text = (float)(mVehicleData.Hp()+addedValue) + "/" + (float)mVehicleData.GetMaxHp();
|
|
|
|
if(addedValue==0)
|
|
{
|
|
Text_HP_Up.text = "" ;
|
|
}
|
|
else
|
|
{
|
|
Text_HP_Up.text = "+" + addedValue;
|
|
}
|
|
int maxCount = VehicleUpgradeTableHelper.Get((int)mVehicleData.nID, cfg.ActorCfg.VihecleUpgradeType.HP).MaxCount;
|
|
|
|
|
|
|
|
}
|
|
void RefreshNowAttack()
|
|
{
|
|
float powerUpAmout = VehicleUpgradeTableHelper.Get((int)mVehicleData.Cfg.ID, cfg.ActorCfg.VihecleUpgradeType.Damage).PowerUpAmount;
|
|
float addedValue = powerUpAmout * attackLvUpTime;
|
|
int nowAttack = mVehicleData.Attack();
|
|
Image_YellowBar02_Attack.fillAmount = (float)nowAttack / (float)mVehicleData.GetMaxAttack();
|
|
Image_YellowBar_Attack.fillAmount = (float)(nowAttack + addedValue) / (float)mVehicleData.GetMaxAttack();
|
|
Text_Attack_Value.text = (float)(mVehicleData.Attack()+addedValue) + "/" + (float)mVehicleData.GetMaxAttack();
|
|
|
|
if (addedValue == 0)
|
|
{
|
|
Text_Attack_Up.text = "";
|
|
}
|
|
else
|
|
{
|
|
Text_Attack_Up.text = "+" + addedValue;
|
|
}
|
|
int maxCount = VehicleUpgradeTableHelper.Get((int)mVehicleData.nID, cfg.ActorCfg.VihecleUpgradeType.Damage).MaxCount;
|
|
|
|
}
|
|
void RefreshNowDenfense()
|
|
{
|
|
float powerUpAmout = VehicleUpgradeTableHelper.Get((int)mVehicleData.Cfg.ID, cfg.ActorCfg.VihecleUpgradeType.Defense).PowerUpAmount;
|
|
float addedValue = powerUpAmout *defenseLvUpTime;
|
|
int nowDefense = mVehicleData.Defense();
|
|
Image_YellowBar02_Denfence.fillAmount = (float)nowDefense / (float)mVehicleData.GetMaxDenfense();
|
|
Image_YellowBar_Denfence.fillAmount = (float)(nowDefense + addedValue) / (float)mVehicleData.GetMaxDenfense();
|
|
Text_Defance_Value.text = (float)(mVehicleData.Defense()+addedValue) + "/" + (float)mVehicleData.GetMaxDenfense();
|
|
|
|
if (addedValue == 0)
|
|
{
|
|
Text_Defance_Up.text = "";
|
|
}
|
|
else
|
|
{
|
|
Text_Defance_Up.text = "+" + addedValue;
|
|
}
|
|
int maxCount = VehicleUpgradeTableHelper.Get((int)mVehicleData.nID, cfg.ActorCfg.VihecleUpgradeType.Defense).MaxCount;
|
|
|
|
|
|
|
|
}
|
|
|
|
void RefreshMaterial()
|
|
{
|
|
if (IsMaxLevel())
|
|
{
|
|
FindObj("Image_BG/UI_Materals").SetActive(false);
|
|
}
|
|
else
|
|
{
|
|
FindObj("Image_BG/UI_Materals").SetActive(true);
|
|
List<cfg.item.ItemCounts>costItems= new List<cfg.item.ItemCounts>();
|
|
GetSumCostItem(ref costItems);
|
|
for (int i = 0; i < Material_count; i++)
|
|
{
|
|
GameObject itemParent = FindObj(string.Format("Image_BG/UI_Materals/{0}", (i + 1).ToString()));
|
|
CommonUtils.DestoryAllChildGameObject(CommonUtils.GetGameObject(itemParent, "item"));
|
|
|
|
if ((i + 1) <= costItems.Count)
|
|
{
|
|
itemParent.SetActive(true);
|
|
|
|
ItemObj itemObj = new ItemObj(costItems[i].Id, CommonUtils.GetGameObject(itemParent, "item"));
|
|
CommonUtils.GetComponent<TMP_Text>(itemParent, "value").text = Actor.Instance.Item.GetItemCount(costItems[i].Id) + "/" + costItems[i].Count;
|
|
bool isFUll = Actor.Instance.Item.GetItemCount(costItems[i].Id) >= costItems[i].Count;
|
|
CommonUtils.GetGameObject(itemParent, "Image_Red").SetActive(!isFUll);
|
|
CommonUtils.GetGameObject(itemParent, "Image_Green02").SetActive(isFUll);
|
|
|
|
}
|
|
else
|
|
{
|
|
itemParent.SetActive(false);
|
|
}
|
|
}
|
|
LayoutRebuilder.ForceRebuildLayoutImmediate((FindObj("Image_BG/UI_Materals").transform as RectTransform));
|
|
|
|
}
|
|
}
|
|
void RefreshMaterialCount()
|
|
{
|
|
if (IsMaxLevel())
|
|
{
|
|
FindObj("Image_BG/UI_Materals").SetActive(false);
|
|
}
|
|
else
|
|
{
|
|
FindObj("Image_BG/UI_Materals").SetActive(true);
|
|
List<cfg.item.ItemCounts> costItems = new List<cfg.item.ItemCounts>();
|
|
GetSumCostItem(ref costItems);
|
|
for (int i = 0; i < Material_count; i++)
|
|
{
|
|
GameObject itemParent = FindObj(string.Format("Image_BG/UI_Materals/{0}", (i + 1).ToString()));
|
|
CommonUtils.DestoryAllChildGameObject(CommonUtils.GetGameObject(itemParent, "item"));
|
|
|
|
if ((i + 1) <= costItems.Count)
|
|
{
|
|
itemParent.SetActive(true);
|
|
|
|
CommonUtils.GetComponent<TMP_Text>(itemParent, "value").text = Actor.Instance.Item.GetItemCount(costItems[i].Id) + "/" + costItems[i].Count;
|
|
bool isFUll = Actor.Instance.Item.GetItemCount(costItems[i].Id) >= costItems[i].Count;
|
|
CommonUtils.GetGameObject(itemParent, "Image_Red").SetActive(!isFUll);
|
|
CommonUtils.GetGameObject(itemParent, "Image_Green02").SetActive(isFUll);
|
|
|
|
}
|
|
else
|
|
{
|
|
itemParent.SetActive(false);
|
|
}
|
|
}
|
|
LayoutRebuilder.ForceRebuildLayoutImmediate((FindObj("Image_BG/UI_Materals").transform as RectTransform));
|
|
|
|
}
|
|
|
|
}
|
|
private void GetSumCostItem(ref List<cfg.item.ItemCounts> costItems)
|
|
{
|
|
//加生命升级材料
|
|
DataVehicleUpgrade dataVehicleUpgrade = VehicleUpgradeTableHelper.Get(mVehicleData.Cfg.ID, VihecleUpgradeType.HP);
|
|
for (int i = 0; i < dataVehicleUpgrade.CostItems.Count;i++)
|
|
{
|
|
CommonUtils.AddItem(ref costItems,CommonUtils.ItemXNumber(dataVehicleUpgrade.CostItems[i],hpLvUpTime));
|
|
}
|
|
//加伤害升级材料
|
|
DataVehicleUpgrade dataVehicleUpgradeDamege = VehicleUpgradeTableHelper.Get(mVehicleData.Cfg.ID, VihecleUpgradeType.Damage);
|
|
|
|
for (int i = 0; i < dataVehicleUpgrade.CostItems.Count; i++)
|
|
{
|
|
CommonUtils.AddItem(ref costItems, CommonUtils.ItemXNumber(dataVehicleUpgradeDamege.CostItems[i], attackLvUpTime));
|
|
}
|
|
|
|
//加防御力升级材料
|
|
DataVehicleUpgrade dataVehicleUpgradeDamegeDenfense = VehicleUpgradeTableHelper.Get(mVehicleData.Cfg.ID, VihecleUpgradeType.Defense);
|
|
|
|
for (int i = 0; i < dataVehicleUpgrade.CostItems.Count; i++)
|
|
{
|
|
CommonUtils.AddItem(ref costItems, CommonUtils.ItemXNumber(dataVehicleUpgradeDamege.CostItems[i],defenseLvUpTime));
|
|
}
|
|
}
|
|
|
|
private bool IsMaxLevel()
|
|
{
|
|
return mVehicleData.SumPowerLevel() >= mVehicleData.SumPowerMaxLevel();
|
|
}
|
|
|
|
void SetScrollView()
|
|
{
|
|
mCurScrollView.SetUpdateFunc(RefreshItem);
|
|
mCurScrollView.SetItemCountFunc(GetCountFunc);
|
|
mCurScrollView.UpdateData(false);
|
|
mCurScrollView.SetButton(SetScrollviewItemButton);
|
|
}
|
|
|
|
private void SetScrollviewItemButton(GameObject item)
|
|
{
|
|
|
|
}
|
|
|
|
private int GetCountFunc()
|
|
{
|
|
return mBonusTabList.Count;
|
|
}
|
|
|
|
private void RefreshItem(int index, RectTransform item)
|
|
{
|
|
DataVehicleUpgradeBonus tempDataInfo = mBonusTabList[index];
|
|
|
|
GameObject unlockObj = CommonUtils.GetGameObject(item.gameObject, "1/Text_Unlock");
|
|
TMP_Text intensifyText = CommonUtils.GetComponent<TMP_Text>(item.gameObject, "1/Text_Level");
|
|
TMP_Text descText = CommonUtils.GetComponent<TMP_Text>(item.gameObject, "1/Text_Level");
|
|
GameObject triObj = CommonUtils.GetGameObject(item.gameObject, "1/Text_Info/Image_Triangle");
|
|
CommonUtils.GetComponent<TMP_Text>(item.gameObject,"1/Text_Info").text = CommonUtils.GetVehicleBonusStr(tempDataInfo.BonusType) + "+" + tempDataInfo.BonusPropertyCount; ;
|
|
Color unLiveCol = new Color(1, 1, 1, (float)150 / (float)255);
|
|
Color LiveCol = new Color((float)250/(float)255, 1, 0, (float)155 / (float)255);
|
|
intensifyText.text =string.Format( CommonUtils.GetLocalizeText("vehicleCultivate_levelstr"),tempDataInfo.SumCount);
|
|
descText.text = CommonUtils.GetVehicleBonusStr(tempDataInfo.BonusType)+tempDataInfo.BonusPropertyCount;
|
|
|
|
Image parentImg = CommonUtils.GetComponent<Image>(item.gameObject,"1");
|
|
int nextLv = GetNextLv();
|
|
if (mVehicleData.SumPowerLevel()>tempDataInfo.SumCount)
|
|
{
|
|
unlockObj.SetActive(false);
|
|
intensifyText.color = unLiveCol;
|
|
descText.color = unLiveCol;
|
|
triObj.SetActive(false);
|
|
parentImg.color = new Color(1, 1, 1, 1);
|
|
}else if(tempDataInfo.SumCount==nextLv)
|
|
{
|
|
unlockObj.SetActive(true);
|
|
intensifyText.color = LiveCol;
|
|
descText.color = LiveCol;
|
|
triObj.SetActive(true);
|
|
parentImg.color = new Color(1, 1, 1, 1);
|
|
|
|
}
|
|
else
|
|
{
|
|
unlockObj.SetActive(false);
|
|
intensifyText.color = unLiveCol;
|
|
descText.color = unLiveCol;
|
|
triObj.SetActive(false);
|
|
parentImg.color = new Color(1, 1, 1, ((float)50/(float)255));
|
|
|
|
}
|
|
mUIBonusDic[item.gameObject] = tempDataInfo;
|
|
|
|
}
|
|
private int GetNextLv()
|
|
{
|
|
for (int i = 0; i < mBonusTabList.Count; i++)
|
|
{
|
|
if (mBonusTabList[i].SumCount>mVehicleData.SumPowerLevel())
|
|
{
|
|
return mBonusTabList[i].SumCount;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
//invoke when reload window
|
|
protected override void OnReloadWindow(object data = null)
|
|
{
|
|
|
|
}
|
|
|
|
//invoke when close window
|
|
protected override void OnCloseWindow()
|
|
{
|
|
ResetData();
|
|
UnRegisterEvent();
|
|
EventManager.Instance.Send(EventManager.EventName.EN_UIControllCultivateMainInput, true);
|
|
|
|
}
|
|
} |