using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SphereColliderExpansion : MonoBehaviour {
	
	public SphereCollider myCollider;
	public SphereColliderExpansion sphereColliderExpansion;
	public float sphereExpansionSpeed = 2.0f;
	public float SphereSlowDownSpeed = 0.05f;
	public float SphereInitialRadius = 0.01f;
	public string primeSphereColliderTag = "Prime Sphere Collider Expansion";

	void Start () {
		if (gameObject.tag == primeSphereColliderTag) {
			sphereColliderExpansion = gameObject.GetComponent<SphereColliderExpansion> ();
			sphereColliderExpansion.enabled = false;
		} else {
			myCollider = gameObject.GetComponent (typeof(SphereCollider)) as SphereCollider;
			myCollider.radius = SphereInitialRadius;
		}
	}

	void Update () {
		if (sphereExpansionSpeed >= 0) {
			myCollider.radius += (sphereExpansionSpeed * Time.deltaTime);
			sphereExpansionSpeed -= (SphereSlowDownSpeed * Time.deltaTime);
			SphereSlowDownSpeed += 1.0f * Time.deltaTime;
		}
		else Destroy (gameObject);
	}
}
