using UnityEngine;
using System.Collections;

[RequireComponent(typeof(CircleCollider2D))]

public class Wave : MonoBehaviour 
{
    CircleCollider2D wave;
    public float waveStartR = 0.5f;
    public float waveSpeed = 8.0f;

    public Circle circle;

    void Start()
    {
        wave = GetComponent<CircleCollider2D>();
        wave.isTrigger = true;
        wave.radius = waveStartR;
        circle.radius = waveStartR;

        gameObject.SetActive(false);
        circle.gameObject.SetActive(false);
    }

    void FixedUpdate()
    {
        wave.radius += waveSpeed * Time.deltaTime;
        circle.radius = circle.xradius + (waveSpeed * Time.deltaTime);

        if (wave.radius > 60.0f)
        {
            gameObject.SetActive(false);
            circle.gameObject.SetActive(false);
        }
    }

    void OnDrawGizmos()
    {
        Gizmos.color = Color.red;

        if(Application.isPlaying)
            Gizmos.DrawWireSphere(transform.position, wave.radius);
    }

    public void Reset()
    {
        wave.radius = waveStartR;
        circle.radius = waveStartR;
    }
}
