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.
 
 
 
 
 
 

174 lines
6.1 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using static DungeonMgr;
public class EscrAwakenItem : EScrCell
{
GameObject unlockSet;
GameObject lockSet;
GameObject clearStamp;
GameObject btnTry;
GameObject imgHighlight;
TextMeshProUGUI txtLevel;
TextMeshProUGUI txtCur;
TextMeshProUGUI txtEnter;
TextMeshProUGUI txtUnlockCondition;
public override void InitCell()
{
unlockSet = transform.Find("Unlock").gameObject;
lockSet = transform.Find("Lock").gameObject;
clearStamp = unlockSet.transform.Find("Clear").gameObject;
btnTry = unlockSet.transform.Find("btnChallenge").gameObject;
txtEnter = btnTry.transform.Find("txtEnter").GetComponent<TextMeshProUGUI>();
txtEnter.text = LocalizationText.GetText("all_enter");
imgHighlight = unlockSet.transform.Find("imgCurrent").gameObject;
txtLevel = unlockSet.transform.Find("txtLevel").GetComponent<TextMeshProUGUI>();
txtCur = unlockSet.transform.Find("txtCur").GetComponent<TextMeshProUGUI>();
txtUnlockCondition = lockSet.transform.Find("UnlockCondition").GetComponent<TextMeshProUGUI>();
}
public override void SetData(int itemid)
{
itemID = itemid;
clearStamp.SetActive(true);
btnTry.SetActive(false);
int totalCount;
DungeonKind dungeonKind = DungeonMgr.GetDungeonKind();
if (dungeonKind == DungeonMgr.DungeonKind.AwakenDG)
{
txtLevel.text = FormatString.StringFormat(LocalizationText.GetText("dg_diff"), itemID);
var targetDugeonInfo = DataHandler.GetDungeonTypeInfo(dungeonKind).diffs[itemid - 1];
var battlePower = DataHandler.CalcBattlePower(targetDugeonInfo.monAtk, targetDugeonInfo.monHp);
txtCur.text = FormatString.StringFormat(LocalizationText.GetText("recommand_battlepower"), FormatString.BigIntString1(battlePower));
txtUnlockCondition.text = LocalizationText.GetText("awaken_unlock_dungeon");
totalCount = DataHandler.PlayDgAwaken.lv;
}
else if (dungeonKind == DungeonMgr.DungeonKind.GuardianDG)
{
txtLevel.text = FormatString.StringFormat(LocalizationText.GetText("dg_diff"), itemID);
var targetDugeonInfo = DataHandler.GetDungeonTypeInfo(dungeonKind).diffs[itemid - 1];
var battlePower = DataHandler.CalcBattlePower(targetDugeonInfo.monAtk, targetDugeonInfo.monHp);
txtCur.text = FormatString.StringFormat(LocalizationText.GetText("recommand_battlepower"), FormatString.BigIntString1(battlePower));
txtUnlockCondition.text = FormatString.StringFormat(LocalizationText.GetText("guardian_awaken_lock"), itemID - 1);
totalCount = DataHandler.PlayDgGuardian[GuardianMgr.GetGuardianId()].lv - 1;
if (DataHandler.GetPlayGuardian(GuardianMgr.GetGuardianId()) != null)
{
totalCount += (DataHandler.GetPlayGuardian(GuardianMgr.GetGuardianId()).exp) / DataHandler.GetSysGuardian(GuardianMgr.GetGuardianId()).levels[DataHandler.GetPlayGuardian(GuardianMgr.GetGuardianId()).lv - 1].maxExp;
}
if (totalCount <= 0)
{
totalCount = 1;
}
}
else
{
txtLevel.text = FormatString.StringFormat(LocalizationText.GetText("dg_diff"), itemID);
txtCur.text = FormatString.StringFormat(LocalizationText.GetText("recommand_battlepower"), itemID * 100);
txtUnlockCondition.text = LocalizationText.GetText("awaken_unlock_dungeon");
totalCount = DataHandler.PlayDgAwaken.lv;
}
if (itemID <= totalCount)
{
unlockSet.SetActive(true);
lockSet.SetActive(false);
}
else
{
unlockSet.SetActive(false);
lockSet.SetActive(true);
}
if (itemID == totalCount)
{
clearStamp.SetActive(false);
btnTry.SetActive(true);
if (dungeonKind == DungeonMgr.DungeonKind.GuardianDG)
{
clearStamp.SetActive(true);
btnTry.SetActive(false);
if (DataHandler.GetPlayGuardian(GuardianMgr.GetGuardianId()) != null)
{
if ((DataHandler.GetPlayGuardian(GuardianMgr.GetGuardianId()).exp) / DataHandler.GetSysGuardian(GuardianMgr.GetGuardianId()).levels[DataHandler.GetPlayGuardian(GuardianMgr.GetGuardianId()).lv - 1].maxExp >= 1)
{
clearStamp.SetActive(false);
btnTry.SetActive(true);
}
}
else
{
clearStamp.SetActive(false);
btnTry.SetActive(true);
}
}
}
if (itemID == EnhanceMgr.GetSelected())
{
imgHighlight.SetActive(true);
txtLevel.color = Global.CLR_TextYellow;
}
else
{
imgHighlight.SetActive(false);
txtLevel.color = new Color(1f, 1f, 1f);
}
}
public override void RefreshCellView()
{
base.RefreshCellView();
SetData(itemID);
}
public void OnBtnSelect()
{
EnhanceMgr.SetSelected(itemID);
}
public void OnBtnGoDungeon()
{
if (DungeonMgr.GetDungeonKind() != DungeonMgr.DungeonKind.GuardianDG && BattleMgr.CurrentBattleType == BattleMgr.BattleType.Stage)
{
DungeonMgr.SetDungeonKind(DungeonMgr.DungeonKind.AwakenDG);
}
if (BattleMgr.CurrentBattleType != BattleMgr.BattleType.Stage)
{
GameUIMgr.SOpenToast(LocalizationText.GetText("donot_changedg"));
}
else if (BattleMgr.doNotInterupt)
{
GameUIMgr.SOpenToast(LocalizationText.GetText("donot_interupt"));
}
else if (!EnhanceMgr.GetAutoReroll() && BattleMgr.CurrentBattleType == BattleMgr.BattleType.Stage)
{
DungeonMgr.SPresetSetting();
DungeonMgr.SetDungeonLevel(itemID);
SoundMgr.PlaySfx(SoundName.BtnPress);
}
}
}