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

public class TriggerCollision : MonoBehaviour {

    public ColorUsed colorIndex;

	// Use this for initialization
	void Start () {
        ManagerReferences refs = GameObject.Find("Menager").GetComponent<ManagerReferences>();

        if(refs!=null)
        {
            Color newColor = refs.Colors[(int)colorIndex];
            gameObject.GetComponent<SpriteRenderer>().color = newColor;
        }

	}
	
	// Update is called once per frame
	void Update () {
		
	}


     void OnTriggerEnter2D(Collider2D other)
     {

        if(other.gameObject.tag=="Player")
        {
            Color playerColor = other.gameObject.GetComponent<SpriteRenderer>().color;
            Color thisColor = this.gameObject.GetComponent<SpriteRenderer>().color;
            ManagerReferences refs =
                GameObject.Find("Menager").GetComponent<ManagerReferences>();
            if(playerColor!=thisColor)
            {
                refs.ShowNewScene();
            }
        }
     }

}
