HUD and prototype textures
This commit is contained in:
parent
37a17878e4
commit
03bc73e9ff
45 changed files with 742 additions and 26 deletions
5
scripts/gui/hud/player_ammo_display.gd
Normal file
5
scripts/gui/hud/player_ammo_display.gd
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
extends Label
|
||||
|
||||
|
||||
func on_ammo_updated(ammo: int, remaining_ammo: int):
|
||||
text = str(ammo)+"/"+str(remaining_ammo)
|
||||
1
scripts/gui/hud/player_ammo_display.gd.uid
Normal file
1
scripts/gui/hud/player_ammo_display.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://gan0amqbhi4i
|
||||
5
scripts/gui/hud/player_healthbar.gd
Normal file
5
scripts/gui/hud/player_healthbar.gd
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
extends ProgressBar
|
||||
|
||||
|
||||
func on_hp_changed(to: int):
|
||||
value = to
|
||||
1
scripts/gui/hud/player_healthbar.gd.uid
Normal file
1
scripts/gui/hud/player_healthbar.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://vmhlmhd6gjx6
|
||||
|
|
@ -9,6 +9,7 @@ func request_spawn(data: Variant) -> Node:
|
|||
return Node.new()
|
||||
var node = load(data.scene).instantiate()
|
||||
if data.has("impulse"):
|
||||
print()
|
||||
if data.has_all(["ammo","remaining_ammo","slot"]):
|
||||
node.weapon.ammo = data.ammo
|
||||
node.weapon.remaining_ammo = data.remaining_ammo
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ class_name Player
|
|||
@export var weapon_models: Dictionary[StringName,Node3D]
|
||||
|
||||
signal spawned
|
||||
signal health_changed(to: int)
|
||||
|
||||
const MAX_HP = 100
|
||||
|
||||
|
|
@ -15,6 +16,7 @@ const MAX_HP = 100
|
|||
hp = 0
|
||||
else:
|
||||
hp = value
|
||||
health_changed.emit(hp)
|
||||
if hp == 0:
|
||||
die()
|
||||
|
||||
|
|
|
|||
|
|
@ -11,4 +11,3 @@ func on_timeout():
|
|||
return
|
||||
|
||||
Session.kill_site(plant)
|
||||
print("boom")
|
||||
|
|
|
|||
|
|
@ -7,18 +7,19 @@ class_name WeaponSubStateMachine
|
|||
@export var visibility_target: StringName
|
||||
|
||||
@export var max_ammo: int
|
||||
@onready var ammo: int = max_ammo:
|
||||
@export var ammo: int:
|
||||
set(value):
|
||||
if value < 0:
|
||||
ammo = 0
|
||||
else:
|
||||
ammo = value
|
||||
ammo_updated.emit()
|
||||
if ammo <= 0 and remaining_ammo <= 0:
|
||||
ammo_depleted.emit()
|
||||
get:
|
||||
return ammo
|
||||
@export var ammo_mags: int = 3
|
||||
@onready var remaining_ammo: int = max_ammo * ammo_mags:
|
||||
@export var remaining_ammo: int:
|
||||
set(value):
|
||||
if value < 0:
|
||||
remaining_ammo = 0
|
||||
|
|
@ -32,14 +33,17 @@ class_name WeaponSubStateMachine
|
|||
@export var slot: StringName
|
||||
|
||||
signal request_return
|
||||
signal ammo_updated
|
||||
signal ammo_depleted
|
||||
|
||||
var system: WeaponSystem
|
||||
var animation_player: AnimationPlayer
|
||||
var player_camera: PlayerCamera
|
||||
var player: Player
|
||||
var player: Player
|
||||
|
||||
func _ready() -> void:
|
||||
remaining_ammo = max_ammo * ammo_mags
|
||||
ammo = max_ammo
|
||||
for child in get_children():
|
||||
if child is WeaponState:
|
||||
states[child.name] = child
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ var slots: Dictionary[StringName,WeaponSubStateMachine] = {
|
|||
}
|
||||
|
||||
signal switched_to(state: WeaponSubStateMachine)
|
||||
signal slots_updated(slots: Dictionary[StringName,WeaponSubStateMachine])
|
||||
signal ammo_updated(ammo: int, remaining_ammo: int)
|
||||
|
||||
func _ready() -> void:
|
||||
$WeaponSpawner.spawn_function = pick_up_weapon
|
||||
|
|
@ -53,9 +55,12 @@ func add(state: WeaponSubStateMachine, slot: StringName,ignore_parent: bool = fa
|
|||
state.player = player
|
||||
state.request_return.connect(return_to_previous)
|
||||
state.ammo_depleted.connect(check_for_empty)
|
||||
state.ammo_updated.connect(on_ammo_updated)
|
||||
slots_updated.emit(slots)
|
||||
|
||||
if current_state == null:
|
||||
current_state = state
|
||||
ammo_updated.emit(current_state.ammo,current_state.remaining_ammo)
|
||||
state.enter.call_deferred()
|
||||
|
||||
func switch(to: StringName, exit: bool = true):
|
||||
|
|
@ -70,6 +75,7 @@ func switch(to: StringName, exit: bool = true):
|
|||
current_state = slots[to]
|
||||
current_state.enter()
|
||||
|
||||
ammo_updated.emit(current_state.ammo,current_state.remaining_ammo)
|
||||
switched_to.emit(current_state)
|
||||
|
||||
update_remotes.rpc(to,exit)
|
||||
|
|
@ -105,6 +111,7 @@ func drop():
|
|||
$"../PickupRange".start_temp_ignore()
|
||||
|
||||
slots[slots.find_key(current_state)] = null
|
||||
slots_updated.emit(slots)
|
||||
current_state.queue_free()
|
||||
return_to_previous(false)
|
||||
|
||||
|
|
@ -141,6 +148,9 @@ func check_for_empty() -> void:
|
|||
if child is WeaponSubStateMachine and child.ammo == 0 and child.remaining_ammo == 0 and child.destroy_when_empty:
|
||||
child.queue_free()
|
||||
|
||||
func on_ammo_updated() -> void:
|
||||
ammo_updated.emit(current_state.ammo,current_state.remaining_ammo)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if current_state == null:
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue