@@ -92,7 +92,7 @@ class Player {
|
||||
if (currentWeapon.state != WeaponState.idle) return;
|
||||
if (weaponType == currentWeapon.type) return;
|
||||
if (!weapons.containsKey(weaponType)) return;
|
||||
if (weaponType == WeaponType.knife && ammo <= 0) return;
|
||||
if (weaponType != WeaponType.knife && ammo <= 0) return;
|
||||
|
||||
pendingWeaponType = weaponType;
|
||||
switchState = WeaponSwitchState.lowering;
|
||||
@@ -162,6 +162,7 @@ class Player {
|
||||
break;
|
||||
|
||||
case CollectibleType.weapon:
|
||||
addAmmo(8);
|
||||
if (item.mapId == 50) {
|
||||
// Machine Gun Pickup
|
||||
if (weapons[WeaponType.machineGun] == null) {
|
||||
@@ -195,13 +196,14 @@ class Player {
|
||||
void fire(int currentTime) {
|
||||
if (switchState != WeaponSwitchState.idle) return;
|
||||
|
||||
bool shotFired = currentWeapon.fire(currentTime, currentAmmo: ammo);
|
||||
// Check currentWeapon.type
|
||||
// We pass the isFiring state to handle automatic vs semi-auto behavior
|
||||
bool shotFired = currentWeapon.fire(
|
||||
currentTime,
|
||||
currentAmmo: ammo,
|
||||
);
|
||||
|
||||
if (shotFired && currentWeapon.type != WeaponType.knife) {
|
||||
ammo--;
|
||||
if (ammo <= 0) {
|
||||
requestWeaponSwitch(WeaponType.knife);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,5 +256,11 @@ class Player {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
if (currentWeapon.state == WeaponState.idle &&
|
||||
ammo <= 0 &&
|
||||
currentWeapon.type != WeaponType.knife) {
|
||||
requestWeaponSwitch(WeaponType.knife);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user