38 lines
955 B
C#
38 lines
955 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class ScalePingPong : MonoBehaviour
|
|
{
|
|
public bool execAlways;
|
|
public float amplitude = 0.2f, speed = 8;
|
|
void Start()
|
|
{
|
|
GameManager.instance.OnNoMoney.AddListener(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));
|
|
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;
|
|
}
|
|
}
|