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

public class TeapotGun : MonoBehaviour
{
    public float Period = 1;
    public int ShotLayer;
    public float ShotSpeed = 10;
    public GameObject Shot;

    private float lastShot = 0;

    public void FixedUpdate()
    {
        if (Time.fixedTime - lastShot < Period || EndCondition.IsGameOver)
        {
            return;
        }

        lastShot = Time.fixedTime;
        var shot = Instantiate(Shot, transform.position, transform.rotation);
        shot.layer = ShotLayer;
        var shotRigidbody = shot.GetComponent<Rigidbody>();
        shotRigidbody.velocity = transform.forward * ShotSpeed;
    }
}
