2023-03-04 13:44:53 +08:00
|
|
|
using SHADE;
|
2023-03-02 16:26:49 +08:00
|
|
|
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;
|
2023-03-04 13:44:53 +08:00
|
|
|
private TweenThread sizeInvertThread;
|
2023-03-02 16:26:49 +08:00
|
|
|
private TweenThread alphaThread;
|
|
|
|
|
|
|
|
|
|
|
|
public float maxSize = 1.0f;
|
|
|
|
public float minSize = 0.3f;
|
|
|
|
public float minAlpha = 0.3f;
|
|
|
|
|
|
|
|
|
|
|
|
private bool showMultiplier = false;
|
2023-03-04 13:44:53 +08:00
|
|
|
const float sizeUpDuration = 0.1f;
|
2023-03-02 16:26:49 +08:00
|
|
|
|
|
|
|
[NonSerialized]
|
|
|
|
private Vector3 defaultScale;
|
|
|
|
|
|
|
|
protected override void start()
|
|
|
|
{
|
|
|
|
sizeThread = TweenManager.CreateTweenThread(0.0f, maxSize, minSize, EASING_METHOD.EASE_IN_SINE);
|
2023-03-04 13:44:53 +08:00
|
|
|
sizeInvertThread = TweenManager.CreateTweenThread(sizeUpDuration, minSize, maxSize, EASING_METHOD.EASE_IN_SINE);
|
2023-03-02 16:26:49 +08:00
|
|
|
alphaThread = TweenManager.CreateTweenThread(0.0f, 1.0f, minAlpha, EASING_METHOD.EASE_OUT_SINE);
|
|
|
|
Transform transform = GetComponent<Transform>();
|
|
|
|
if (transform != null)
|
|
|
|
{
|
|
|
|
defaultScale = transform.LocalScale;
|
|
|
|
transform.LocalScale = Vector3.Zero;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
showMultiplier = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void update()
|
|
|
|
{
|
|
|
|
Transform transform = GetComponent<Transform>();
|
2023-03-04 13:44:53 +08:00
|
|
|
|
|
|
|
|
2023-03-02 16:26:49 +08:00
|
|
|
if (transform != null && showMultiplier == true)
|
|
|
|
{
|
2023-03-04 13:44:53 +08:00
|
|
|
if(!sizeInvertThread.IsCompleted())
|
|
|
|
{
|
|
|
|
transform.LocalScale = defaultScale * sizeInvertThread.GetValue();
|
|
|
|
|
|
|
|
Renderable rend = GetComponentInChildren<Renderable>();
|
|
|
|
if(rend)
|
|
|
|
{
|
|
|
|
rend.Material.SetProperty<float>("data.alpha", 1.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextRenderable text = GetComponent<TextRenderable>();
|
|
|
|
if (text)
|
|
|
|
{
|
|
|
|
Color clr = text.TextColor;
|
|
|
|
text.TextColor = new Color(clr.r, clr.g, clr.b, 1.0f);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-03-02 16:26:49 +08:00
|
|
|
if(sizeThread.IsCompleted())
|
|
|
|
{
|
|
|
|
transform.LocalScale = Vector3.Zero;
|
|
|
|
showMultiplier = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
transform.LocalScale = defaultScale * sizeThread.GetValue();
|
2023-03-04 13:44:53 +08:00
|
|
|
|
|
|
|
Renderable rend = GetComponentInChildren<Renderable>();
|
|
|
|
if (rend)
|
|
|
|
{
|
|
|
|
rend.Material.SetProperty<float>("data.alpha", alphaThread.GetValue());
|
|
|
|
}
|
|
|
|
TextRenderable text = GetComponent<TextRenderable>();
|
|
|
|
if(text)
|
|
|
|
{
|
|
|
|
Color clr = text.TextColor;
|
|
|
|
text.TextColor = new Color(clr.r,clr.g,clr.b,alphaThread.GetValue() * 1.3f);
|
|
|
|
}
|
2023-03-02 16:26:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ShowMultiplier(int multiplier, float duration)
|
|
|
|
{
|
|
|
|
GetComponent<TextRenderable>().Text = $"X {multiplier}";
|
2023-03-04 13:44:53 +08:00
|
|
|
sizeThread.duration = duration + sizeUpDuration;
|
|
|
|
alphaThread.duration = duration + sizeUpDuration;
|
2023-03-02 16:26:49 +08:00
|
|
|
|
2023-03-04 13:44:53 +08:00
|
|
|
sizeInvertThread.Reset();
|
2023-03-02 16:26:49 +08:00
|
|
|
sizeThread.Reset();
|
|
|
|
alphaThread.Reset();
|
|
|
|
showMultiplier = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|