using System.Collections; using System.Collections.Generic; using UnityEngine; public class Weapon : MonoBehaviour { [SerializeField] private int maxAmmo; [SerializeField] private float shootSpeed; [SerializeField] private int damage; [SerializeField] private bool fullAuto; [SerializeField] private GameObject Bullet; private int Ammo; private bool shootDone; private float Wait; private void Start() { Ammo = maxAmmo; } public void shoot() { if(Ammo == 0 || Wait > 0 || shootDone && !fullAuto) { return; } if(!fullAuto) { shootDone = true; } Wait += shootSpeed; GameObject bullet = GameObject.Instantiate(Bullet, transform.position, transform.rotation); bullet.GetComponent().setDmg = damage; } private void Update() { Wait -= Time.deltaTime; Wait = Mathf.Clamp(Wait, 0, shootSpeed); } }