diff --git a/Cannon.gd b/Cannon.gd index a5ac436..56a55e5 100644 --- a/Cannon.gd +++ b/Cannon.gd @@ -17,15 +17,15 @@ func interact(): #TODO: RELOADING if currentStashValue < maxStashValue: currentState = STATE.RELOADING - currentStashValue = maxStashValue + ++currentStashValue return return func _on_signal_shooting(): - if currentStashValue == 1 and currentState == STATE.INACTIVE: + if currentStashValue >= 1 and currentState == STATE.INACTIVE: currentState = STATE.SHOOTING + --currentStashValue #TODO: SHOOTING currentState = STATE.INACTIVE - return diff --git a/Storage.gd b/Storage.gd index 3aba42d..840cc53 100644 --- a/Storage.gd +++ b/Storage.gd @@ -1,11 +1,23 @@ -extends "res://Module.gd" +extends Module +class_name Storage -# Called when the node enters the scene tree for the first time. +enum TYPE {AMMO, GUNPOWDER, FUEL} + +@export var currentType: TYPE + +#------------Methods-------------# func _ready(): - pass # Replace with function body. - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - pass + var root = get_tree().root.get_child(0) + root.shooting.connect(_on_signal_storing) + maxStashValue = 5 + currentStashValue = 0 +func interact(): + if currentStashValue >= 1: + --currentStashValue + return +func _on_signal_storing(): + if currentStashValue < maxStashValue: + ++currentStashValue + return + diff --git a/project.godot b/project.godot index 675ee97..401df3a 100644 --- a/project.godot +++ b/project.godot @@ -20,6 +20,11 @@ _global_script_classes=[{ "path": "res://Module.gd" }, { "base": "Module", +"class": &"Storage", +"language": &"GDScript", +"path": "res://Storage.gd" +}, { +"base": "Module", "class": &"TrainEngine", "language": &"GDScript", "path": "res://Engine.gd" @@ -27,6 +32,7 @@ _global_script_classes=[{ _global_script_class_icons={ "Cannon": "", "Module": "", +"Storage": "", "TrainEngine": "" }