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

public class MyPlayer : MonoBehaviour {

	MyManager manager;
	public PlayerSkills skills;
	public float coolDown = 1f;
	float coolDownMax = 1f;
	public PlayerInventory inventory;
	Attack attack;
	public AudioSource stepAudio;

	public bool CanMove = false;

	void Awake()
	{
		manager = GameObject.Find("MyManager").GetComponent<MyManager>();
		skills = gameObject.GetComponent<PlayerSkills>();
		inventory = gameObject.GetComponent<PlayerInventory>();
		renderer.enabled = false;
		attack = gameObject.GetComponent<Attack>();
		stepAudio = gameObject.AddComponent<AudioSource>();
		stepAudio.clip = Resources.Load("Step") as AudioClip;
		stepAudio.volume = 0.3f;
	}

	public void SetLocation(string loc)
	{
		switch(loc)
		{
		case "Home":
			transform.position = manager.ConvertToVector3(manager.basement.StartPosition);
			CanMove = true;
			renderer.enabled = true;
			manager.startScreenManager.GetComponent<AudioSource>().enabled = false;
			manager.basement.GetComponent<AudioSource>().enabled = true;
			break;

		case "HomeSteeple":
			transform.position = manager.ConvertToVector3(manager.homeSteepleManager.StartPosition);
			CanMove = true;
			renderer.enabled = true;
			manager.homeSteepleManager.speakerAudio.enabled = true;
			break;

		case "VirginFoods":
			transform.position = manager.ConvertToVector3(manager.virginFoodsManager.StartPosition);
			CanMove = true;
			renderer.enabled = true;
			break;

		case "WorldMap":
			transform.position = manager.ConvertToVector3(manager.worldMapManager.StartPosition);
			CanMove = true;
			renderer.enabled = true;
			manager.homeSteepleManager.speakerAudio.enabled = false;
			break;

		case "Workbench":
			transform.position = manager.ConvertToVector3(manager.workbenchManager.StartPosition);
			CanMove = false;
			renderer.enabled = false;
			break;

		case "Credits":
			transform.position = manager.ConvertToVector3(manager.creditsManager.StartPosition);
			CanMove = false;
			renderer.enabled = false;
			break;

		case "Start":
			transform.position = manager.ConvertToVector3(manager.startScreenManager.StartPosition);
			CanMove = false;
			renderer.enabled = false;
			break;

		case "endScreen":

			break;

		default:
			break;
		}
	}

}
