extends Node func _ready() -> void: #Health ready #on ready it sets the current health to the max health currenthealth = maxHealth #================================================COIN=============================================== #the coin amount the player has static var totalCoinAmount: int #signal for the UI signal on_coin_amount_recevied func give_pickup_award(coinAmount: int) -> void: #add the award amount to the total amount totalCoinAmount += coinAmount #emist the siganl so the UI updates on_coin_amount_recevied.emit(totalCoinAmount) #================================================AMMO=============================================== static var ammo: int = 30 signal on_ammo_update func decrease_ammo(ammoAmount: int) -> void: ammo -= ammoAmount on_ammo_update.emit(ammo) func add_ammo(ammoAmount: int) -> void: ammo += ammoAmount on_ammo_update.emit(ammo) #===============================================HEALTH============================================== var maxHealth: int = 100 var currenthealth: int #signal signal on_health_changed(newHealth) signal on_max_health_changed(newMaxHealth) func decress_health(healthAmount: int) -> void: #decreases the current health y the health amount currenthealth -= healthAmount #clamps the current health so it dosen't go under 0s currenthealth = clampi(currenthealth, 0, maxHealth) #emmits the health change signal on_health_changed.emit(currenthealth) func increase_health(healthAmount: int) -> void: #add the amount of health to the current healt currenthealth += healthAmount #clamps the current health so it doesn't go over max health currenthealth = clampi(currenthealth, 0, maxHealth) #emits the health change signal on_health_changed.emit(currenthealth) func increase_max_health(healthAmount: int) -> void: maxHealth += healthAmount on_max_health_changed.emit(maxHealth) func decress_max_health(healthAmount: int) -> void: maxHealth -= healthAmount on_max_health_changed.emit(maxHealth) #=============================================INVENTORY============================================= var invetory: Dictionary func add_to_inventory(type: String, value: String) -> void: invetory[type] = value func has_inventory_item(value: String) -> bool: if value == null: return false var item = invetory.find_key(value) if item: return true return false #==============================================WEAPONS============================================== var currentFirstWeapon: String = "fist" var currentSecondWeapon: String = "fist" var currentFirstWeaponIndex: int = 0 var currentSecondWeaponIndex: int = 0 func change_weapon(weaponKey: String, slot: String) -> void: match slot: "first": #primary currentFirstWeapon = weaponKey "second": #secondary currentSecondWeapon = weaponKey