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

public class CharacterShooter : MonoBehaviour {

    [SerializeField]
    private Transform spawnBulletPoint;

    [SerializeField]
    private GameObject bulletPrefab;

    [SerializeField]
    private float shootInterval = 0.2f;

    private float lastShoot = 0;

    protected Character controller;

    public virtual void PrepareShooter (Character controller) {
        this.controller = controller;
        this.lastShoot = 0;
    }

    public void Shoot () {
        if (this.controller is Player) {
            if ((this.controller as Player).HasAntena) {
                return;
            }
        }

        if (Time.time - this.lastShoot > this.shootInterval) {
            this.controller.CharacterAnimator.SetTrigger(Keys.Animator.FIREGUN_KEY);
            this.lastShoot = Time.time;
            Instantiate(this.bulletPrefab, this.spawnBulletPoint.position, this.spawnBulletPoint.rotation);
        }
    }
}
