SHADE_Y3/Assets/Scripts/UI/SC_StealFoodPopUp.cs

91 lines
2.4 KiB
C#
Raw Normal View History

using System;
using SHADE;
namespace SHADE_Scripting.UI
{
public class StealFoodPopUp : Script
{
[NonSerialized]
private TweenThread rot;
[NonSerialized]
private TweenThread scaleX;
[NonSerialized]
private TweenThread scaleY;
[NonSerialized]
private TweenThread scaleOutX;
[NonSerialized]
private TweenThread scaleOutY;
private Transform tran;
public float popInDuration = 0.3f;
public float popOutDuration = 0.3f;
public float stayDuration = 1.0f;
public float rotationAmt = 1800;
public float scaleAmtX = 538;
public float scaleAmtY = 377;
private bool popInDone = false;
private bool stayDone = false;
private bool createThreadOnce = true;
private float timer = 0;
protected override void start()
{
rot = TweenManager.CreateTweenThread(popInDuration, 0, rotationAmt, EASING_METHOD.EASE_IN_SINE);
scaleX = TweenManager.CreateTweenThread(popInDuration, 0, scaleAmtX, EASING_METHOD.EASE_IN_SINE);
scaleY = TweenManager.CreateTweenThread(popInDuration, 0, scaleAmtY, EASING_METHOD.EASE_IN_SINE);
tran = GetComponent<Transform>();
if (!tran)
Debug.LogError("Missing Transform");
else
{
tran.LocalScale = new Vector3(0.0f,0.0f,1.0f);
tran.LocalEulerAngles = new Vector3(0.0f,0.0f,0.0f);
}
}
//538x377
protected override void update()
{
if (!popInDone)
{
tran.LocalEulerAngles = new Vector3(0.0f, 0.0f, SHADE.Math.DegreesToRadians(rot.GetValue()));
tran.LocalScale = new Vector3(scaleX.GetValue(), scaleY.GetValue(), 1);
}
else
{
timer += Time.DeltaTimeF;
if (timer >= stayDuration)
stayDone = true;
}
if (rot.IsCompleted() && scaleX.IsCompleted() && scaleY.IsCompleted())
popInDone = true;
if (stayDone)
{
if (createThreadOnce)
{
scaleOutX = TweenManager.CreateTweenThread(popOutDuration, scaleAmtX, 0, EASING_METHOD.EASE_IN_SINE);
scaleOutY = TweenManager.CreateTweenThread(popOutDuration, scaleAmtY, 0, EASING_METHOD.EASE_IN_SINE);
createThreadOnce = false;
}
tran.LocalScale = new Vector3(scaleOutX.GetValue(), scaleOutY.GetValue(), 1);
if (scaleOutX.IsCompleted() && scaleOutY.IsCompleted())
{
GameObject.SetActive(false);
}
}
}
}
}