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

public class Entity : MonoBehaviour {
	public Seat seat;
	public Transform head;
	public Renderer rendTorso;

	public string name;
	public string description;
	public Sprite sprite;

	public float personalityMood = 0f;
	float _realMood;
	public int effectiveMood {
		get { return _realMood<0? Mathf.FloorToInt(_realMood): Mathf.CeilToInt(_realMood); }
	}

	//class ModeCycle {
	//	public int index;
	//	public int beatPeriod = 1;	//TODO: Partial (float) for any Game.pulsesPerBeat?
	//	public int pulsePeriod = 0;
	//}
	//class Affect

	//public ModeCycle[] cycle;

	public void LoadInfo() {
		if(Game.instance.ui.tutorial == null) {
			var compDesc = description + "\n\nMOOD: " + effectiveMood.ToString("+0;-#;-0");
			Game.instance.ui.Info(name, compDesc, sprite);
		}
	}

	public float realHeadSize = 0.3354831f;
	float _headSize;

	public void HeadBump() {
		_headSize = realHeadSize * 1.2f;
	}

	// Use this for initialization
	void Start () {
		_headSize = realHeadSize;
		_realMood = personalityMood;

		rendTorso.material.color = Color.HSVToRGB(
			personalityMood< 0f ? 0f : 0.66f
			, Mathf.Clamp01(Mathf.Abs(personalityMood) / 4f)
			, 0.75f
			);
	}
	
	// Update is called once per frame
	void Update () {
		head.transform.localScale = Vector3.one * _headSize;
		_headSize = Mathf.Lerp(_headSize, realHeadSize, Time.deltaTime);
		_realMood = Mathf.Lerp(_realMood, personalityMood, Time.deltaTime);
		
	}
}
