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;
|
2023-03-02 17:34:11 +08:00
|
|
|
|
private TweenThread sizeInvertThread;
|
2023-03-31 14:50:25 +08:00
|
|
|
|
|
2023-02-27 17:01:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public float maxSize = 1.0f;
|
|
|
|
|
public float minSize = 0.3f;
|
2023-03-02 09:55:41 +08:00
|
|
|
|
|
2023-03-02 17:34:11 +08:00
|
|
|
|
const float sizeUpDuration = 0.1f;
|
2023-03-02 09:55:41 +08:00
|
|
|
|
|
2023-02-27 17:01:46 +08:00
|
|
|
|
[NonSerialized]
|
|
|
|
|
private Vector3 defaultScale;
|
|
|
|
|
|
2023-03-31 14:50:25 +08:00
|
|
|
|
private bool tweenUp = false;
|
|
|
|
|
|
2023-02-27 17:01:46 +08:00
|
|
|
|
protected override void start()
|
|
|
|
|
{
|
2023-03-31 14:50:25 +08:00
|
|
|
|
sizeThread = TweenManager.CreateTweenThread(0.01f, maxSize, minSize, EASING_METHOD.EASE_IN_SINE);
|
2023-03-02 17:34:11 +08:00
|
|
|
|
sizeInvertThread = TweenManager.CreateTweenThread(sizeUpDuration, minSize, maxSize, EASING_METHOD.EASE_IN_SINE);
|
2023-03-31 14:50:25 +08:00
|
|
|
|
|
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-31 14:50:25 +08:00
|
|
|
|
protected override void update()
|
|
|
|
|
{
|
|
|
|
|
Transform transform = GetComponent<Transform>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (transform != null)
|
|
|
|
|
{
|
|
|
|
|
if (tweenUp == false)
|
2023-02-27 17:01:46 +08:00
|
|
|
|
{
|
2023-03-31 14:50:25 +08:00
|
|
|
|
transform.LocalScale = defaultScale * sizeThread.GetValue();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (sizeInvertThread.IsCompleted())
|
|
|
|
|
{
|
|
|
|
|
tweenUp = false;
|
|
|
|
|
sizeThread.Reset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
transform.LocalScale = defaultScale * sizeInvertThread.GetValue();
|
2023-03-02 17:34:11 +08:00
|
|
|
|
|
2023-02-27 17:01:46 +08:00
|
|
|
|
}
|
2023-03-31 14:50:25 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
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}";
|
2023-03-02 17:34:11 +08:00
|
|
|
|
sizeThread.duration = duration + sizeUpDuration;
|
2023-03-02 09:55:41 +08:00
|
|
|
|
|
2023-03-02 17:34:11 +08:00
|
|
|
|
sizeInvertThread.Reset();
|
2023-03-02 09:55:41 +08:00
|
|
|
|
sizeThread.Reset();
|
2023-03-31 14:50:25 +08:00
|
|
|
|
tweenUp = true;
|
2023-03-02 09:55:41 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-27 17:01:46 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|