using UnityEngine;
using System.Collections;

public class NavigationController : MonoBehaviour {

	public GameController gameController;
	public Transform source;
	public Transform target;
	
	public Action action;
	public Actor actor;
	
	public Sprite actionImage;
	
	public SpriteManager spriteManager;
	
	NavMeshAgent agent;
	Quaternion initialRotation;

	// Use this for initialization
	void Start () {
		agent = GetComponent<NavMeshAgent>();
		initialRotation = transform.rotation;
		agent.updateRotation = false;
	}
	
	// Update is called once per frame
	void Update () {
		agent.SetDestination(target.position);
		transform.rotation = initialRotation;
		actionImage = spriteManager.GetSpriteByAction(action);
		//gameObject.transform.LookAt(target);
	}
	
	public void GetRandomAction() {
		if(actor == Actor.coder) {
			if(action != Action.code) {
				action = Action.code;
				return;
			}
		} else if(actor == Actor.designer) {
			if(action != Action.design) {
				action =  Action.design;
				return;
			}
		} else if(actor == Actor.sound) {
			if(action != Action.sound) {
				action = Action.sound;
				return;
			}
		}
		int actionValue = (int) Mathf.Floor(Random.Range(4, 9.99f));
		action = (Action) actionValue;
	}
}
