Files
ft/Client/Assets/Scripts/UI/PartnerStatue/EventPartnerStatueView.cs
2026-06-29 21:18:33 +08:00

40 lines
1.1 KiB
C#

using UnityEngine;
public class EventPartnerStatueView : MonoBehaviour
{
[SerializeField] private GameObject[] masks;
private int _maxStage;
public void Init(int currentStage, int maxStage)
{
_maxStage = maxStage;
Set(currentStage);
if (masks.Length != maxStage)
Debug.LogError($"Masks count {masks.Length} does not match max stage count {maxStage}", this);
}
public void Set(int stage)
{
foreach (var mask in masks)
mask.SetActive(false);
stage = Mathf.Clamp(stage, 0, _maxStage);
if (stage == _maxStage)
return;
masks[_maxStage - 1 - stage].SetActive(true);
}
public int SetWithFx(int stage)
{
var res = -1;
foreach (var mask in masks)
mask.SetActive(false);
stage = Mathf.Clamp(stage, 0, _maxStage);
var idx = _maxStage - 1 - stage;
res = idx + 1;
if (stage == _maxStage)
return res;
masks[_maxStage - 1 - stage].SetActive(true);
return res >= _maxStage ? -1 : res;
}
}