diff --git a/Cannon.gd b/Cannon.gd new file mode 100644 index 0000000..56a55e5 --- /dev/null +++ b/Cannon.gd @@ -0,0 +1,31 @@ +extends Module + +class_name Cannon + +enum STATE {INACTIVE, RELOADING, SHOOTING} + +#------------Methods-------------# +func _ready(): + var root = get_tree().root.get_child(0) + root.shooting.connect(_on_signal_shooting) + maxStashValue = 1 + currentStashValue = 0 + currentState = STATE.INACTIVE +#TODO: FINISH +func interact(): + if currentState == STATE.INACTIVE: + #TODO: RELOADING + if currentStashValue < maxStashValue: + currentState = STATE.RELOADING + ++currentStashValue + return + + return + +func _on_signal_shooting(): + if currentStashValue >= 1 and currentState == STATE.INACTIVE: + currentState = STATE.SHOOTING + --currentStashValue + #TODO: SHOOTING + currentState = STATE.INACTIVE + return diff --git a/Engine.gd b/Engine.gd new file mode 100644 index 0000000..760d79e --- /dev/null +++ b/Engine.gd @@ -0,0 +1,26 @@ +extends Module +class_name TrainEngine + + +enum STATE {RUNNING, DEAD} + +#------------Methods-------------# +func _ready(): + var root = get_tree().root.get_child(0) + maxStashValue = 100 + currentStashValue = 100 + currentState = STATE.RUNNING +#TODO: FINISH +func interact(): + if currentState == STATE.RUNNING: + if currentStashValue < maxStashValue: + currentStashValue += 10 + if currentStashValue > maxStashValue: + currentStashValue = maxStashValue + + return + #TODO: Repair Train + currentState = STATE.RUNNING + + + diff --git a/Module.gd b/Module.gd new file mode 100644 index 0000000..ca86d7d --- /dev/null +++ b/Module.gd @@ -0,0 +1,47 @@ +extends Node + +class_name Module +#-----------Parameters----------------' +var currentStashValue = 0 : set = _set_currentStashValue, get = _get_currentStashValue + +var maxStashValue = 0 : set = _set_maxStashValue, get = _get_maxStashValue + +var currentState = null : set = _set_state, get = _get_state + +var level = 0 : set = _set_level, get = _get_level + + + + +enum MODULE_TYPE {CANNON, STEERING, ENGINE, STORAGE} + + + +#------------Methods-------------# + + +func interact(): + pass + + +func _ready(): + var root = get_tree().root.get_child(0) + + +#-----------Setter and Getter---------------# +func _set_currentStashValue(newValue): + currentStashValue = newValue +func _get_currentStashValue(): + return currentStashValue +func _set_maxStashValue(newValue): + currentStashValue = newValue +func _get_maxStashValue(): + return currentStashValue +func _set_level(newValue): + level = newValue +func _get_level(): + return level +func _set_state(newValue): + currentState = newValue +func _get_state(): + return currentState diff --git a/Module.tscn b/Module.tscn new file mode 100644 index 0000000..ac2c192 --- /dev/null +++ b/Module.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://b87b68ghm4dkk"] + +[ext_resource type="Script" path="res://Module.gd" id="1_42v8k"] + +[node name="Node" type="Node"] +script = ExtResource("1_42v8k") diff --git a/Storage.gd b/Storage.gd new file mode 100644 index 0000000..840cc53 --- /dev/null +++ b/Storage.gd @@ -0,0 +1,23 @@ +extends Module + +class_name Storage + +enum TYPE {AMMO, GUNPOWDER, FUEL} + +@export var currentType: TYPE + +#------------Methods-------------# +func _ready(): + 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/cannon.tscn b/cannon.tscn new file mode 100644 index 0000000..4c528ea --- /dev/null +++ b/cannon.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://d2g0of2prwwj4"] + +[ext_resource type="Script" path="res://Cannon.gd" id="1_mopo1"] + +[node name="Cannon" type="Node"] +script = ExtResource("1_mopo1") diff --git a/project.godot b/project.godot index 40c705b..401df3a 100644 --- a/project.godot +++ b/project.godot @@ -8,6 +8,34 @@ config_version=5 +_global_script_classes=[{ +"base": "Module", +"class": &"Cannon", +"language": &"GDScript", +"path": "res://Cannon.gd" +}, { +"base": "Node", +"class": &"Module", +"language": &"GDScript", +"path": "res://Module.gd" +}, { +"base": "Module", +"class": &"Storage", +"language": &"GDScript", +"path": "res://Storage.gd" +}, { +"base": "Module", +"class": &"TrainEngine", +"language": &"GDScript", +"path": "res://Engine.gd" +}] +_global_script_class_icons={ +"Cannon": "", +"Module": "", +"Storage": "", +"TrainEngine": "" +} + [application] config/name="Semester Game Jam 2022"