46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using TMPro;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
|
||
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;
|
||
|
||
protected override void OnPremiumStatusChanged(PremiumStatusChangedEvent eventData)
|
||
{
|
||
if(icon==null) icon = gameObject.transform.Find("Image").GetComponent<Image>();
|
||
if(text==null) text = gameObject.transform.Find("Text").GetComponent<TextMeshProUGUI>();
|
||
|
||
if (eventData.IsActivated)
|
||
{
|
||
if (eventData.PvpProtectionCount == 0)
|
||
{
|
||
gameObject.transform.localScale = Vector3.one;
|
||
icon.sprite = normalSprite;
|
||
text.color = normalColor;
|
||
}
|
||
else
|
||
{
|
||
//发生了PVP保护,隐藏图标
|
||
gameObject.transform.localScale = Vector3.one;
|
||
icon.sprite = expiredSprite;
|
||
text.color = expiredColor;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
gameObject.transform.localScale = Vector3.zero;
|
||
}
|
||
}
|
||
}
|