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

public class Boost : MonoBehaviour {

	public BoostManager boostManager;

	[SerializeField] SpriteRenderer[] arrowsRenderers;



	public void Init(){
		arrowsRenderers = new SpriteRenderer[transform.childCount];
		arrowsRenderers = transform.GetComponentsInChildren<SpriteRenderer> ();

		Deactivate ();
	}

	void OnTriggerStay2D(Collider2D other){
		other.GetComponent<Rigidbody2D> ().AddForce (transform.right * 2f, ForceMode2D.Impulse);
	}

	void OnTriggerExit2D(Collider2D other){
		//transform.position = new Vector3 (Mathf.Sign(transform.position.x) * Random.Range(0.6f,6.8f), Random.Range (-4.5f, 4.5f), 0);
		//transform.Rotate(new Vector3(0,0,Random.Range(0f,360f)));
		Deactivate();
		boostManager.ChooseNextBoost ();
	}

	public void Activate(){
		GetComponent<Collider2D> ().enabled = true;
		for (int i=0; i < arrowsRenderers.Length; i++) {
			arrowsRenderers[i].color = Color.white;
		}
	}

	void Deactivate(){
		GetComponent<Collider2D> ().enabled = false;
		for (int i=0; i < arrowsRenderers.Length; i++) {
			arrowsRenderers[i].color = Color.grey;
		}
	}




}
