using UnityEngine;
using System.Collections;

public class togglePsychosis : MonoBehaviour 
{
    public GameObject crazyLand;
    public GameObject saneLand;

    public float freakOutTime;

	// Use this for initialization
	void Start () 
    {

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

    IEnumerator freakOut()
    {
        foreach (GameObject tempGameObject in toggleEnemies.Enemies.Keys)
        {
			if (tempGameObject == true)
			{
	            tempGameObject.renderer.enabled = false;
	            tempGameObject.GetComponent<placeOnAllEnemies>().childSaneEnemy.renderer.enabled = true;
			}
        }
        crazyLand.gameObject.SetActive(false);
        saneLand.gameObject.SetActive(true);
        yield return new WaitForSeconds(freakOutTime);
        saneLand.gameObject.SetActive(false);
        crazyLand.gameObject.SetActive(true);
        foreach (GameObject tempGameObject in toggleEnemies.Enemies.Keys)
        {
			if (tempGameObject == true)
			{
	            tempGameObject.GetComponent<placeOnAllEnemies>().childSaneEnemy.renderer.enabled = false;
	            tempGameObject.renderer.enabled = true;
			}
        }
    }

    public void switchPhyschosis()
    {
        StartCoroutine(freakOut());
    }
}
