TapEffect.cs 961 B

12345678910111213141516171819202122232425262728293031323334
  1. namespace Shapes2D {
  2. using UnityEngine;
  3. using System.Collections;
  4. public class TapEffect : MonoBehaviour {
  5. public float speed = 1;
  6. public float length = 1.5f;
  7. float timer;
  8. Shapes2D.Shape shape;
  9. // Use this for initialization
  10. void Start () {
  11. shape = GetComponent<Shapes2D.Shape>();
  12. }
  13. // Update is called once per frame
  14. void Update () {
  15. transform.localScale += new Vector3(speed * Time.deltaTime,
  16. speed * Time.deltaTime);
  17. Color color = shape.settings.outlineColor;
  18. color.a = 1 - timer / length;
  19. shape.settings.outlineColor = color;
  20. shape.settings.outlineSize -= Time.deltaTime;
  21. timer += Time.deltaTime;
  22. if (timer > length) {
  23. gameObject.SetActive(false);
  24. Destroy(gameObject, 1);
  25. }
  26. }
  27. }
  28. }