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

public class IA : MonoBehaviour {

	public bool jumping;
	public Animator anim;
	public Rigidbody playerRigidbody;
    public MovIA movIAScript;

//	private float cansancio = 0f;


	// Update is called once per frame


	void OnTriggerEnter(Collider col)
	{
        if(movIAScript.muerto == false)
        {
            //Si el objeto con el que colisiona es un rayo.
            if (col.gameObject.CompareTag("Rayo"))
            {
                //	Invoke ("Jump", Random.Range (0f, cansancio));
                //	cansancio = cansancio + 0.1f;
                if (jumping == false)
                {
                    jumping = true;
                    Invoke("stopJump", 1f);
                    playerRigidbody.AddForce(Vector3.up * 7, ForceMode.Impulse);
                }
            }
        }		
	}

	private void Jump(){
		jumping = true;
		Invoke("stopJump", 1f);
		playerRigidbody.AddForce (Vector3.up * 7, ForceMode.Impulse);
		//anim.SetTrigger("Jump");
	}

	private void stopJump()
	{
		jumping = false;
	}
}
