working with level changes and money deposits

This commit is contained in:
Derek
2025-02-23 14:17:36 -06:00
parent 3ee1f261d1
commit fd2a32dde9
16 changed files with 178 additions and 68 deletions

View File

@@ -93,12 +93,12 @@ func _process(_delta):
func reload_finished():
if player.ammo_reserve[str(ammo_type)] >= max_ammo:
player.gun_ammo[gun_name] += max_ammo
player.ammo_reserve[str(ammo_type)] -= max_ammo
if GameGlobals.ammo_reserve[str(ammo_type)] >= max_ammo:
GameGlobals.gun_ammo[gun_name] += max_ammo
GameGlobals.ammo_reserve[str(ammo_type)] -= max_ammo
else:
player.gun_ammo[gun_name] += player.ammo_reserve[str(ammo_type)]
player.ammo_reserve[str(ammo_type)] -= player.ammo_reserve[str(ammo_type)]
GameGlobals.gun_ammo[gun_name] += GameGlobals.ammo_reserve[str(ammo_type)]
GameGlobals.ammo_reserve[str(ammo_type)] -= GameGlobals.ammo_reserve[str(ammo_type)]
func shoot(delta):
if !anim_player.is_playing():
@@ -111,9 +111,9 @@ func shoot(delta):
func fire():
if player.gun_ammo[gun_name] > 0 and cycle_count > 0:
if GameGlobals.gun_ammo[gun_name] > 0 and cycle_count > 0:
if !anim_player.is_playing():
player.gun_ammo[gun_name] -= 1
GameGlobals.gun_ammo[gun_name] -= 1
#audio and anims
audio_fire.pitch_scale = 1 + rng.randf_range(-fire_pitch_scale_amt,fire_pitch_scale_amt)
audio_fire.play()
@@ -161,7 +161,7 @@ func remove_tracker():
tracker = null
func check_ammo():
if player.gun_ammo[gun_name] == 0 and player.ammo_reserve[str(ammo_type)] > 0:
if GameGlobals.gun_ammo[gun_name] == 0 and GameGlobals.ammo_reserve[str(ammo_type)] > 0:
anim_player.play("reload")
audio_reload.play()
@@ -169,15 +169,15 @@ func reload():
if tracker != null:
anim_player.play("remove_tracker")
else:
if player.gun_ammo[gun_name] < max_ammo and player.gun.anim_player.get_current_animation() != "reload" and player.ammo_reserve[str(ammo_type)] > 0:
if GameGlobals.gun_ammo[gun_name] < max_ammo and player.gun.anim_player.get_current_animation() != "reload" and GameGlobals.ammo_reserve[str(ammo_type)] > 0:
anim_player.play("reload")
audio_reload.play()
remove_tracker()
if anim_player.is_playing() and anim_player.current_animation == "reload":
if player.gun_ammo[gun_name] == 0:
player.gun_ammo[gun_name] = 0
if GameGlobals.gun_ammo[gun_name] == 0:
GameGlobals.gun_ammo[gun_name] = 0
else:
player.gun_ammo[gun_name] = 1
GameGlobals.gun_ammo[gun_name] = 1
func spawn_mag():
var instance_mag = mag.instantiate()