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

@@ -7,9 +7,9 @@ script = ExtResource("1_bpthy")
gamemode_name = "HUB" gamemode_name = "HUB"
win_conditions = null win_conditions = null
survival_time = 160.0 survival_time = 160.0
money_lost_multiplier = 0.5 money_lost_multiplier = 1.0
weapon_penalty = 0 weapon_penalty = 2
weapon_drop_percentage = 0.5 weapon_drop_percentage = 0.0
walk_speed = 12.0 walk_speed = 12.0
jump_velocity = 5 jump_velocity = 5
dash_speed = 40 dash_speed = 40
@@ -20,7 +20,7 @@ max_stamina = 100.0
stamina_drain = 20.0 stamina_drain = 20.0
air_dash_max = 1 air_dash_max = 1
load_save = false load_save = false
money_drop_multiplier = 1.0 money_multiplier = 1.0
start_health = 10 start_health = 10
drop_chance_minimum = 0.1 drop_chance_minimum = 0.1
random_drops = false random_drops = false

View File

@@ -20,7 +20,7 @@ max_stamina = 100.0
stamina_drain = 20.0 stamina_drain = 20.0
air_dash_max = 1 air_dash_max = 1
load_save = false load_save = false
money_drop_multiplier = 1.0 money_multiplier = 1.0
start_health = 10 start_health = 10
drop_chance_minimum = 0.1 drop_chance_minimum = 0.1
random_drops = false random_drops = false

31
assets/deposit_money.tscn Normal file
View File

@@ -0,0 +1,31 @@
[gd_scene load_steps=5 format=3 uid="uid://bvjrsc86n2ak0"]
[ext_resource type="Script" path="res://scripts/deposit_money.gd" id="1_b77vt"]
[ext_resource type="FontFile" uid="uid://d2h2tjhxiv5wo" path="res://assets/fonts/White On Black.ttf" id="1_bjyml"]
[sub_resource type="BoxShape3D" id="BoxShape3D_8clsv"]
[sub_resource type="BoxMesh" id="BoxMesh_6sj7f"]
[node name="DEPOSIT MONEY" type="StaticBody3D"]
collision_layer = 3
collision_mask = 3
script = ExtResource("1_b77vt")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("BoxShape3D_8clsv")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
mesh = SubResource("BoxMesh_6sj7f")
[node name="Deposit Money" type="Label3D" parent="."]
transform = Transform3D(0.7, 0, 0, 0, 0.7, 0, 0, 0, 0.7, 0.143, 1.207, 0)
text = "Deposit Money"
font = ExtResource("1_bjyml")
font_size = 100
[node name="Amount" type="Label3D" parent="."]
transform = Transform3D(0.7, 0, 0, 0, 0.7, 0, 0, 0, 0.7, 0.142793, 0.747273, 0)
text = "Test"
font = ExtResource("1_bjyml")
font_size = 100

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=11 format=3 uid="uid://jdwpc622vmok"] [gd_scene load_steps=12 format=3 uid="uid://jdwpc622vmok"]
[ext_resource type="Script" path="res://scripts/LevelManager.gd" id="1_1bnbi"] [ext_resource type="Script" path="res://scripts/LevelManager.gd" id="1_1bnbi"]
[ext_resource type="Resource" uid="uid://bxcxqt7rmfvdw" path="res://GameModes/hubworld.tres" id="2_62iy8"] [ext_resource type="Resource" uid="uid://bxcxqt7rmfvdw" path="res://GameModes/hubworld.tres" id="2_62iy8"]
@@ -7,6 +7,7 @@
[ext_resource type="PackedScene" uid="uid://dgapcuvg0gtmm" path="res://assets/scene_changer.tscn" id="5_alya6"] [ext_resource type="PackedScene" uid="uid://dgapcuvg0gtmm" path="res://assets/scene_changer.tscn" id="5_alya6"]
[ext_resource type="PackedScene" uid="uid://bessq6hl7qsh8" path="res://assets/stats.tscn" id="6_mkn70"] [ext_resource type="PackedScene" uid="uid://bessq6hl7qsh8" path="res://assets/stats.tscn" id="6_mkn70"]
[ext_resource type="PackedScene" uid="uid://bj1y0fbjtul4a" path="res://post_processing.tscn" id="7_2h1ea"] [ext_resource type="PackedScene" uid="uid://bj1y0fbjtul4a" path="res://post_processing.tscn" id="7_2h1ea"]
[ext_resource type="PackedScene" uid="uid://bvjrsc86n2ak0" path="res://assets/deposit_money.tscn" id="8_n0nhe"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_s7e4t"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_s7e4t"]
sky_top_color = Color(0.623488, 0.812575, 0.900791, 1) sky_top_color = Color(0.623488, 0.812575, 0.900791, 1)
@@ -23,7 +24,7 @@ sky = SubResource("Sky_kdw67")
tonemap_mode = 2 tonemap_mode = 2
glow_enabled = true glow_enabled = true
fog_enabled = true fog_enabled = true
fog_density = 0.0015 fog_density = 0.0001
[node name="HUB_1" type="Node3D" groups=["hub_level"]] [node name="HUB_1" type="Node3D" groups=["hub_level"]]
script = ExtResource("1_1bnbi") script = ExtResource("1_1bnbi")
@@ -83,3 +84,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.212402, 1.9891, -6.02898)
[node name="PostProcessing" parent="." instance=ExtResource("7_2h1ea")] [node name="PostProcessing" parent="." instance=ExtResource("7_2h1ea")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.84741, 0.0564995, -2.31308) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.84741, 0.0564995, -2.31308)
[node name="DEPOSIT MONEY" parent="." instance=ExtResource("8_n0nhe")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.24039, 0.888024, -4.81185)

