using UnityEngine;
using System.Collections;

public class CCDIKMan : MonoBehaviour {
	[SerializeField] private GameObject head;
	[SerializeField] private GameObject rightHand;
	[SerializeField] private GameObject leftHand;
	[SerializeField] private GameObject rightLeg;
	[SerializeField] private GameObject leftLeg;
	[SerializeField] private GameObject hip;

	[SerializeField] private Animator manAnimator;

	[SerializeField] private bool isReceiveInput;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		if (!isReceiveInput) {
			return;
		}
		if (Input.GetButtonDown ("Fire1")) {
			manAnimator.ResetTrigger ("Idle");
			manAnimator.SetTrigger ("Bow");
		} else if (Input.GetButtonUp ("Fire1")) {
			manAnimator.ResetTrigger ("Bow");
			manAnimator.SetTrigger ("Idle");
		}
	}

	void OnTriggerEnter2D(Collider2D col)
	{ 
		if(col.gameObject.tag == "Player" )
		{
			Debug.Log ("collide");
			this.GetComponent<Rigidbody2D> ().AddForce ( (this.transform.position - col.gameObject.transform.position) * 3, ForceMode2D.Impulse);
		}
	}
}
