2025-12-23 13:09:28 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
2026-01-23 13:42:28 +08:00
|
|
|
|
using TMPro;
|
2025-12-23 13:09:28 +08:00
|
|
|
|
using UnityEngine;
|
2026-01-23 13:42:28 +08:00
|
|
|
|
using UnityEngine.UI;
|
2025-12-23 13:09:28 +08:00
|
|
|
|
|
|
|
|
|
|
public class PremiumPVPHandle : PremiumHandle
|
|
|
|
|
|
{
|
2026-01-23 13:42:28 +08:00
|
|
|
|
[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)
|
|
|
|
|
|
{
|
2026-01-16 11:43:16 +08:00
|
|
|
|
if (eventData.PvpProtectionCount == 0)
|
2025-12-23 13:09:28 +08:00
|
|
|
|
{
|
|
|
|
|
|
gameObject.transform.localScale = Vector3.one;
|
2026-01-23 13:42:28 +08:00
|
|
|
|
icon.sprite = normalSprite;
|
|
|
|
|
|
text.color = normalColor;
|
2025-12-23 13:09:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2026-01-16 11:43:16 +08:00
|
|
|
|
//发生了PVP保护,隐藏图标
|
2026-01-23 13:42:28 +08:00
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|