Files
fps_project_1/scripts/game_globals.gd

41 lines
929 B
GDScript

extends Node
var game_loaded = false
var high_score = 0
var money = 0
var health
var held_guns = []
var current_gun_index
var gun_ammo = {}
var ammo_reserve = {}
func _ready() -> void:
SignalBus.money_changed.connect(money_update)
func money_update():
if money > high_score:
high_score = money
func money_penalty():
var level_control = get_tree().current_scene
#Save High Scores
if money >= high_score:
high_score = money
#Do money penalty
money = money * level_control.gamemode.money_lost_multiplier
func weapon_penalty():
var level_control = get_tree().current_scene
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