SHADE_Y3/Assets/Scripts/UI/SC_MultiplierTextFx.cs

81 lines
1.9 KiB
C#

using SHADE;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SHADE_Scripting.UI
{
public class MultiplierTextFx : Script
{
[NonSerialized]
private TweenThread sizeThread;
private TweenThread sizeInvertThread;
public float maxSize = 1.0f;
public float minSize = 0.3f;
const float sizeUpDuration = 0.1f;
[NonSerialized]
private Vector3 defaultScale;
private bool tweenUp = false;
protected override void start()
{
sizeThread = TweenManager.CreateTweenThread(0.01f, maxSize, minSize, EASING_METHOD.EASE_IN_SINE);
sizeInvertThread = TweenManager.CreateTweenThread(sizeUpDuration, minSize, maxSize, EASING_METHOD.EASE_IN_SINE);
Transform transform = GetComponent<Transform>();
if (transform != null)
{
defaultScale = transform.LocalScale;
transform.LocalScale = Vector3.Zero;
}
}
protected override void update()
{
Transform transform = GetComponent<Transform>();
if (transform != null)
{
if (tweenUp == false)
{
transform.LocalScale = defaultScale * sizeThread.GetValue();
}
else
{
if (sizeInvertThread.IsCompleted())
{
tweenUp = false;
sizeThread.Reset();
}
transform.LocalScale = defaultScale * sizeInvertThread.GetValue();
}
}
}
public void ShowMultiplier(int multiplier, float duration)
{
GetComponent<TextRenderable>().Text = $"X {multiplier}";
sizeThread.duration = duration + sizeUpDuration;
sizeInvertThread.Reset();
sizeThread.Reset();
tweenUp = true;
}
}
}