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

public class PlayerControls : MonoBehaviour {
    HeadController controller;
    int winFoodAmount = 25;
	// Use this for initialization
	void Start () {
        controller = GetComponent<HeadController>();
	}
	
	// Update is called once per frame
	void FixedUpdate () {
        var inputVector = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
        controller.MoveTowards(inputVector);
        if (inputVector.magnitude > 0.1f)
            controller.RotateTowards(Mathf.Atan2(inputVector.y,inputVector.x)*Mathf.Rad2Deg);
        if (controller.nutrition > winFoodAmount)
        {
            //you have completed great game
        }
	}

    public string GetScoreString()
    {
        return string.Format("Nutrition: {0}/{1}", controller.nutrition, winFoodAmount);
    }

    public int GetCellCount()
    {
        return controller.cellCount;
    }

    public bool GameWon()
    {
        return controller.nutrition >= winFoodAmount;
    }
}
