using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class ControlCharacter : MonoBehaviour
{
    public Text nameTxt;
    public string nameStr = "Insert_name";

    public Text hpText;
    public int hp = 0;
    public int hpMax = 100;

    private Vector3 pos;
    //private bool _isEnd = false;
    private Shot obj_shot;
    private Motion motion;

    void Start()
    {
        nameTxt = nameTxt.GetComponent<Text>();
        nameTxt.text = nameStr;
        hpText = hpText.GetComponent<Text>();

        obj_shot = GetComponent<Shot>();
        //motion = GetComponent<Motion>();

        SetText();
    }

    void Update()
    {
        if (Input.touchCount == 1)
        {
        }
    }

    private Vector3 tmpPos;
    void FixedUpdate()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (obj_shot != null)
            {
                tmpPos = transform.position;//motion.getPosition();
                obj_shot.doShot(true, tmpPos.x, tmpPos.y);
                GetComponent<AudioSource>().Play();
            }
        }
        
        SetText();
    }

    void SetText()
    {
        hpText.text = "HP: " + hp.ToString() + " / " + hpMax.ToString();
    }
}