2023-03-10 19:31:23 +08:00
|
|
|
|
using SHADE;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace SHADE_Scripting.UI
|
|
|
|
|
{
|
2023-03-26 20:38:03 +08:00
|
|
|
|
public class SingleScaleBounce : Script
|
|
|
|
|
{
|
|
|
|
|
[NonSerialized]
|
|
|
|
|
TweenThread thread;
|
2023-03-10 19:31:23 +08:00
|
|
|
|
|
2023-03-26 20:38:03 +08:00
|
|
|
|
[NonSerialized]
|
|
|
|
|
Vector3 defaultScale;
|
2023-03-10 19:31:23 +08:00
|
|
|
|
|
2023-03-26 20:38:03 +08:00
|
|
|
|
public float durationUp = 0.15f;
|
|
|
|
|
public float durationDown = 0.3f;
|
2023-03-10 19:31:23 +08:00
|
|
|
|
|
2023-03-26 20:38:03 +08:00
|
|
|
|
public float scaleSize = 1.2f;
|
2023-03-10 19:31:23 +08:00
|
|
|
|
|
2023-03-26 20:38:03 +08:00
|
|
|
|
[NonSerialized]
|
|
|
|
|
private bool scaleUp = false;
|
2023-03-10 19:31:23 +08:00
|
|
|
|
|
2023-03-26 20:38:03 +08:00
|
|
|
|
private Transform trans;
|
2023-03-10 19:31:23 +08:00
|
|
|
|
|
2023-03-26 20:38:03 +08:00
|
|
|
|
protected override void awake()
|
|
|
|
|
{
|
|
|
|
|
trans = GetComponent<Transform>();
|
|
|
|
|
if (trans != null)
|
|
|
|
|
{
|
|
|
|
|
defaultScale = trans.LocalScale;
|
|
|
|
|
}
|
2023-03-10 19:31:23 +08:00
|
|
|
|
|
2023-03-26 20:38:03 +08:00
|
|
|
|
}
|
2023-03-10 19:31:23 +08:00
|
|
|
|
|
2023-03-26 20:38:03 +08:00
|
|
|
|
protected override void start()
|
|
|
|
|
{
|
|
|
|
|
if(thread != null)
|
|
|
|
|
thread = TweenManager.CreateTweenThread(0.0f, 1.0f, 1.0f, EASING_METHOD.EASE_IN_SINE);
|
|
|
|
|
}
|
2023-03-10 19:31:23 +08:00
|
|
|
|
|
|
|
|
|
|
2023-03-26 20:38:03 +08:00
|
|
|
|
protected override void update()
|
|
|
|
|
{
|
|
|
|
|
if (scaleUp)
|
|
|
|
|
{
|
|
|
|
|
if (thread != null && thread.IsCompleted())
|
2023-03-10 19:31:23 +08:00
|
|
|
|
{
|
2023-03-26 20:38:03 +08:00
|
|
|
|
scaleUp = false;
|
|
|
|
|
thread.duration = durationDown;
|
|
|
|
|
thread.ResetInvert();
|
2023-03-10 19:31:23 +08:00
|
|
|
|
}
|
2023-03-26 20:38:03 +08:00
|
|
|
|
}
|
2023-03-10 19:31:23 +08:00
|
|
|
|
|
2023-03-26 20:38:03 +08:00
|
|
|
|
if (trans && thread != null)
|
|
|
|
|
trans.LocalScale = defaultScale * thread.GetValue();
|
|
|
|
|
}
|
2023-03-10 19:31:23 +08:00
|
|
|
|
|
2023-03-26 20:38:03 +08:00
|
|
|
|
public void ScaleBounceOnce()
|
|
|
|
|
{
|
|
|
|
|
scaleUp = true;
|
|
|
|
|
if (thread != null)
|
|
|
|
|
{
|
|
|
|
|
thread.duration = durationUp;
|
|
|
|
|
thread.Reset(1.0f, scaleSize);
|
|
|
|
|
}
|
2023-03-10 19:31:23 +08:00
|
|
|
|
}
|
2023-03-26 20:38:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-03-10 19:31:23 +08:00
|
|
|
|
}
|