diff --git a/scripts/Modules/Cannon.gd b/scripts/Modules/Cannon.gd index 8711c12..704b3ae 100644 --- a/scripts/Modules/Cannon.gd +++ b/scripts/Modules/Cannon.gd @@ -3,7 +3,8 @@ extends Module class_name Cannon enum STATE {INACTIVE, RELOADING, SHOOTING} - +enum AMMO {NORMAL, HEAVY, LIGHT} +var currentAmmo: AMMO var CAN_ENGAGE = true var DAMAGE = 5 @onready var train = get_parent() as Train @@ -15,13 +16,13 @@ func _ready(): currentState = STATE.INACTIVE #TODO: FINISH func interact(): + if currentState == STATE.INACTIVE: #TODO: RELOADING if currentStashValue < maxStashValue: currentState = STATE.RELOADING currentStashValue += 1 return - return func shoot(): diff --git a/scripts/Modules/Engine.gd b/scripts/Modules/Engine.gd index 58ac3e6..4969c82 100644 --- a/scripts/Modules/Engine.gd +++ b/scripts/Modules/Engine.gd @@ -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 - diff --git a/scripts/Train.gd b/scripts/Train.gd index 6c64b3d..c0228a5 100644 --- a/scripts/Train.gd +++ b/scripts/Train.gd @@ -31,4 +31,5 @@ func _on_signal_shooting(): func is_dead(): if current_speed <= 0: game_over.emit() - + return true + return false