using UnityEngine; using UnityEngine.UI; public class PhantasmPavilionAddStarButton : MonoBehaviour { [SerializeField] ButtonEx btnAddStar; [SerializeField] ImageEx imgAddStar; [SerializeField] TextEx txtAddStar; [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; btnAddStar.SetListener(() => { if (unlockWay == 2) { var hasCnt = PackManager.Instance.GetItemCountByID(PackType.Item, unlockValue); int useCnt = manager.GetUpNeedCnt(type, id); if (useCnt > hasCnt) { if (!ItemConfig.HasKey(unlockValue)) return; string name = ItemConfig.Get(unlockValue).ItemName; SysNotifyMgr.Instance.ShowTip("UnLockFail2", name); return; } } manager.SendOPPack(type, PhantasmPavilionOperation.UpgradeStar, (uint)id); }); unlockWay = manager.GetUnlockWay(type, id); unlockValue = manager.GetUnlockValue(type, id); bool isStarMax = manager.IsStarMax(type, id); txtAddStar.text = Language.Get(isStarMax ? "L1110" : "L1109"); imgAddStar.gray = isStarMax; btnAddStar.interactable = !isStarMax; imgRed.SetActive(false); txtCount.SetActive(unlockWay == 2 && !isStarMax); if (unlockWay == 2) { if (!ItemConfig.HasKey(unlockValue)) return; imgItem.SetItemSprite(unlockValue); var hasCnt = PackManager.Instance.GetItemCountByID(PackType.Item, unlockValue); int useCnt = manager.GetUpNeedCnt(type, id); txtCount.text = UIHelper.AppendColor(useCnt <= hasCnt ? TextColType.DarkGreen : TextColType.Red, Language.Get("BoneField09", hasCnt, useCnt)); imgRed.SetActive(useCnt <= hasCnt && !isStarMax); } } }