revival/game/Assets/Scripts/UI/FreezeUI.cs

45 lines
1009 B
C#

using Ktyl.Util;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class FreezeUI : MonoBehaviour
{
[SerializeField]
private Image cooldownImage;
[SerializeField]
private PlayerPower freeze;
[SerializeField]
private GameObject freezePanel;
[SerializeField]
private SerialFloat frozenTime;
private float cooldownTimer = 0f;
public void updateCooldownUI(float rawCooldownTimer, float regenerateTime, float timeSinceConsume)
{
if (rawCooldownTimer <= 0)
cooldownTimer = 0;
else
cooldownTimer = rawCooldownTimer / regenerateTime;
cooldownImage.fillAmount = cooldownTimer;
if (rawCooldownTimer > frozenTime)
freezePanel.SetActive(true);
else
freezePanel.SetActive(false);
}
private void Update()
{
updateCooldownUI(freeze.cooldown, freeze.regenerateTime, freeze.timeSinceConsume);
}
}