112 lines
2.9 KiB
C#
112 lines
2.9 KiB
C#
using System;
|
|
using SHADE_Scripting.Audio;
|
|
using SHADE;
|
|
|
|
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;
|
|
|
|
private bool playAudio = true;
|
|
|
|
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);
|
|
}
|
|
|
|
AudioHandler.audioClipHandlers["StealFood"] = Audio.CreateAudioClip("event:/UI/spin_in");
|
|
|
|
}
|
|
protected override void update()
|
|
{
|
|
if (!GameManager.Instance.PreviewLevelDone)
|
|
{
|
|
if (rot != null && scaleX != null && scaleY != null)
|
|
{
|
|
rot.Reset();
|
|
scaleX.Reset();
|
|
scaleY.Reset();
|
|
}
|
|
return;
|
|
}
|
|
|
|
if (playAudio)
|
|
{
|
|
AudioHandler.audioClipHandlers["StealFood"].Play();
|
|
playAudio = false;
|
|
}
|
|
|
|
if (!popInDone && rot != null && scaleX != null && scaleY != null)
|
|
{
|
|
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 != null && scaleX != null && scaleY != null && 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;
|
|
}
|
|
|
|
if (scaleOutX != null && scaleOutY != null)
|
|
tran.LocalScale = new Vector3(scaleOutX.GetValue(), scaleOutY.GetValue(), 1);
|
|
|
|
if (scaleOutX != null && scaleOutY != null && scaleOutX.IsCompleted() && scaleOutY.IsCompleted())
|
|
{
|
|
GameObject.SetActive(false);
|
|
GameManager.Instance.stealFoodPopUpDone = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|