Leo - storage finished2.0

This commit is contained in:
2022-12-10 13:09:57 +01:00
parent 7d8127e151
commit 797396b4f2
9 changed files with 26 additions and 20 deletions

View File

@@ -19,13 +19,10 @@ animations = [{
"speed": 2.0 "speed": 2.0
}] }]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_p76ml"] [sub_resource type="CylinderShape3D" id="CylinderShape3D_h8ivv"]
radius = 0.500599 radius = 0.494048
height = 1.99403
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_ndwdl"] [sub_resource type="CylinderShape3D" id="CylinderShape3D_8lrgm"]
radius = 1.26679
height = 2.53358
[node name="CharacterBody3D" type="CharacterBody3D"] [node name="CharacterBody3D" type="CharacterBody3D"]
script = ExtResource("1_dta8q") script = ExtResource("1_dta8q")
@@ -43,10 +40,12 @@ visible = false
texture = ExtResource("2_yjfj7") texture = ExtResource("2_yjfj7")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."] [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="."] [node name="HitBox" type="Area3D" parent="."]
collision_mask = 5 collision_mask = 5
[node name="CollisionShape3D" type="CollisionShape3D" parent="HitBox"] [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")

View File

@@ -5,13 +5,14 @@
[sub_resource type="CylinderShape3D" id="CylinderShape3D_c1ipa"] [sub_resource type="CylinderShape3D" id="CylinderShape3D_c1ipa"]
height = 3.60519 height = 3.60519
radius = 1.29067 radius = 2.08877
[node name="Storage" type="StaticBody3D"] [node name="Storage" type="StaticBody3D"]
script = ExtResource("1_guwoh") script = ExtResource("1_guwoh")
currentType = 0 currentType = 0
[node name="CollisionShape3D" type="CollisionShape3D" parent="."] [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") shape = SubResource("CylinderShape3D_c1ipa")
[node name="Sprite3D" type="Sprite3D" parent="."] [node name="Sprite3D" type="Sprite3D" parent="."]

View File

@@ -29,7 +29,7 @@ _global_script_classes=[{
"language": &"GDScript", "language": &"GDScript",
"path": "res://scripts/Logic/MapNode.gd" "path": "res://scripts/Logic/MapNode.gd"
}, { }, {
"base": "Node", "base": "StaticBody3D",
"class": &"Module", "class": &"Module",
"language": &"GDScript", "language": &"GDScript",
"path": "res://scripts/Modules/Module.gd" "path": "res://scripts/Modules/Module.gd"

View File

@@ -5,5 +5,5 @@ class_name Bin
@onready var train = get_parent() as Train @onready var train = get_parent() as Train
#------------Methods-------------# #------------Methods-------------#
func interact(): func interact(player):
train.get_node("CharacterBody3D").inventory = 0 train.get_node("CharacterBody3D").inventory = 0

View File

@@ -15,7 +15,7 @@ func _ready():
currentStashValue = 1 currentStashValue = 1
currentState = STATE.INACTIVE currentState = STATE.INACTIVE
#TODO: FINISH #TODO: FINISH
func interact(): func interact(player):
if currentState == STATE.INACTIVE: if currentState == STATE.INACTIVE:
#TODO: RELOADING #TODO: RELOADING

View File

@@ -15,7 +15,7 @@ func _ready():
currentStashValue = 100 currentStashValue = 100
currentState = STATE.RUNNING currentState = STATE.RUNNING
#TODO: FINISH #TODO: FINISH
func interact(): func interact(player):
if currentState == STATE.RUNNING: if currentState == STATE.RUNNING:
if (train.current_speed + refuelRate) <= maxSpeed: if (train.current_speed + refuelRate) <= maxSpeed:
train.current_speed += refuelRate train.current_speed += refuelRate

View File

@@ -20,7 +20,7 @@ enum MODULE_TYPE {CANNON, STEERING, ENGINE, STORAGE}
#------------Methods-------------# #------------Methods-------------#
func interact(): func interact(player):
pass pass

View File

@@ -11,11 +11,12 @@ func _ready():
var root = get_tree().root.get_child(0) var root = get_tree().root.get_child(0)
root.ammo_pickup.connect(_on_signal_storing) root.ammo_pickup.connect(_on_signal_storing)
maxStashValue = 5 maxStashValue = 5
currentStashValue = 0 currentStashValue = 5
func interact():
func interact(player):
if currentStashValue >= 1: if currentStashValue >= 1:
currentStashValue -= 1 currentStashValue -= 1
player.fill_inventory(currentType)
return return
func _on_signal_storing(): func _on_signal_storing():

View File

@@ -3,13 +3,14 @@ extends CharacterBody3D
#-----------Parameters--------------# #-----------Parameters--------------#
var SPEED = 10 var SPEED = 10
var movement = Vector3(0,0,0) var movement = Vector3(0,0,0)
var collisionLayer = 3
var inventory = 0 #1 - full, 0 - empty inventory var inventory = 0 #1 - full, 0 - empty inventory
var resource = 0 var resource = 0
var is_alive = true var is_alive = true
@onready var is_player1 = true @onready var is_player1 = true
enum TYPE {AMMO, GUNPOWDER, FUEL}
#---------------Methods--------------# #---------------Methods--------------#
func _physics_process(delta): func _physics_process(delta):
@@ -65,6 +66,10 @@ func check_interaction():
if body is Module: if body is Module:
#Storage interaction #Storage interaction
if not inventory && body is Storage: if not inventory && body is Storage:
body.interact() body.interact(self)
elif inventory && not body is Storage: elif inventory && not body is Storage:
body.interact() body.interact(self)
func fill_inventory(type):
self.inventory = 1
self.resource = type