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

public class UltimateWave : MonoBehaviour {
	public float waitTime = 5f;
	public float startTime;
	public bool dropping;

	void Update () {
		transform.localScale += new Vector3 (0.05f, 0.05f, 0f);
		if (Time.time >= startTime + waitTime && dropping == true) {
			Destroy (this.gameObject);
		}
	}
	void OnTriggerEnter2D (Collider2D other) {
		if (other.gameObject.tag == "Red Enemy" || other.gameObject.tag == "Blue Enemy" || other.gameObject.tag == "Green Enemy" || other.gameObject.tag == "Yellow Enemy") {
			Rigidbody2D otherRb = other.gameObject.GetComponent<Rigidbody2D> ();
			other.gameObject.GetComponent<EnemyScript> ().enabled = false;
			otherRb.velocity = new Vector2 (other.gameObject.transform.position.x, other.gameObject.transform.position.y) ;
		}
		if (other.gameObject.tag == "Player") {
			startTime = Time.time;
			dropping = true;
		}
	}
}
