This commit is contained in:
Arthur
2022-12-10 03:02:53 +01:00
10 changed files with 94 additions and 16 deletions

View File

@@ -1,6 +1,3 @@
[gd_scene load_steps=2 format=3 uid="uid://b87b68ghm4dkk"] [gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://Module.gd" id="1_42v8k"] [ext_resource type="Script" path="res://scripts/Modules/Module.gd" id="1_42v8k"]
[node name="Node" type="Node"]
script = ExtResource("1_42v8k")

6
Nodes/cannon.tscn Normal file
View File

@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://kupfq75m0v37"]
[ext_resource type="Script" path="res://scripts/Modules/Cannon.gd" id="1_vdn0s"]
[node name="Cannon" type="Node"]
script = ExtResource("1_vdn0s")

53
Nodes/game.tscn Normal file
View File

@@ -0,0 +1,53 @@
[gd_scene load_steps=5 format=3 uid="uid://bl1yrgr7g06db"]
[ext_resource type="Script" path="res://scripts/Logic/Game.gd" id="1_iox18"]
[sub_resource type="Curve3D" id="Curve3D_42kdk"]
_data = {
"points": PackedVector3Array(-8, 0, 0, 8, 0, 0, 0, 0, -8, -16, 0, 0, 16, 0, 0, 72, 0, -16, 0, 0, -16, 0, 0, 16, 88, 0, 0, 16, 0, 0, -16, 0, 0, 72, 0, 16, 0, 0, 16, 0, 0, -16, 56, 0, 0, -16, 0, 0, 16, 0, 0, 72, 0, -16, 0, 0, -16, 0, 0, 16, 88, 0, 0, 16, 0, 0, -16, 0, 0, 72, 0, 16, 8, 0, 0, -8, 0, 0, 0, 0, 8, 0, 0, 8, 0, 0, -8, -8, 0, 0, -8, 0, 0, 8, 0, 0, 0, 0, -8, 0, 0, -8, 0, 0, 8, 8, 0, 0, 8, 0, 0, -8, 0, 0, 0, 0, 8, 0, 0, 8, 0, 0, -8, -8, 0, 0, -8, 0, 0, 8, 0, 0, 0, 0, -8),
"tilts": PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
}
point_count = 15
[sub_resource type="BoxMesh" id="BoxMesh_3vwcb"]
size = Vector3(1, 1, 2)
[sub_resource type="Curve3D" id="Curve3D_ycdkn"]
_data = {
"points": PackedVector3Array(-16, 0, 0, 16, 0, 0, 0, 0, -16, 0, 0, -16, 0, 0, 16, 16, 0, 0, 16, 0, 0, -16, 0, 0, 0, 0, 16, 0, 0, 16, 0, 0, -16, -15.9109, 0.0032196, 0.0159729, -16, 0, 0, 16, 0, 0, 0, 0, -16, -8, 0, 0, 8, 0, 0, 72, 0, -8, 0, 0, -8, 0, 0, 8, 80, 0, 0, 8, 0, 0, -8, 0, 0, 72, 0, 8, 0, 0, 8, 0, 0, -8, 64, 0, 0, -8, 0, 0, 8, 0, 0, 72, 0, -8, 0, 0, -8, 0, 0, 8, 80, 0, 0, 8, 0, 0, -8, 0, 0, 72, 0, 8, 16, 0, 0, -16, 0, 0, 0, 0, 16, 0, 0, 16, 0, 0, -16, -16, 0, 0, -16, 0, 0, 16, 0, 0, 0, 0, -16),
"tilts": PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
}
point_count = 15
[node name="Game" type="Node"]
script = ExtResource("1_iox18")
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 1.77636e-14, 7.76471e-22, 0, -4.37114e-08, 1, 1.77636e-14, -1, -4.37114e-08, 36.5305, 43.522, 0.295507)
[node name="Player1Path" type="Path3D" parent="."]
curve = SubResource("Curve3D_42kdk")
[node name="PathFollow3D" type="PathFollow3D" parent="Player1Path"]
transform = Transform3D(-4.37107e-08, 0, 0.999984, 0, 1, 0, -0.999984, 0, -4.37107e-08, 0, 0, -8)
[node name="root" type="Node3D" parent="Player1Path/PathFollow3D"]
[node name="Zug1" type="MeshInstance3D" parent="Player1Path/PathFollow3D/root"]
transform = Transform3D(1, 0, -7.10543e-15, 0, 1, 0, 7.10543e-15, 0, 1, 0, 0, 0)
mesh = SubResource("BoxMesh_3vwcb")
skeleton = NodePath("../..")
[node name="Player2Path" type="Path3D" parent="."]
curve = SubResource("Curve3D_ycdkn")
[node name="PathFollow3D" type="PathFollow3D" parent="Player2Path"]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0, -16)
[node name="root" type="Node3D" parent="Player2Path/PathFollow3D"]
transform = Transform3D(-0.0154456, -6.75146e-10, -0.999881, -5.21344e-12, 1, -6.75146e-10, 0.999881, -5.21341e-12, -0.0154456, 0, 0, 0)
[node name="Zug1" type="MeshInstance3D" parent="Player2Path/PathFollow3D/root"]
transform = Transform3D(1, 0, -7.10543e-15, 0, 1, 0, 7.10543e-15, 0, 1, 0, 0, 0)
mesh = SubResource("BoxMesh_3vwcb")
skeleton = NodePath("../..")

