full playable game
This commit is contained in:
1 parent
afcd8761e6
commit
1869fa7584
56 files changed
+7581
-37
No files matched your search
@@ -21,7 +21,7 @@ namespace Code.Gameplay.Weapons
|
||||
[SerializeField] protected float reloadTime = 1.5f;
|
||||
[SerializeField] protected float spreadAngle = 1f;
|
||||
|
||||
private Transform _firePoint;
|
||||
public Transform _firePoint;
|
||||
[SerializeField] protected GameObject bulletPrefab;
|
||||
[SerializeField] protected ParticleSystem muzzleFlash;
|
||||
[SerializeField] protected AudioClip shootSound;
|
||||
@@ -32,12 +32,15 @@ namespace Code.Gameplay.Weapons
|
||||
protected bool isShooting;
|
||||
protected bool isReloading;
|
||||
protected float lastShotTime;
|
||||
protected float lastShotTryTime;
|
||||
|
||||
public WeaponType Type => weaponType;
|
||||
public int CurrentAmmo => currentAmmo;
|
||||
public int ReserveAmmo => reserveAmmo;
|
||||
public int MagazineSize => magazineSize;
|
||||
public bool IsReloading => isReloading;
|
||||
public float FireRate => fireRate;
|
||||
public string WeaponName => weaponName;
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
@@ -50,21 +53,23 @@ namespace Code.Gameplay.Weapons
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
_firePoint = FindFirstObjectByType<CameraController>().transform;
|
||||
if (!_firePoint)
|
||||
_firePoint = FindFirstObjectByType<CameraController>().transform;
|
||||
}
|
||||
|
||||
public virtual void Shoot()
|
||||
{
|
||||
if (isReloading) return;
|
||||
|
||||
if (Time.time - lastShotTime < fireRate)
|
||||
return;
|
||||
|
||||
if (currentAmmo <= 0)
|
||||
{
|
||||
PlayEmptySound();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Time.time - lastShotTime < fireRate)
|
||||
return;
|
||||
|
||||
switch (fireMode)
|
||||
{
|
||||
case FireMode.SemiAutomatic:
|
||||
@@ -160,6 +165,9 @@ namespace Code.Gameplay.Weapons
|
||||
|
||||
protected virtual void PlayEmptySound()
|
||||
{
|
||||
if (Time.time - lastShotTryTime < fireRate)
|
||||
return;
|
||||
lastShotTryTime = Time.time;
|
||||
if (emptySound != null)
|
||||
audioSource.PlayOneShot(emptySound);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user