fixed hud, moved weapon and ammo penalties to gamemode

This commit is contained in:
derek
2025-03-18 10:16:09 -05:00
parent d17bc56ca2
commit 891ae8a7f2
10 changed files with 79 additions and 42 deletions

View File

@@ -163,8 +163,8 @@ func cleared():
func die():
SignalBus.emit_signal("player_exiting_tree")
#record stats
GameGlobals.money_penalty()
GameGlobals.weapon_penalty()
gamemode.apply_money_penalty()
gamemode.apply_weapon_penalty()
if GameGlobals.player_deaths:
GameGlobals.player_deaths += 1
SaveLoad.save_user_data()

View File

@@ -43,23 +43,3 @@ func deposit_money():
func _process(delta: float) -> void:
pass
#print("current level : ",get_tree().current_scene.scene_file_path)
func money_penalty():
var level_control = get_tree().current_scene
#Do money penalty
money = money * level_control.gamemode.money_lost_multiplier
deposited_money = money
func weapon_penalty():
var level_control = get_tree().current_scene
GameGlobals.ammo_reserve = {}
match level_control.gamemode.weapon_penalty:
0: #Drop All
GameGlobals.held_guns = []
1: #Drop Percentage
var weapons_lost = GameGlobals.held_guns.size() * level_control.gamemode.weapon_drop_percentage
for weapon in weapons_lost:
GameGlobals.held_guns.erase(GameGlobals.held_guns.pick_random())
2: #Do Nothing
pass

View File

@@ -42,6 +42,8 @@ const CROSSHAIR_SIZE = Vector2(40,40)
var pickup_notifs = []
var can_spawn = true
var dir_clamped = Vector2.ZERO
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
# Get Viewport size
@@ -227,16 +229,21 @@ func player_hit():
func hud_wobble(delta):
var viewport_height_adj = (get_viewport().size.y/1080)
var HUD_WOBBLE_MAX : float = 40 * viewport_height_adj
var MOUSE_AMT = 10 * viewport_height_adj
var HUD_WOBBLE_MAX : float = 4 * viewport_height_adj
var MOUSE_AMT = 1 * viewport_height_adj
var VELOCITY_AMT = 100 * viewport_height_adj
var HUD_SPEED = 10 * viewport_height_adj
var HUD_MOVE_SPEED = 1 * viewport_height_adj
var HUD_RETURN_SPEED = 10 * viewport_height_adj
var dir_mouse = Vector2(-player.mouse_input.x * MOUSE_AMT,-player.mouse_input.y * MOUSE_AMT)
var velocity_dir_transformed = player.velocity.normalized() * player.global_basis
var velocity_lengh_clamped = clamp(player.velocity.length(),-VELOCITY_AMT,VELOCITY_AMT)
var dir_velocity = Vector2(-velocity_dir_transformed.x * velocity_lengh_clamped,velocity_dir_transformed.y * velocity_lengh_clamped)
var dir_clamped = clamp(dir_mouse + dir_velocity,Vector2(-HUD_WOBBLE_MAX,-HUD_WOBBLE_MAX),Vector2(HUD_WOBBLE_MAX,HUD_WOBBLE_MAX))
var offset = lerp(position, dir_clamped, delta * HUD_SPEED)
return offset
#add movement
dir_clamped += clamp(dir_mouse + dir_velocity,Vector2(-HUD_WOBBLE_MAX,-HUD_WOBBLE_MAX),Vector2(HUD_WOBBLE_MAX,HUD_WOBBLE_MAX))
#return to zero over time
dir_clamped = lerp(dir_clamped,Vector2.ZERO,delta * HUD_RETURN_SPEED)
#apply offset
return dir_clamped

View File

@@ -1,4 +1,5 @@
extends Node
class_name SwitchBasic
@export var switch_override : bool = false
@export var start_on : bool = false