using UnityEngine;
using System.Collections;

public class AIMove_HitPlayer : AIMove_Base
{
    private Vector3 vCurrentGoal;
    private PlayerController _attackTarget;
    public GameObject Prefab_Smoke;

    void Update()
    {
        _attackTarget = _attackTarget == null ? GameObject.Find("Player").GetComponent<PlayerController>() : _attackTarget;
        UpdateMovement(_attackTarget);

        //make some smoke
        if (Random.value < 0.35f)
        {
            GameObject go = Instantiate(Prefab_Smoke);
            go.transform.position = transform.position;
            DebrisComponent dc = go.GetComponent<DebrisComponent>();
            dc.Launch();
        }
    }

    public override void UpdateMovement(PlayerController attackTarget)
    {
        //look at the target
        FaceObject(attackTarget);

        vCurrentGoal = attackTarget.vGamePosition;

        //if we have a goal position, move towards it.
        ApplyInertiaTowardsGoalPosition(vCurrentGoal);

        DecayInertia();
        //move
        transform.position += vMoveInertia*Time.deltaTime;
    }
}