View File

@@ -1,6 +0,0 @@
[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")

View File

@@ -12,22 +12,22 @@ _global_script_classes=[{
"base": "Module", "base": "Module",
"class": &"Cannon", "class": &"Cannon",
"language": &"GDScript", "language": &"GDScript",
"path": "res://Cannon.gd" "path": "res://scripts/Modules/Cannon.gd"
}, { }, {
"base": "Node", "base": "Node",
"class": &"Module", "class": &"Module",
"language": &"GDScript", "language": &"GDScript",
"path": "res://Module.gd" "path": "res://scripts/Modules/Module.gd"
}, { }, {
"base": "Module", "base": "Module",
"class": &"Storage", "class": &"Storage",
"language": &"GDScript", "language": &"GDScript",
"path": "res://Storage.gd" "path": "res://scripts/Modules/Storage.gd"
}, { }, {
"base": "Module", "base": "Module",
"class": &"TrainEngine", "class": &"TrainEngine",
"language": &"GDScript", "language": &"GDScript",
"path": "res://Engine.gd" "path": "res://scripts/Modules/Engine.gd"
}] }]
_global_script_class_icons={ _global_script_class_icons={
"Cannon": "", "Cannon": "",

27
scripts/Logic/Game.gd Normal file
View File

@@ -0,0 +1,27 @@
extends Node
#Signals
signal ammo_pickup
signal shoot
var t = 0.0
@onready var tween = create_tween() as Tween
@onready var p1 = $Player1Path/PathFollow3D
@onready var p2 = $Player2Path/PathFollow3D
func _ready():
start_tween()
func start_tween():
tween.set_trans(Tween.TRANS_LINEAR)
tween.set_parallel(true)
tween.tween_property(p1, "progress_ratio", 1, 5)
tween.tween_property(p2, "progress_ratio", -1, 5)
func _process(delta):
if round(p1.position.distance_to(p2.position)) == 9:
emit_signal("shoot")

View File

@@ -7,7 +7,7 @@ enum STATE {INACTIVE, RELOADING, SHOOTING}
#------------Methods-------------# #------------Methods-------------#
func _ready(): func _ready():
var root = get_tree().root.get_child(0) var root = get_tree().root.get_child(0)
root.shooting.connect(_on_signal_shooting) root.shoot.connect(_on_signal_shooting)
maxStashValue = 1 maxStashValue = 1
currentStashValue = 0 currentStashValue = 0
currentState = STATE.INACTIVE currentState = STATE.INACTIVE
@@ -23,6 +23,7 @@ func interact():
return return
func _on_signal_shooting(): func _on_signal_shooting():
print("hit")
if currentStashValue >= 1 and currentState == STATE.INACTIVE: if currentStashValue >= 1 and currentState == STATE.INACTIVE:
currentState = STATE.SHOOTING currentState = STATE.SHOOTING
currentStashValue -= 1 currentStashValue -= 1