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

@@ -138,6 +138,7 @@ func cleared():
pass
func die():
SignalBus.emit_signal("player_exiting_tree")
#record stats
GameGlobals.money_penalty()
GameGlobals.weapon_penalty()
@@ -193,7 +194,7 @@ func pickup_spawn(randomized):
stamina_weight = 0
var money_weight
if money_drop_enabled:
money_weight = (1.0 - clamp(float(GameGlobals.money) / float(500),0,1)) + drop_chance_minimum #fix this logic later once the economy makes sense
money_weight = 1 + drop_chance_minimum #fix this logic later once the economy makes sense
else:
money_weight = 0
var ammo_weight

15
scripts/deposit_money.gd Normal file
View File

@@ -0,0 +1,15 @@
extends StaticBody3D
@onready var amount: Label3D = $Amount
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func interact():
SignalBus.emit_signal("money_deposited")

View File

@@ -1,8 +1,8 @@
extends Node
var game_loaded = false
var high_score = 0
var money = 0
var high_score : int = 0
var money : int = 0
var health
var held_guns = []
var current_gun_index
@@ -10,9 +10,9 @@ var gun_ammo = {}
var ammo_reserve = {}
func _ready() -> void:
SignalBus.money_changed.connect(money_update)
SignalBus.money_deposited.connect(deposit_money)
func money_update():
func deposit_money():
if money > high_score:
high_score = money

View File

@@ -3,6 +3,8 @@ extends Node
signal room_entered()
signal room_exited()
@export var one_way = false
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
add_to_group("room_check")
@@ -13,8 +15,9 @@ func _process(delta: float) -> void:
func _on_body_entered(body: Node3D) -> void:
if body.is_in_group("player"):
emit_signal("room_entered")
get_parent().room_entered()
func _on_body_exited(body: Node3D) -> void:
if body.is_in_group("player"):
emit_signal("room_exited")
if !one_way:
if body.is_in_group("player"):
get_parent().room_exited()

View File

@@ -8,10 +8,6 @@ extends Node
@export var special_key_name : String
@export_group("Item Drops")
@export var number_of_drops = 5
@export var ammo_drop_enabled = true
@export var stamina_drop_enabled = true
@export var health_drop_enabled = true
@export var money_drop_enabled = true
var enemies = []
var doors = []

View File

@@ -6,7 +6,7 @@ signal enemy_count_changed()
signal game_loaded()
##PLAYER
signal money_changed()
signal money_deposited()
signal player_exiting_tree()
signal player_hit()
signal shot_fired()

View File

@@ -16,7 +16,7 @@ func _ready() -> void:
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
gamemode.text = str(level_control.gamemode.gamemode_name)
high_score.text = str("HIGH SCORE : ",GameGlobals.high_score)
high_score.text = str("HIGH SCORE : $",GameGlobals.high_score)
kills.text = "Kills : " + str(SaveLoad.enemies_killed)
deaths.text = "Deaths : " + str(SaveLoad.player_deaths)
shots_fired.text = "Shots Fired : " + str(SaveLoad.shots_fired)

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()