You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

310 lines
11 KiB

using TMPro;
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
using IVDataFormat;
using Sirenix.OdinInspector;
using Spine.Unity;
using System.Numerics;
public class EScrLvPointEnchance : EScrCell
{
GameObject unlockSet;
GameObject lockSet;
Image icon;
TextMeshProUGUI txtLevel;
TextMeshProUGUI txtName;
TextMeshProUGUI txtCur;
Button btnLvUp;
GameObject goBtnLvUpObj;
GameObject goBtnLvMax;
TextMeshProUGUI txtMaxLevel;
TextMeshProUGUI txtMaxLevelMax;
TextMeshProUGUI txtPrice;
TextMeshProUGUI unlockConditionText;
ParticleSystem partUpEffect;
int iupgradeMulti = 1;
int iprice;
int inextValue = 0;
int iresetValue = 0;
//int iintervalMaxLv = 100;
bool bClicking = false;
nIdEnhance dataEnhance = null;
[SerializeField] Color effectValueColor = Color.white;
public override void InitCell()
{
unlockSet = transform.Find("Unlock").gameObject;
lockSet = transform.Find("Lock").gameObject;
icon = unlockSet.transform.Find("icon").GetComponent<Image>();
txtLevel = unlockSet.transform.Find("txtLevel").GetComponent<TextMeshProUGUI>();
txtName = unlockSet.transform.Find("txtName").GetComponent<TextMeshProUGUI>();
txtCur = unlockSet.transform.Find("txtCur").GetComponent<TextMeshProUGUI>();
btnLvUp = unlockSet.transform.Find("btnlvup").GetComponent<Button>();
goBtnLvUpObj = unlockSet.transform.Find("btnlvup").gameObject;
goBtnLvMax = unlockSet.transform.Find("btnMaxLv").gameObject;
txtMaxLevel = btnLvUp.transform.Find("txtMaxLevel").GetComponent<TextMeshProUGUI>();
txtMaxLevelMax = goBtnLvMax.transform.Find("txtMaxLevel").GetComponent<TextMeshProUGUI>();
txtPrice = btnLvUp.transform.Find("txtPrice").GetComponent<TextMeshProUGUI>();
unlockConditionText = lockSet.transform.Find("UnlockCondition").GetComponent<TextMeshProUGUI>();
partUpEffect = unlockSet.transform.Find("StrengthenLevel").GetComponent<ParticleSystem>();
}
public override void SetData(int itemid)
{
itemID = itemid;
dCharStat charData = DataHandler.GetCharLvPoint(itemid);
iupgradeMulti = EnhanceMgr.GetMultifulLvPointEnhance();
icon.sprite = AddressableMgr.GetEnhanceIcon(itemid + 5);
int iMaxLv = 100;
int abilityValue = 0;
int abilityValueInc = 1;
BigInteger buyingCnt = 0L;
int buyingCntInc = 1;
int level = 1;
bool isUnlock = false;
iMaxLv = charData.maxLv;
abilityValue = charData.abilityValue;
abilityValueInc = charData.abilityValueInc;
buyingCnt = charData.buyingCount;
buyingCntInc = charData.buyingCntInc;
level = charData.level;
if (charData.level + iupgradeMulti > iMaxLv)
{
iupgradeMulti = iMaxLv - level;
}
iprice = 1;
long icurValue = abilityValue + (abilityValueInc * level);
inextValue = abilityValue + (abilityValueInc * (level + 1));
if (iupgradeMulti > 1)
{
iprice = (1 * iupgradeMulti);
inextValue = abilityValue + (abilityValueInc * (level + iupgradeMulti));
}
iresetValue = abilityValue + (abilityValueInc * level);
txtLevel.text = FormatString.TextLv(charData.level);
txtName.text = LocalizationText.GetText(FormatString.CombineAllString("enhancelvpoint", itemid.ToString()));
#if false
if(charData.abilityType == eEffectType.AtkBase || charData.abilityType == eEffectType.HpBase)
txtCur.text = FormatString.StringFormat("<color=#FFEA73>{0}</color>", FormatString.TextEffectValue(charData.abilityType, icurValue, true, false));
else
txtCur.text = FormatString.StringFormat("<color=#FFEA73>{0}</color>", FormatString.TextEffectValue(charData.abilityType, icurValue, true, true));
#else
if (charData.abilityType == eEffectType.AtkBase || charData.abilityType == eEffectType.HpBase)
txtCur.text = Utility.GetMergeStringWithColor(effectValueColor, FormatString.TextEffectValue(charData.abilityType, icurValue, true, false));
else
txtCur.text = Utility.GetMergeStringWithColor(effectValueColor, FormatString.TextEffectValue(charData.abilityType, icurValue, true, true));
#endif
txtMaxLevel.text = FormatString.CombineAllString("Max Lv.", iMaxLv.ToString());
txtPrice.text = FormatString.TextInt(iprice);
goBtnLvMax.SetActive(false);
goBtnLvUpObj.SetActive(true);
btnLvUp.interactable = iprice <= DataHandler.Goods.point;
if(charData.level >= charData.maxLv)
{
//txtCur.text = FormatString.StringFormat("{0} <color=#FFEA73>{1}</color>", LocalizationText.GetText(FormatString.StringFormat("enhancelvpoint{0}", itemid)), icurValue);
txtPrice.text = "Max";
goBtnLvUpObj.SetActive(false);
goBtnLvMax.SetActive(true);
txtMaxLevelMax.text = FormatString.CombineAllString("Max Lv.", charData.maxLv.ToString());
}
if (DataHandler.PlayData.playerLv >= charData.condValue)
{
if (isUnlock == false)
{
unlockSet.SetActive(true);
lockSet.SetActive(false);
BuffMgr.Instance.ChangeCharLvPoint(DataHandler.GetCharLvPoint(itemID).abilityType, abilityValue + (abilityValueInc * level), true);
isUnlock = true;
}
}
else
{
UnlockConditionDescPlayerLevel(charData.condValue);
unlockSet.SetActive(false);
lockSet.SetActive(true);
}
}
void UnlockConditionDesc(eEffectType unlockType, int unlockLevel)
{
string sampleText = "???";
switch (unlockType)
{
case eEffectType.None:
break;
case eEffectType.AtkBase:
sampleText = LocalizationText.GetText("enhancelvpoint1");
break;
case eEffectType.HpBase:
sampleText = LocalizationText.GetText("enhancelvpoint2");
break;
case eEffectType.Mov:
sampleText = LocalizationText.GetText("enhancelvpoint4");
break;
case eEffectType.Spd:
sampleText = LocalizationText.GetText("enhancelvpoint5");
break;
case eEffectType.GoldDropRate:
sampleText = LocalizationText.GetText("enhancelvpoint6");
break;
case eEffectType.ExpDropRate:
sampleText = LocalizationText.GetText("enhancelvpoint7");
break;
case eEffectType.ChestDropRate:
sampleText = LocalizationText.GetText("enhancelvpoint8");
break;
default:
break;
}
sampleText += FormatString.StringFormat(LocalizationText.GetText("enhance_unlock_condition"), unlockLevel.ToString());
unlockConditionText.text = sampleText;
}
void UnlockConditionDescPlayerLevel(int unlockLevel)
{
string sampleText = LocalizationText.GetText("unlock_player_lv");
sampleText += FormatString.StringFormat(LocalizationText.GetText("enhance_unlock_condition"), unlockLevel.ToString());
unlockConditionText.text = sampleText;
}
public override void RefreshCellView()
{
base.RefreshCellView();
SetData(itemID);
}
//public void OnBtnLvUp()
//{
// dataEnhance = new nIdEnhance(itemID, DataHandler.GetCharLvPoint(itemID).level);
//
// dataEnhance.aftLv += iupgradeMulti;
// dataEnhance.tryCount += iupgradeMulti;
// dataEnhance.useGoods += iprice;//이 정보를 아래쪽 포스트 요청에 보내서 서버에 적용한다. 맨 끝에서 두번째에 있다.
//
//}
public void OnBtnLvPointDown()
{
if (bClicking)
return;
if (EnhanceMgr.IsILoadingSetOne())
{
return;
}
if(iprice <= DataHandler.Goods.point)
{
bClicking = true;
dataEnhance = new nIdEnhance(itemID, DataHandler.GetCharLvPoint(itemID).level);
StartCoroutine("CPointLevelUp");
}
else
{
EnhanceMgr.MinusILoading();
}
}
int delayTimer = 0;
private IEnumerator CPointLevelUp()
{
int imaxlv = DataHandler.GetCharLvPoint(itemID).maxLv;
if (iprice > DataHandler.Goods.point || dataEnhance.aftLv >= imaxlv)
{
OnBtnLvPointUp();
yield break;
}
//upEffect.AnimationState.SetAnimation(0, "idle", false);
partUpEffect.Play();
dataEnhance.aftLv += iupgradeMulti;
dataEnhance.tryCount += iupgradeMulti;
dataEnhance.useGoods += iprice;//이 정보를 아래쪽 포스트 요청에 보내서 서버에 적용한다. 맨 끝에서 두번째에 있다.
DataHandler.SubLvPoint(iprice);
EnhanceMgr.SLevelUpCharPointServer(itemID, iupgradeMulti, iprice, inextValue);
//asLvUp.Play();
SoundMgr.PlaySfx(SoundName.BtnPress, SoundName.ReinforceSuccess);
EnhanceMgr.CheckBedge();
RefreshCellView();
while (bClicking)
{
if (delayTimer > 3)
{
//int iprice = (dataEnhance.aftLv - 1) * gear.buyingCountInc + gear.buyingCount;
if (iprice > DataHandler.Goods.point || dataEnhance.aftLv >= imaxlv)
{
OnBtnLvPointUp();
yield break;
}
//upEffect.AnimationState.SetAnimation(0, "idle", false);
partUpEffect.Play();
dataEnhance.aftLv += iupgradeMulti;
dataEnhance.tryCount += iupgradeMulti;
dataEnhance.useGoods += iprice;//이 정보를 아래쪽 포스트 요청에 보내서 서버에 적용한다. 맨 끝에서 두번째에 있다.
DataHandler.SubLvPoint(iprice);
EnhanceMgr.SLevelUpCharPointServer(itemID, iupgradeMulti, iprice, inextValue);
//asLvUp.Play();
SoundMgr.PlaySfx(SoundName.BtnPress, SoundName.ReinforceSuccess);
EnhanceMgr.CheckBedge();
RefreshCellView();
}
else
{
delayTimer++;
}
yield return YieldInstructionCache.WaitForSeconds(0.1f);
}
}
public void OnBtnLvPointUp()
{
if (!bClicking)
return;
//CoverCamera.Hold();
delayTimer = 0;
StopCoroutine("CPointLevelUp");
bClicking = false;
EnhanceMgr.TrySVPointEnhance(dataEnhance);
}
}