Merge remote-tracking branch 'refs/remotes/origin/main'
This commit is contained in:
commit
1566354cc6
|
|
@ -10,7 +10,12 @@ const STAMINA_COST = 15
|
|||
const STAMINA_RECOVER = 10
|
||||
|
||||
var pedestrian_area_count = 0
|
||||
var stamina: float = BASE_STAMINA
|
||||
|
||||
var max_stamina: float = BASE_STAMINA
|
||||
var stamina: float = max_stamina
|
||||
|
||||
func _ready() -> void:
|
||||
$Upgrades.update()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
$StaminaLabel.text = str(int(stamina))
|
||||
|
|
@ -25,7 +30,7 @@ func _process(delta: float) -> void:
|
|||
if Input.is_action_pressed("player_sprint") and stamina > 0:
|
||||
stamina -= STAMINA_COST * delta
|
||||
speed *= SPRINT_MULT
|
||||
elif stamina <= BASE_STAMINA:
|
||||
elif stamina <= max_stamina:
|
||||
stamina += STAMINA_RECOVER * delta
|
||||
|
||||
self.velocity = Vector3(dir.x * speed, 0, dir.y * speed)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
[gd_scene format=3 uid="uid://cmb3b7xrlboy3"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bobw4cfg1v6gj" path="res://player.gd" id="1_4flbx"]
|
||||
[ext_resource type="PackedScene" uid="uid://ct7cc7qg3hpu1" path="res://upgrades.tscn" id="2_onrkg"]
|
||||
|
||||
[sub_resource type="PlaneMesh" id="PlaneMesh_sh265"]
|
||||
size = Vector2(1, 1)
|
||||
|
|
@ -29,6 +30,8 @@ collision_layer = 4
|
|||
collision_mask = 3
|
||||
script = ExtResource("1_4flbx")
|
||||
|
||||
[node name="Upgrades" parent="." unique_id=1238785974 instance=ExtResource("2_onrkg")]
|
||||
|
||||
[node name="Mesh" type="MeshInstance3D" parent="." unique_id=1740724392]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, 0)
|
||||
mesh = SubResource("PlaneMesh_sh265")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
extends Node
|
||||
|
||||
var enabled: bool = true
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func update() -> void:
|
||||
if enabled:
|
||||
print("Updating Stamina")
|
||||
$"..".parent.max_stamina = $"..".parent.BASE_STAMINA * 2
|
||||
$"..".parent.stamina = $"..".parent.max_stamina
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://dk6j6kddvr2jc
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
extends Node
|
||||
|
||||
var parent: CharacterBody3D
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
assert(get_parent().name == "Player", "Upgrade must have player as parent")
|
||||
parent = get_parent()
|
||||
|
||||
## Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta: float) -> void:
|
||||
#pass
|
||||
|
||||
func update() -> void:
|
||||
var upgrades: Array = get_children()
|
||||
print("Updating all upgrades...")
|
||||
for upgrade in upgrades:
|
||||
upgrade.update()
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://4f7orky5jeey
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
[gd_scene format=3 uid="uid://ct7cc7qg3hpu1"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://4f7orky5jeey" path="res://upgrades.gd" id="1_k80ou"]
|
||||
[ext_resource type="Script" uid="uid://dk6j6kddvr2jc" path="res://stamina.gd" id="2_alr6r"]
|
||||
|
||||
[node name="Upgrades" type="Node" unique_id=1238785974]
|
||||
script = ExtResource("1_k80ou")
|
||||
|
||||
[node name="Stamina" type="Node" parent="." unique_id=1030985851]
|
||||
script = ExtResource("2_alr6r")
|
||||
Loading…
Reference in New Issue