From 797396b4f266badd3180aeb811be2f033c81ba98 Mon Sep 17 00:00:00 2001 From: INoro Date: Sat, 10 Dec 2022 13:09:57 +0100 Subject: [PATCH] Leo - storage finished2.0 --- Nodes/Player.tscn | 15 +++++++-------- Storage.tscn | 3 ++- project.godot | 2 +- scripts/Modules/Bin.gd | 2 +- scripts/Modules/Cannon.gd | 2 +- scripts/Modules/Engine.gd | 2 +- scripts/Modules/Module.gd | 2 +- scripts/Modules/Storage.gd | 7 ++++--- scripts/Player.gd | 11 ++++++++--- 9 files changed, 26 insertions(+), 20 deletions(-) diff --git a/Nodes/Player.tscn b/Nodes/Player.tscn index 152cb4d..a1ba324 100644 --- a/Nodes/Player.tscn +++ b/Nodes/Player.tscn @@ -19,13 +19,10 @@ animations = [{ "speed": 2.0 }] -[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_p76ml"] -radius = 0.500599 -height = 1.99403 +[sub_resource type="CylinderShape3D" id="CylinderShape3D_h8ivv"] +radius = 0.494048 -[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_ndwdl"] -radius = 1.26679 -height = 2.53358 +[sub_resource type="CylinderShape3D" id="CylinderShape3D_8lrgm"] [node name="CharacterBody3D" type="CharacterBody3D"] script = ExtResource("1_dta8q") @@ -43,10 +40,12 @@ visible = false texture = ExtResource("2_yjfj7") [node name="CollisionShape3D" type="CollisionShape3D" parent="."] -shape = SubResource("CapsuleShape3D_p76ml") +transform = Transform3D(1.57581, 0, 0, 0, 2.47805, 0, 0, 0, 1.5749, 0, 0, 0) +shape = SubResource("CylinderShape3D_h8ivv") [node name="HitBox" type="Area3D" parent="."] collision_mask = 5 [node name="CollisionShape3D" type="CollisionShape3D" parent="HitBox"] -shape = SubResource("CapsuleShape3D_ndwdl") +transform = Transform3D(2.74062, 0, 0, 0, 2.24144, 0, 0, 0, 2.70992, 0, 0, 0) +shape = SubResource("CylinderShape3D_8lrgm") diff --git a/Storage.tscn b/Storage.tscn index 5c9fce1..2bcf470 100644 --- a/Storage.tscn +++ b/Storage.tscn @@ -5,13 +5,14 @@ [sub_resource type="CylinderShape3D" id="CylinderShape3D_c1ipa"] height = 3.60519 -radius = 1.29067 +radius = 2.08877 [node name="Storage" type="StaticBody3D"] script = ExtResource("1_guwoh") currentType = 0 [node name="CollisionShape3D" type="CollisionShape3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1.10389, 0, 0, 0, 1, 0, 0, 0) shape = SubResource("CylinderShape3D_c1ipa") [node name="Sprite3D" type="Sprite3D" parent="."] diff --git a/project.godot b/project.godot index 127a278..80c0093 100644 --- a/project.godot +++ b/project.godot @@ -29,7 +29,7 @@ _global_script_classes=[{ "language": &"GDScript", "path": "res://scripts/Logic/MapNode.gd" }, { -"base": "Node", +"base": "StaticBody3D", "class": &"Module", "language": &"GDScript", "path": "res://scripts/Modules/Module.gd" diff --git a/scripts/Modules/Bin.gd b/scripts/Modules/Bin.gd index dacfdab..ae5d00d 100644 --- a/scripts/Modules/Bin.gd +++ b/scripts/Modules/Bin.gd @@ -5,5 +5,5 @@ class_name Bin @onready var train = get_parent() as Train #------------Methods-------------# -func interact(): +func interact(player): train.get_node("CharacterBody3D").inventory = 0 diff --git a/scripts/Modules/Cannon.gd b/scripts/Modules/Cannon.gd index 704b3ae..2dd40d2 100644 --- a/scripts/Modules/Cannon.gd +++ b/scripts/Modules/Cannon.gd @@ -15,7 +15,7 @@ func _ready(): currentStashValue = 1 currentState = STATE.INACTIVE #TODO: FINISH -func interact(): +func interact(player): if currentState == STATE.INACTIVE: #TODO: RELOADING diff --git a/scripts/Modules/Engine.gd b/scripts/Modules/Engine.gd index 4969c82..6e87fe8 100644 --- a/scripts/Modules/Engine.gd +++ b/scripts/Modules/Engine.gd @@ -15,7 +15,7 @@ func _ready(): currentStashValue = 100 currentState = STATE.RUNNING #TODO: FINISH -func interact(): +func interact(player): if currentState == STATE.RUNNING: if (train.current_speed + refuelRate) <= maxSpeed: train.current_speed += refuelRate diff --git a/scripts/Modules/Module.gd b/scripts/Modules/Module.gd index 8c2fc80..6feadaa 100644 --- a/scripts/Modules/Module.gd +++ b/scripts/Modules/Module.gd @@ -20,7 +20,7 @@ enum MODULE_TYPE {CANNON, STEERING, ENGINE, STORAGE} #------------Methods-------------# -func interact(): +func interact(player): pass diff --git a/scripts/Modules/Storage.gd b/scripts/Modules/Storage.gd index 9add654..8844ed5 100644 --- a/scripts/Modules/Storage.gd +++ b/scripts/Modules/Storage.gd @@ -11,11 +11,12 @@ func _ready(): var root = get_tree().root.get_child(0) root.ammo_pickup.connect(_on_signal_storing) maxStashValue = 5 - currentStashValue = 0 -func interact(): + currentStashValue = 5 + +func interact(player): if currentStashValue >= 1: currentStashValue -= 1 - + player.fill_inventory(currentType) return func _on_signal_storing(): diff --git a/scripts/Player.gd b/scripts/Player.gd index dee7700..dcd9acc 100644 --- a/scripts/Player.gd +++ b/scripts/Player.gd @@ -3,13 +3,14 @@ extends CharacterBody3D #-----------Parameters--------------# var SPEED = 10 var movement = Vector3(0,0,0) -var collisionLayer = 3 var inventory = 0 #1 - full, 0 - empty inventory var resource = 0 var is_alive = true @onready var is_player1 = true +enum TYPE {AMMO, GUNPOWDER, FUEL} + #---------------Methods--------------# func _physics_process(delta): @@ -65,6 +66,10 @@ func check_interaction(): if body is Module: #Storage interaction if not inventory && body is Storage: - body.interact() + body.interact(self) elif inventory && not body is Storage: - body.interact() + body.interact(self) + +func fill_inventory(type): + self.inventory = 1 + self.resource = type