NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/GameWrapper/Premium/PremiumPVPHandle.cs

46 lines
1.4 KiB
C#
Raw Normal View History

2025-12-23 13:09:28 +08:00
using System.Collections;
using System.Collections.Generic;
using TMPro;
2025-12-23 13:09:28 +08:00
using UnityEngine;
using UnityEngine.UI;
2025-12-23 13:09:28 +08:00
public class PremiumPVPHandle : PremiumHandle
{
[SerializeField] private Image icon;
[SerializeField] private TextMeshProUGUI text;
[Header("激活")]
[SerializeField] private Sprite normalSprite;
[SerializeField] private Color normalColor;
[Header("失效")]
[SerializeField] private Sprite expiredSprite;
[SerializeField] private Color expiredColor;
2025-12-23 13:09:28 +08:00
protected override void OnPremiumStatusChanged(PremiumStatusChangedEvent eventData)
{
2026-01-28 12:48:50 +08:00
if(icon==null) icon = gameObject.transform.Find("Image").GetComponent<Image>();
if(text==null) text = gameObject.transform.Find("Text").GetComponent<TextMeshProUGUI>();
2025-12-23 13:09:28 +08:00
if (eventData.IsActivated)
{
if (eventData.PvpProtectionCount == 0)
2025-12-23 13:09:28 +08:00
{
gameObject.transform.localScale = Vector3.one;
icon.sprite = normalSprite;
text.color = normalColor;
2025-12-23 13:09:28 +08:00
}
else
{
//发生了PVP保护隐藏图标
gameObject.transform.localScale = Vector3.one;
icon.sprite = expiredSprite;
text.color = expiredColor;
2025-12-23 13:09:28 +08:00
}
}
else
{
gameObject.transform.localScale = Vector3.zero;
}
}
}