SHADE_Y3/Assets/Scripts/UI/SC_GameTimer.cs

58 lines
903 B
C#
Raw Permalink Normal View History

2023-03-31 14:50:25 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SHADE;
namespace SHADE_Scripting.UI
{
public class GameTimer: Script
{
private ScaleBounce scaleBounce;
private TextRenderable text;
public float criticalTime = 30;
public float timer;
protected override void awake()
{
text = GetComponent<TextRenderable>();
if(!text)
{
Debug.Log("GameTimer: No text renderable found");
}
scaleBounce = GetScript<ScaleBounce>();
if(!scaleBounce)
{
Debug.Log("GameTimer: No Scalebounce found in children");
}
else
{
scaleBounce.isActive = false;
}
}
protected override void update()
{
timer = GameManager.Instance.timer;
if (timer <= criticalTime)
{
scaleBounce.isActive = true;
text.TextColor = new Color(1.0f, 0.0f, 0.0f, 1.0f);
}
}
}
}