using UnityEngine;
using System.Collections;

public class WeirdScript : MonoBehaviour {

	public PlayerScript ps;
	public Transform cam;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		if (((ps.stress > 0.25F) && (ps.isdreaming) && (!ps.transition)) || (ps.stress >= 1F)) {
			renderer.material.color = new Color(1F,1F,1F,(ps.stress - 0.25F));
		} else {
			renderer.material.color = new Color(1F,1F,1F,0);
		}
		if (renderer.material.color.a > 0) {
			float wx = cam.position.x;
			float wy = cam.position.y;
			float wz = transform.position.z;
			wx += (Random.value * 36F) - 18F;
			wy += (Random.value * 36F) - 18F;
			transform.position = new Vector3(wx,wy,wz);
		}
	}
}
