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.
285 lines
8.2 KiB
285 lines
8.2 KiB
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
using System;
|
|
using IVDataFormat;
|
|
using System.Numerics;
|
|
using System.Collections.Generic;
|
|
using Spine;
|
|
|
|
public class EscrDungeonLevel : EScrCell, IOnRecieveIntent
|
|
{
|
|
[SerializeField] GraphicsColorSetter levelTxtColorSetter;
|
|
|
|
GameObject unlockSet;
|
|
GameObject lockSet;
|
|
GameObject clearStamp;
|
|
ButtonIV btnTry;
|
|
Image imgTicket;
|
|
|
|
GameObject imgHighlight;
|
|
|
|
TextMeshProUGUI txtLevel;
|
|
TextMeshProUGUI txtCur;
|
|
|
|
GameModData gModData;
|
|
Action<uint> setDataHandler;
|
|
Func<uint, IList<nGoods>> getRewards;
|
|
|
|
public void OnRecieveIntent(object intent)
|
|
{
|
|
gModData = null;
|
|
setDataHandler = null;
|
|
getRewards = null;
|
|
|
|
if (intent is DeepCaveDungeonData deepCaveData)
|
|
{
|
|
gModData = deepCaveData;
|
|
setDataHandler = SetWithDeepCaveDungeon;
|
|
getRewards = deepCaveData.GetRewardList;
|
|
}
|
|
else if (intent is AtlantisDungeonData atlantisData)
|
|
{
|
|
gModData = atlantisData;
|
|
setDataHandler = SetWithAtlantisDungeon;
|
|
getRewards = atlantisData.GetRewardList;
|
|
}
|
|
else if (intent is ProtectTheMerchantDgData ptmData)
|
|
{
|
|
gModData = ptmData;
|
|
setDataHandler = SetWithProtectTheMerchantDg;
|
|
getRewards = ptmData.GetRewardList;
|
|
}
|
|
else if (intent is DevelopTheJungleDgData dtjData)
|
|
{
|
|
gModData = dtjData;
|
|
setDataHandler = SetWithDevelopTheJungelDg;
|
|
getRewards = dtjData.GetRewardList;
|
|
}
|
|
else if (intent is HuntEagleDgData huntEagleData)
|
|
{
|
|
gModData = huntEagleData;
|
|
setDataHandler = SetWithHuntEagleDg;
|
|
getRewards = huntEagleData.GetRewardList;
|
|
}
|
|
}
|
|
|
|
private void SetWithDeepCaveDungeon(uint level)
|
|
{
|
|
var deepCaveDg = gModData as DeepCaveDungeonData;
|
|
|
|
if (level <= deepCaveDg.Level)
|
|
{
|
|
bool isClear = deepCaveDg.IsClear(level);
|
|
|
|
clearStamp.SetActive(isClear);
|
|
SetLockState(false);
|
|
|
|
btnTry.gameObject.SetActive(!isClear);
|
|
btnTry.interactable = deepCaveDg.EnterTicketCount > 0;
|
|
|
|
SetLevelText(level);
|
|
SetBattlePowerText(deepCaveDg.GetRecommendBattlePower(level));
|
|
|
|
imgTicket.sprite = AddressableMgr.GetIcon((int)deepCaveDg.EnterCostItem.ID, (int)deepCaveDg.EnterCostItem.SubID);
|
|
|
|
SetToSelected(level == DungeonMgr.Instance.GetSelectDgLv());
|
|
}
|
|
else
|
|
{
|
|
clearStamp.SetActive(false);
|
|
SetLockState(true);
|
|
btnTry.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
private void SetWithAtlantisDungeon(uint level)
|
|
{
|
|
var atlasDg = gModData as AtlantisDungeonData;
|
|
|
|
if (level <= atlasDg.Level)
|
|
{
|
|
bool isClear = atlasDg.IsClear(level);
|
|
|
|
clearStamp.SetActive(isClear);
|
|
SetLockState(false);
|
|
|
|
btnTry.gameObject.SetActive(!isClear);
|
|
btnTry.interactable = atlasDg.EnterTicketCount > 0;
|
|
|
|
SetLevelText(level);
|
|
SetBattlePowerText(atlasDg.GetRecommendBattlePower(level));
|
|
|
|
imgTicket.sprite = AddressableMgr.GetIcon((int)atlasDg.EnterCostItem.ID, (int)atlasDg.EnterCostItem.SubID);
|
|
|
|
SetToSelected(level == DungeonMgr.Instance.GetSelectDgLv());
|
|
}
|
|
else
|
|
{
|
|
clearStamp.SetActive(false);
|
|
SetLockState(true);
|
|
btnTry.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
private void SetWithProtectTheMerchantDg(uint level)
|
|
{
|
|
var ptmMode = gModData as ProtectTheMerchantDgData;
|
|
|
|
if (level <= ptmMode.Level)
|
|
{
|
|
bool isClear = ptmMode.IsClear(level);
|
|
|
|
clearStamp.SetActive(isClear);
|
|
SetLockState(false);
|
|
|
|
btnTry.gameObject.SetActive(!isClear);
|
|
btnTry.interactable = ptmMode.EnterTicketCount > 0;
|
|
|
|
SetLevelText(level);
|
|
SetBattlePowerText(ptmMode.GetRecommendBattlePower(level));
|
|
|
|
imgTicket.sprite = AddressableMgr.GetIcon((int)ptmMode.EnterCostItem.ID, (int)ptmMode.EnterCostItem.SubID);
|
|
|
|
SetToSelected(level == DungeonMgr.Instance.GetSelectDgLv());
|
|
}
|
|
else
|
|
{
|
|
clearStamp.SetActive(false);
|
|
SetLockState(true);
|
|
btnTry.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
private void SetWithDevelopTheJungelDg(uint level)
|
|
{
|
|
var dtjMode = gModData as DevelopTheJungleDgData;
|
|
|
|
if (level <= dtjMode.Level)
|
|
{
|
|
bool isClear = dtjMode.IsClear(level);
|
|
|
|
clearStamp.SetActive(isClear);
|
|
SetLockState(false);
|
|
|
|
btnTry.gameObject.SetActive(!isClear);
|
|
btnTry.interactable = dtjMode.EnterTicketCount > 0;
|
|
|
|
SetLevelText(level);
|
|
SetBattlePowerText(dtjMode.GetRecommendBattlePower(level));
|
|
|
|
imgTicket.sprite = AddressableMgr.GetIcon((int)dtjMode.EnterCostItem.ID, (int)dtjMode.EnterCostItem.SubID);
|
|
|
|
SetToSelected(level == DungeonMgr.Instance.GetSelectDgLv());
|
|
}
|
|
else
|
|
{
|
|
clearStamp.SetActive(false);
|
|
SetLockState(true);
|
|
btnTry.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
private void SetWithHuntEagleDg(uint level)
|
|
{
|
|
var huntEagle = gModData as HuntEagleDgData;
|
|
|
|
if (level <= huntEagle.Level)
|
|
{
|
|
bool isClear = huntEagle.IsClear(level);
|
|
|
|
clearStamp.SetActive(isClear);
|
|
SetLockState(false);
|
|
|
|
btnTry.gameObject.SetActive(!isClear);
|
|
btnTry.interactable = huntEagle.EnterTicketCount > 0;
|
|
|
|
SetLevelText(level);
|
|
SetBattlePowerText(huntEagle.GetRecommendBattlePower(level));
|
|
|
|
imgTicket.sprite = AddressableMgr.GetIcon((int)huntEagle.EnterCostItem.ID, (int)huntEagle.EnterCostItem.SubID);
|
|
|
|
SetToSelected(level == DungeonMgr.Instance.GetSelectDgLv());
|
|
}
|
|
else
|
|
{
|
|
clearStamp.SetActive(false);
|
|
SetLockState(true);
|
|
btnTry.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
private void SetLockState(bool isLock)
|
|
{
|
|
lockSet.SetActive(isLock);
|
|
unlockSet.SetActive(!isLock);
|
|
}
|
|
|
|
private void SetLevelText(uint level)
|
|
{
|
|
txtLevel.text = FormatString.StringFormat(LocalizationText.GetText("dg_diff"), level);
|
|
}
|
|
|
|
private void SetBattlePowerText(BigInteger battlePower)
|
|
{
|
|
txtCur.text = FormatString.StringFormat(LocalizationText.GetText("recommand_battlepower"), FormatString.BigIntString1(battlePower));
|
|
}
|
|
|
|
private void SetToSelected(bool isSelected)
|
|
{
|
|
if (isSelected)
|
|
{
|
|
imgHighlight.SetActive(true);
|
|
levelTxtColorSetter.SetColor("brown_dark");
|
|
}
|
|
else
|
|
{
|
|
imgHighlight.SetActive(false);
|
|
levelTxtColorSetter.SetColor("brown_light");
|
|
}
|
|
}
|
|
|
|
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").GetComponent<ButtonIV>();
|
|
|
|
imgTicket = btnTry.transform.Find("icon").GetComponent<Image>();
|
|
|
|
imgHighlight = unlockSet.transform.Find("imgCurrent").gameObject;
|
|
txtLevel = unlockSet.transform.Find("txtLevel").GetComponent<TextMeshProUGUI>();
|
|
txtCur = unlockSet.transform.Find("txtCur").GetComponent<TextMeshProUGUI>();
|
|
}
|
|
|
|
public override void SetData(int level)
|
|
{
|
|
itemID = level;
|
|
setDataHandler?.Invoke((uint)level);
|
|
}
|
|
|
|
public override void RefreshCellView()
|
|
{
|
|
SetData(itemID);
|
|
}
|
|
|
|
public void OnBtnSelect()
|
|
{
|
|
if(getRewards != null)
|
|
{
|
|
DungeonMgr.Instance.SetSelectDgLv(itemID);
|
|
DungeonMgr.Instance.SetRewardList(getRewards((uint)itemID));
|
|
}
|
|
|
|
SoundMgr.Instance.PlaySfx(SoundName.BtnPress);
|
|
}
|
|
|
|
public void OnBtnGoDungeon()
|
|
{
|
|
SoundMgr.Instance.PlaySfx(SoundName.BtnPress);
|
|
|
|
if(gModData != null)
|
|
DungeonMgr.Instance.OpenPopupPreset(gModData);
|
|
}
|
|
}
|