add: minigun

bug: minigun's mesh
This commit is contained in:
KOSMOGOR
2025-04-27 17:35:06 +03:00
parent 15ea51e465
commit f754b692e2
12 changed files with 541 additions and 1 deletions
+21
View File
@@ -0,0 +1,21 @@
using UnityEngine;
public class Minigun : Weapon
{
public GameObject projectilePrefab;
public Transform spawnPosition;
public float fireRate = 10f;
[SerializeField] float currentDelay = 0;
public override void Shoot(bool keyDown, bool keyHold) {
if (keyHold && (fireRate == 0 || currentDelay >= 1 / fireRate) && GameController.i.ConsumeBullet(bulletType)) {
Instantiate(projectilePrefab, spawnPosition.position, spawnPosition.rotation);
currentDelay = 0;
}
}
void Update() {
if (fireRate != 0) currentDelay = Mathf.Clamp(currentDelay += Time.deltaTime, 0, 1 / fireRate);
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: bc7add7c3de58ca4d802a6eb169808fa
+1 -1
View File
@@ -9,7 +9,7 @@ public class Rifle : Weapon
[SerializeField] float currentDelay = 0;
public override void Shoot(bool keyDown, bool keyHold) {
if (keyHold && (fireRate == 0 || currentDelay >= 1 / fireRate) && GameController.i.ConsumeBullet(BulletType.Rifle)) {
if (keyHold && (fireRate == 0 || currentDelay >= 1 / fireRate) && GameController.i.ConsumeBullet(bulletType)) {
Instantiate(projectilePrefab, spawnPosition.position, spawnPosition.rotation);
currentDelay = 0;
}
+1
View File
@@ -3,6 +3,7 @@ using UnityEngine;
public abstract class Weapon : MonoBehaviour
{
public bool isActive { get; private set; } = false;
public BulletType bulletType = BulletType.None;
public abstract void Shoot(bool keyDown, bool keyHold);