title says all. must fix some audio related bugs, and fix the breathing mechanic, so that the character breathes even when not staying still, but the breathing should sync to the camera bobbing
65 lines
1.3 KiB
GDScript
65 lines
1.3 KiB
GDScript
extends Node
|
|
|
|
var walking: bool = false
|
|
var running: bool = false
|
|
var crouching: bool = false
|
|
var in_menu: bool = false
|
|
var breathing_mode = breath.calm
|
|
|
|
enum breath {
|
|
calm,
|
|
low,
|
|
mid,
|
|
heavy,
|
|
max,
|
|
exhausted
|
|
}
|
|
|
|
## 0 --> exhausted [br]
|
|
## 0 - 10 --> max [br]
|
|
## 10 -- 20 --> heavy [br]
|
|
## 20 -- 50 --> mid [br]
|
|
## 50 -- 80 --> low [br]
|
|
## 80 -- 100 --> calm
|
|
var _breath_change_points: Array[float] = [10, 20, 50, 80]
|
|
|
|
@onready var player_properties: Node = %PlayerProperties
|
|
|
|
func _process(_delta: float) -> void:
|
|
var stamina = player_properties.stamina
|
|
if stamina == 0:
|
|
breathing_mode = breath.exhausted
|
|
elif stamina <= _breath_change_points[0]:
|
|
breathing_mode = breath.max
|
|
elif stamina <= _breath_change_points[1]:
|
|
breathing_mode = breath.heavy
|
|
elif stamina <= _breath_change_points[2]:
|
|
breathing_mode = breath.mid
|
|
elif stamina <= _breath_change_points[3]:
|
|
breathing_mode = breath.low
|
|
else:
|
|
breathing_mode = breath.calm
|
|
|
|
func is_crouched(yes:bool):
|
|
if yes:
|
|
crouching = true
|
|
walking = false
|
|
running = false
|
|
else:
|
|
crouching = false
|
|
|
|
func is_walking(yes:bool):
|
|
if yes:
|
|
crouching = false
|
|
walking = true
|
|
running = false
|
|
else:
|
|
walking = false
|
|
|
|
func is_running(yes:bool):
|
|
if yes:
|
|
crouching = false
|
|
walking = false
|
|
running = true
|
|
else:
|
|
running = false
|