add: functional riffle and inventory for bullets

This commit is contained in:
KOSMOGOR
2025-04-26 13:53:06 +03:00
parent 1b106e4e18
commit df5602dc00
8 changed files with 258 additions and 416 deletions
+21
View File
@@ -0,0 +1,21 @@
using UnityEngine;
public class Rifle : Weapon
{
public GameObject projectilePrefab;
public Transform spawnPosition;
public float fireRate = 3f;
[SerializeField] float currentDelay = 0;
public override void Shoot(bool keyDown, bool keyHold) {
if (keyHold && (fireRate == 0 || currentDelay >= 1 / fireRate) && GameController.i.ConsumeBullet(BulletType.Rifle)) {
Instantiate(projectilePrefab, spawnPosition.position, spawnPosition.rotation);
currentDelay = 0;
}
}
void Update() {
if (fireRate != 0) currentDelay = Mathf.Clamp(currentDelay += Time.deltaTime, 0, 1 / fireRate);
}
}