add: minigun
bug: minigun's mesh
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc7add7c3de58ca4d802a6eb169808fa
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user