Engine.gd Speed dependencies

This commit is contained in:
Arthur
2022-12-10 12:16:04 +01:00
parent 64197ae3c9
commit fbb96edc50
4 changed files with 16 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=9 format=3 uid="uid://n7w0ff7u25yc"]
[gd_scene load_steps=9 format=3 uid="uid://cp2itfdd21cg2"]
[ext_resource type="Script" path="res://scripts/Logic/Game.gd" id="1_iox18"]
[ext_resource type="PackedScene" uid="uid://bqe8ucbruto1j" path="res://Nodes/StartNode.tscn" id="2_61aog"]
@@ -48,7 +48,6 @@ transform = Transform3D(0.999998, 0, 0, 0, 1, 0, 0, 0, 0.999998, 12, 0, 0)
script = ExtResource("2_xl0he")
[node name="MeshInstance3D" type="MeshInstance3D" parent="Player2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
mesh = SubResource("BoxMesh_ognqx")
[node name="StaticBody3D" type="StaticBody3D" parent="Player2/MeshInstance3D"]

View File

@@ -23,7 +23,6 @@ func interact():
currentState = STATE.RELOADING
currentStashValue += 1
return
return
func shoot():

View File

@@ -3,6 +3,10 @@ class_name TrainEngine
enum STATE {RUNNING, DEAD}
const maxSpeed = 6
const refuelRate = 0.5
@onready var train = get_parent() as Train
#------------Methods-------------#
func _ready():
@@ -13,13 +17,17 @@ func _ready():
#TODO: FINISH
func interact():
if currentState == STATE.RUNNING:
if currentStashValue < maxStashValue:
currentStashValue += 10
if currentStashValue > maxStashValue:
currentStashValue = maxStashValue
if (train.current_speed + refuelRate) <= maxSpeed:
train.current_speed += refuelRate
if train.current_speed >= maxSpeed:
train.current_speed = maxSpeed
return
#TODO: Repair Train
currentState = STATE.RUNNING
#
func _process(delta):
if not train.is_dead():
train.current_speed -= 0.1 * delta

View File

@@ -30,4 +30,5 @@ func _on_signal_shooting():
func is_dead():
if current_speed <= 0:
game_over.emit()
return true
return false