From 1878cf26b21638f3ac1bc56f1cf39a3668f2cf95 Mon Sep 17 00:00:00 2001 From: PfandBoss <68470553+PfandBoss@users.noreply.github.com> Date: Fri, 9 Dec 2022 23:39:45 +0100 Subject: [PATCH 01/11] Modul Oberklasse geadded --- Module.gd | 42 ++++++++++++++++++++++++++++++++++++++++++ Module.tscn | 6 ++++++ 2 files changed, 48 insertions(+) create mode 100644 Module.gd create mode 100644 Module.tscn diff --git a/Module.gd b/Module.gd new file mode 100644 index 0000000..6f4a51b --- /dev/null +++ b/Module.gd @@ -0,0 +1,42 @@ +extends Node + +#-----------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 + + + + +#-----------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") From 83cb61e5451cea9275d493e670e1ec95c3b8b4d6 Mon Sep 17 00:00:00 2001 From: PfandBoss <68470553+PfandBoss@users.noreply.github.com> Date: Sat, 10 Dec 2022 00:22:54 +0100 Subject: [PATCH 02/11] Added Cannon Module --- Cannon.gd | 11 +++++++++++ Module.gd | 1 + project.godot | 16 ++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 Cannon.gd diff --git a/Cannon.gd b/Cannon.gd new file mode 100644 index 0000000..841fef3 --- /dev/null +++ b/Cannon.gd @@ -0,0 +1,11 @@ +extends Module + +class_name Cannon + + + +#------------Methods-------------# + +#TODO: FINISH +func interact(): + pass diff --git a/Module.gd b/Module.gd index 6f4a51b..2867d47 100644 --- a/Module.gd +++ b/Module.gd @@ -1,5 +1,6 @@ extends Node +class_name Module #-----------Parameters----------------' var currentStashValue = 0 : set = _set_currentStashValue, get = _get_currentStashValue diff --git a/project.godot b/project.godot index 40c705b..e993081 100644 --- a/project.godot +++ b/project.godot @@ -8,6 +8,22 @@ 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" +}] +_global_script_class_icons={ +"Cannon": "", +"Module": "" +} + [application] config/name="Semester Game Jam 2022" From f9839eb6fb1f922fd8207b32cb5873af07b8e191 Mon Sep 17 00:00:00 2001 From: PfandBoss <68470553+PfandBoss@users.noreply.github.com> Date: Sat, 10 Dec 2022 01:11:36 +0100 Subject: [PATCH 03/11] Blub --- Cannon.gd | 19 ++++++++++++++++--- Module.gd | 6 +++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Cannon.gd b/Cannon.gd index 841fef3..da77fe3 100644 --- a/Cannon.gd +++ b/Cannon.gd @@ -2,10 +2,23 @@ extends Module class_name Cannon - - +enum STATE {INACTIVE, RELOADING, SHOOTING} #------------Methods-------------# - +func _ready(): + var root = get_tree().root.get_child(0) + root.timeout.connect("shooting",self,"_on_signal_shooting") + maxStashValue = 1 + currentStashValue = 0 + currentState = STATE.INAKTIVE #TODO: FINISH func interact(): + if currentState == STATE.INACTIVE: + if currentStashValue < maxStashValue: + currentState = STATE.RELOADING + currentStashValue = maxStashValue + return + + return + +func _on_signal_shooting(): pass diff --git a/Module.gd b/Module.gd index 2867d47..e3517f7 100644 --- a/Module.gd +++ b/Module.gd @@ -11,6 +11,8 @@ 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} @@ -22,7 +24,9 @@ func interact(): pass - +func _ready(): + emit_signal("MODULE") + #-----------Setter and Getter---------------# func _set_currentStashValue(newValue): From d8f6b92ebb960f934040c118b1caa8899e1c42d4 Mon Sep 17 00:00:00 2001 From: PfandBoss <68470553+PfandBoss@users.noreply.github.com> Date: Sat, 10 Dec 2022 01:14:41 +0100 Subject: [PATCH 04/11] Update Module.gd --- Module.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Module.gd b/Module.gd index e3517f7..ca86d7d 100644 --- a/Module.gd +++ b/Module.gd @@ -25,7 +25,7 @@ func interact(): func _ready(): - emit_signal("MODULE") + var root = get_tree().root.get_child(0) #-----------Setter and Getter---------------# From cb6e7382fcafd34390365398f597dfbb4c6fe8b2 Mon Sep 17 00:00:00 2001 From: Arthur Date: Sat, 10 Dec 2022 01:21:02 +0100 Subject: [PATCH 05/11] Update Cannon.gd --- Cannon.gd | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Cannon.gd b/Cannon.gd index da77fe3..6fe3811 100644 --- a/Cannon.gd +++ b/Cannon.gd @@ -9,7 +9,7 @@ func _ready(): root.timeout.connect("shooting",self,"_on_signal_shooting") maxStashValue = 1 currentStashValue = 0 - currentState = STATE.INAKTIVE + currentState = STATE.INACTIVE #TODO: FINISH func interact(): if currentState == STATE.INACTIVE: @@ -21,4 +21,8 @@ func interact(): return func _on_signal_shooting(): + if currentStashValue == 1: + currentState = STATE.SHOOTING + #TODO shooting + currentState = STATE.INACTIVE pass From 4a1b2887a8805fa1c6db1252e655fa787a1817fa Mon Sep 17 00:00:00 2001 From: Arthur Date: Sat, 10 Dec 2022 01:22:07 +0100 Subject: [PATCH 06/11] Update Cannon.gd Comments --- Cannon.gd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Cannon.gd b/Cannon.gd index 6fe3811..c063111 100644 --- a/Cannon.gd +++ b/Cannon.gd @@ -13,6 +13,7 @@ func _ready(): #TODO: FINISH func interact(): if currentState == STATE.INACTIVE: + #TODO: RELOADING if currentStashValue < maxStashValue: currentState = STATE.RELOADING currentStashValue = maxStashValue @@ -23,6 +24,6 @@ func interact(): func _on_signal_shooting(): if currentStashValue == 1: currentState = STATE.SHOOTING - #TODO shooting + #TODO: SHOOTING currentState = STATE.INACTIVE pass From 86f9f1d2eb45887393484f508e3e3d800a69705c Mon Sep 17 00:00:00 2001 From: Arthur Date: Sat, 10 Dec 2022 01:34:34 +0100 Subject: [PATCH 07/11] Create Storage.gd --- Storage.gd | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Storage.gd diff --git a/Storage.gd b/Storage.gd new file mode 100644 index 0000000..3aba42d --- /dev/null +++ b/Storage.gd @@ -0,0 +1,11 @@ +extends "res://Module.gd" + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass From 042576acff482749a14baf9a70e648c499f7aaee Mon Sep 17 00:00:00 2001 From: PfandBoss <68470553+PfandBoss@users.noreply.github.com> Date: Sat, 10 Dec 2022 02:03:09 +0100 Subject: [PATCH 08/11] Engine basic added --- Cannon.gd | 10 ++++++---- Engine.gd | 32 ++++++++++++++++++++++++++++++++ project.godot | 8 +++++++- 3 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 Engine.gd diff --git a/Cannon.gd b/Cannon.gd index c063111..4fd34bb 100644 --- a/Cannon.gd +++ b/Cannon.gd @@ -3,6 +3,7 @@ extends Module class_name Cannon enum STATE {INACTIVE, RELOADING, SHOOTING} + #------------Methods-------------# func _ready(): var root = get_tree().root.get_child(0) @@ -22,8 +23,9 @@ func interact(): return func _on_signal_shooting(): - if currentStashValue == 1: + if currentStashValue == 1 and currentState == STATE.INACTIVE: currentState = STATE.SHOOTING - #TODO: SHOOTING - currentState = STATE.INACTIVE - pass + #TODO: SHOOTING + currentState = STATE.INACTIVE + + return diff --git a/Engine.gd b/Engine.gd new file mode 100644 index 0000000..6b1b284 --- /dev/null +++ b/Engine.gd @@ -0,0 +1,32 @@ +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 + + if currentStashValue == 1 and currentState == STATE.INACTIVE: + currentState = STATE.SHOOTING + #TODO: SHOOTING + currentState = STATE.INACTIVE + + return + + diff --git a/project.godot b/project.godot index e993081..675ee97 100644 --- a/project.godot +++ b/project.godot @@ -18,10 +18,16 @@ _global_script_classes=[{ "class": &"Module", "language": &"GDScript", "path": "res://Module.gd" +}, { +"base": "Module", +"class": &"TrainEngine", +"language": &"GDScript", +"path": "res://Engine.gd" }] _global_script_class_icons={ "Cannon": "", -"Module": "" +"Module": "", +"TrainEngine": "" } [application] From d2094ff79d357c3d19595efa46569c8821353c0a Mon Sep 17 00:00:00 2001 From: PfandBoss <68470553+PfandBoss@users.noreply.github.com> Date: Sat, 10 Dec 2022 02:04:32 +0100 Subject: [PATCH 09/11] Update Engine.gd --- Engine.gd | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Engine.gd b/Engine.gd index 6b1b284..760d79e 100644 --- a/Engine.gd +++ b/Engine.gd @@ -21,12 +21,6 @@ func interact(): return #TODO: Repair Train currentState = STATE.RUNNING - - if currentStashValue == 1 and currentState == STATE.INACTIVE: - currentState = STATE.SHOOTING - #TODO: SHOOTING - currentState = STATE.INACTIVE - return From d049e3c1aef43612b3f430f79b06f3f766bb2795 Mon Sep 17 00:00:00 2001 From: PfandBoss <68470553+PfandBoss@users.noreply.github.com> Date: Sat, 10 Dec 2022 02:14:36 +0100 Subject: [PATCH 10/11] Yeah --- Cannon.gd | 2 +- cannon.tscn | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 cannon.tscn diff --git a/Cannon.gd b/Cannon.gd index 4fd34bb..a5ac436 100644 --- a/Cannon.gd +++ b/Cannon.gd @@ -7,7 +7,7 @@ enum STATE {INACTIVE, RELOADING, SHOOTING} #------------Methods-------------# func _ready(): var root = get_tree().root.get_child(0) - root.timeout.connect("shooting",self,"_on_signal_shooting") + root.shooting.connect(_on_signal_shooting) maxStashValue = 1 currentStashValue = 0 currentState = STATE.INACTIVE 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") From 359c3cf1f1e386f9fb37ca224630102d8e669f6e Mon Sep 17 00:00:00 2001 From: Arthur Date: Sat, 10 Dec 2022 02:22:52 +0100 Subject: [PATCH 11/11] Summary (required) --- Cannon.gd | 6 +++--- Storage.gd | 28 ++++++++++++++++++++-------- project.godot | 6 ++++++ 3 files changed, 29 insertions(+), 11 deletions(-) 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": "" }