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

public class VideoCamera : MonoBehaviour {
	int rotateDir = 1;
	public float speed = 90;
	public float bounds = 90;
	float initRot;
	float slow_time = 5;
	float timer;
	float currentOrientation;

	void Start(){
		currentOrientation =0;
		initRot = transform.eulerAngles.z;
	}

	public void Update(){
		float rotation= speed * rotateDir * Time.deltaTime;
		transform.Rotate (new Vector3 (0,0,360 + rotation));
		currentOrientation += rotation;
		if (timer > 0) {
			timer -= Time.deltaTime;
			if (timer <= 0) {
				speed *= 2;
			}
		}
		if ((this.transform.eulerAngles.z - initRot +360 )%360 > bounds &&  (this.transform.eulerAngles.z - initRot +360)%360 < 360 - bounds){
			rotateDir *= -1;
		}
	}

	public void Activation(){
		if (timer <= 0) {
			speed /= 2;
			timer = slow_time;
		}
	}

	void VisionToKill(PlayerScript p1){
		Vector3 forward = this.gameObject.transform.TransformDirection (Vector3.forward);
		Debug.DrawRay (transform.position,forward,Color.green);
	}

}
