SHADE_Y3/Assets/Scripts/UI/SC_MultiplierTextFx.cs

77 lines
2.1 KiB
C#
Raw Normal View History

2023-02-27 17:01:46 +08:00
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 alphaThread;
public float maxSize = 1.0f;
public float minSize = 0.3f;
public float minAlpha = 0.3f;
2023-03-02 09:55:41 +08:00
private bool showMultiplier = false;
2023-02-27 17:01:46 +08:00
[NonSerialized]
private Vector3 defaultScale;
protected override void start()
{
2023-03-02 09:55:41 +08:00
sizeThread = TweenManager.CreateTweenThread(0.0f, maxSize, minSize, EASING_METHOD.EASE_IN_SINE);
alphaThread = TweenManager.CreateTweenThread(0.0f, 1.0f, minAlpha, EASING_METHOD.EASE_OUT_SINE);
2023-02-27 17:01:46 +08:00
Transform transform = GetComponent<Transform>();
if (transform != null)
2023-03-02 09:55:41 +08:00
{
2023-02-27 17:01:46 +08:00
defaultScale = transform.LocalScale;
2023-03-02 09:55:41 +08:00
transform.LocalScale = Vector3.Zero;
}
2023-02-27 17:01:46 +08:00
2023-03-02 09:55:41 +08:00
showMultiplier = false;
2023-02-27 17:01:46 +08:00
}
protected override void update()
{
Transform transform = GetComponent<Transform>();
2023-03-02 09:55:41 +08:00
if (transform != null && showMultiplier == true)
2023-02-27 17:01:46 +08:00
{
if(sizeThread.IsCompleted())
{
transform.LocalScale = Vector3.Zero;
2023-03-02 09:55:41 +08:00
showMultiplier = false;
2023-02-27 17:01:46 +08:00
}
else
{
transform.LocalScale = defaultScale * sizeThread.GetValue();
2023-03-02 09:55:41 +08:00
GetComponentInChildren<Renderable>().Material.SetProperty<float>("data.alpha",alphaThread.GetValue());
2023-02-27 17:01:46 +08:00
}
}
}
2023-03-02 09:55:41 +08:00
public void ShowMultiplier(int multiplier, float duration)
{
GetComponent<TextRenderable>().Text = $"X {multiplier}";
sizeThread.duration = duration;
alphaThread.duration = duration;
sizeThread.Reset();
alphaThread.Reset();
showMultiplier = true;
}
2023-02-27 17:01:46 +08:00
}
}