40 lines
1.0 KiB
C#
40 lines
1.0 KiB
C#
using System.Collections;
|
|
using UnityEngine;
|
|
|
|
public class ScalePingPong : MonoBehaviour
|
|
{
|
|
public bool execAlways;
|
|
public float amplitude = 0.2f, speed = 8;
|
|
|
|
[SerializeField] Notification notification;
|
|
void Start()
|
|
{
|
|
PaymentSystem.OnNotEnoughMoney += exec;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (execAlways)
|
|
{
|
|
transform.localScale = Vector3.one * (1 - Mathf.PingPong(Time.time * speed, amplitude));
|
|
}
|
|
}
|
|
public void exec()
|
|
{
|
|
//transform.localScale = Vector3.one * (1- Mathf.PingPong(Time.time*speed, amplitude));
|
|
NotificationSystem.instance.Notificate(notification);
|
|
StartCoroutine(animate());
|
|
}
|
|
|
|
IEnumerator animate()
|
|
{
|
|
float startTime = Time.time;
|
|
while (Time.time - startTime < 0.5f)
|
|
{
|
|
transform.localScale = Vector3.one * (1 - Mathf.PingPong(Time.time * speed, amplitude));
|
|
yield return null;
|
|
}
|
|
transform.localScale = Vector3.one;
|
|
}
|
|
}
|