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

public class ColorSwitch : MonoBehaviour {
    public ColorUsed[] allowed;

    void OnTriggerEnter2D(Collider2D col)
    {
        if(col.gameObject.tag == "Player")
        {
            ManagerReferences refs =
               GameObject.Find("Menager").GetComponent<ManagerReferences>();
            int index = Random.Range(0, allowed.Length - 1);
            ColorUsed newColor = allowed[index];
            refs.SwitchColorPlayer(newColor);

            Destroy(gameObject);
        }
    }
	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		
	}
}
