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

public class BasicWall : MonoBehaviour {

	public Sprite wallSpriteOpen;
	public Sprite wallSpriteClosen;

	public GlobalEnums.WaveTypes waveType;
	protected GlobalEnums.ActivityState currentActivityState;
	protected bool isAsleep = false;
	bool isPaused = false; //used so level "stops"

	// Use this for initialization

	void Start () 
	{
		
	}
	
	// Update is called once per frame
	void Update ()
	{
		if (!isPaused) 
		{
			ChangeActivityState ();
		}

	}

	public void UnPause()
	{
		isPaused = false;
	}

	public void Pause()
	{
		isPaused = true;
	}

	protected void ChangeActivityState()
	{
		GlobalEnums.WaveTypes pWave = GameObject.FindGameObjectWithTag ("Player").GetComponent<PlayerScript> ().GetCurrentWaveType();

		if(pWave == waveType) 
		{
			currentActivityState = GlobalEnums.ActivityState.Open;
		}
		else if(pWave != waveType) 
		{
			currentActivityState = GlobalEnums.ActivityState.Closed;
		}

		if (currentActivityState == GlobalEnums.ActivityState.Open)
		{
			this.gameObject.GetComponent<Collider2D> ().enabled = false;
			this.gameObject.GetComponent<SpriteRenderer>().sprite = wallSpriteOpen;
		} 
		else
		{
			this.gameObject.GetComponent<Collider2D> ().enabled = true;
			this.gameObject.GetComponent<SpriteRenderer>().sprite = wallSpriteClosen;
		}
	}

	protected void OnCollisionEnter2D(Collision2D col) 
	{
		
	}
}