File diff suppressed because one or more lines are too long

View File

@@ -138,6 +138,7 @@ func cleared():
pass pass
func die(): func die():
SignalBus.emit_signal("player_exiting_tree")
#record stats #record stats
GameGlobals.money_penalty() GameGlobals.money_penalty()
GameGlobals.weapon_penalty() GameGlobals.weapon_penalty()
@@ -193,7 +194,7 @@ func pickup_spawn(randomized):
stamina_weight = 0 stamina_weight = 0
var money_weight var money_weight
if money_drop_enabled: 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: else:
money_weight = 0 money_weight = 0
var ammo_weight 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 extends Node
var game_loaded = false var game_loaded = false
var high_score = 0 var high_score : int = 0
var money = 0 var money : int = 0
var health var health
var held_guns = [] var held_guns = []
var current_gun_index var current_gun_index
@@ -10,9 +10,9 @@ var gun_ammo = {}
var ammo_reserve = {} var ammo_reserve = {}
func _ready() -> void: 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: if money > high_score:
high_score = money high_score = money

View File

@@ -3,6 +3,8 @@ extends Node
signal room_entered() signal room_entered()
signal room_exited() signal room_exited()
@export var one_way = false
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready() -> void: func _ready() -> void:
add_to_group("room_check") add_to_group("room_check")
@@ -13,8 +15,9 @@ func _process(delta: float) -> void:
func _on_body_entered(body: Node3D) -> void: func _on_body_entered(body: Node3D) -> void:
if body.is_in_group("player"): if body.is_in_group("player"):
emit_signal("room_entered") get_parent().room_entered()
func _on_body_exited(body: Node3D) -> void: func _on_body_exited(body: Node3D) -> void:
if body.is_in_group("player"): if !one_way:
emit_signal("room_exited") 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 var special_key_name : String
@export_group("Item Drops") @export_group("Item Drops")
@export var number_of_drops = 5 @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 enemies = []
var doors = [] var doors = []

View File

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

View File

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

View File

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