using UnityEngine;
|
using UnityEngine.UI;
|
|
public class PhantasmPavilionUnlockButton : MonoBehaviour
|
{
|
[SerializeField] ButtonEx btnUnlock;
|
[SerializeField] ImageEx imgItem;
|
[SerializeField] TextEx txtCount;
|
[SerializeField] Image imgRed;
|
PhantasmPavilionType type;
|
int id;
|
int unlockWay;
|
int unlockValue;
|
PhantasmPavilionManager manager { get { return PhantasmPavilionManager.Instance; } }
|
public void Display(int id)
|
{
|
type = manager.nowType;
|
this.id = id;
|
btnUnlock.SetListener(() =>
|
{
|
if (unlockWay == 2)
|
{
|
var hasCnt = PackManager.Instance.GetItemCountByID(PackType.Item, unlockValue);
|
int useCnt = manager.GetUnlockNeedCnt(type, id);
|
if (useCnt > hasCnt)
|
{
|
if (!ItemConfig.HasKey(unlockValue))
|
return;
|
string name = ItemConfig.Get(unlockValue).ItemName;
|
SysNotifyMgr.Instance.ShowTip("UnLockFail2", name);
|
return;
|
}
|
}
|
else if (unlockWay == 3)
|
{
|
bool hasHero = HeroManager.Instance.HasHero(unlockValue);
|
if (!hasHero)
|
{
|
SysNotifyMgr.Instance.ShowTip("UnLockFail1");
|
return;
|
}
|
}
|
manager.SendOPPack(type, PhantasmPavilionOperation.Activate, (uint)id);
|
SysNotifyMgr.Instance.ShowTip("UnLockSuccess");
|
});
|
|
unlockWay = manager.GetUnlockWay(type, id);
|
unlockValue = manager.GetUnlockValue(type, id);
|
|
txtCount.SetActive(unlockWay == 2);
|
imgRed.SetActive(false);
|
if (unlockWay == 2)
|
{
|
|
if (!ItemConfig.HasKey(unlockValue))
|
return;
|
imgItem.SetItemSprite(unlockValue);
|
|
var hasCnt = PackManager.Instance.GetItemCountByID(PackType.Item, unlockValue);
|
int useCnt = manager.GetUnlockNeedCnt(type, id);
|
txtCount.text = UIHelper.AppendColor(useCnt <= hasCnt ? TextColType.Green : TextColType.Red, Language.Get("BoneField09", hasCnt, useCnt));
|
imgRed.SetActive(useCnt <= hasCnt);
|
}
|
}
|
|
}
|