This commit is contained in:
2022-12-10 07:24:53 +01:00
parent 652f758c73
commit 2e0faec3ac
4 changed files with 37 additions and 10 deletions

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=5 format=3 uid="uid://csh4o2b15qltk"]
[gd_scene load_steps=5 format=3 uid="uid://vwjd5od63jgh"]
[ext_resource type="Script" path="res://scripts/Player.gd" id="1_dta8q"]
[ext_resource type="Texture2D" uid="uid://cy6x8d3xe8lux" path="res://icon.svg" id="2_yjfj7"]

View File

@@ -1,12 +1,19 @@
[gd_scene load_steps=5 format=3 uid="uid://n7w0ff7u25yc"]
[gd_scene load_steps=8 format=3 uid="uid://n7w0ff7u25yc"]
[ext_resource type="Script" path="res://scripts/Logic/Game.gd" id="1_iox18"]
[ext_resource type="PackedScene" uid="uid://byo1m0n20yl45" path="res://Nodes/cannon.tscn" id="2_vrf6k"]
[ext_resource type="Script" path="res://scripts/Train.gd" id="2_xl0he"]
[ext_resource type="PackedScene" uid="uid://vwjd5od63jgh" path="res://Nodes/Player.tscn" id="4_1ipcp"]
[sub_resource type="BoxMesh" id="BoxMesh_ognqx"]
size = Vector3(13, 1, 25)
[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_p3d4e"]
data = PackedVector3Array(-6.5, 0.5, 12.5, 6.5, 0.5, 12.5, -6.5, -0.5, 12.5, 6.5, 0.5, 12.5, 6.5, -0.5, 12.5, -6.5, -0.5, 12.5, 6.5, 0.5, -12.5, -6.5, 0.5, -12.5, 6.5, -0.5, -12.5, -6.5, 0.5, -12.5, -6.5, -0.5, -12.5, 6.5, -0.5, -12.5, 6.5, 0.5, 12.5, 6.5, 0.5, -12.5, 6.5, -0.5, 12.5, 6.5, 0.5, -12.5, 6.5, -0.5, -12.5, 6.5, -0.5, 12.5, -6.5, 0.5, -12.5, -6.5, 0.5, 12.5, -6.5, -0.5, -12.5, -6.5, 0.5, 12.5, -6.5, -0.5, 12.5, -6.5, -0.5, -12.5, 6.5, 0.5, 12.5, -6.5, 0.5, 12.5, 6.5, 0.5, -12.5, -6.5, 0.5, 12.5, -6.5, 0.5, -12.5, 6.5, 0.5, -12.5, -6.5, -0.5, 12.5, 6.5, -0.5, 12.5, -6.5, -0.5, -12.5, 6.5, -0.5, 12.5, 6.5, -0.5, -12.5, -6.5, -0.5, -12.5)
[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_l76gd"]
data = PackedVector3Array(-6.5, 0.5, 12.5, 6.5, 0.5, 12.5, -6.5, -0.5, 12.5, 6.5, 0.5, 12.5, 6.5, -0.5, 12.5, -6.5, -0.5, 12.5, 6.5, 0.5, -12.5, -6.5, 0.5, -12.5, 6.5, -0.5, -12.5, -6.5, 0.5, -12.5, -6.5, -0.5, -12.5, 6.5, -0.5, -12.5, 6.5, 0.5, 12.5, 6.5, 0.5, -12.5, 6.5, -0.5, 12.5, 6.5, 0.5, -12.5, 6.5, -0.5, -12.5, 6.5, -0.5, 12.5, -6.5, 0.5, -12.5, -6.5, 0.5, 12.5, -6.5, -0.5, -12.5, -6.5, 0.5, 12.5, -6.5, -0.5, 12.5, -6.5, -0.5, -12.5, 6.5, 0.5, 12.5, -6.5, 0.5, 12.5, 6.5, 0.5, -12.5, -6.5, 0.5, 12.5, -6.5, 0.5, -12.5, 6.5, 0.5, -12.5, -6.5, -0.5, 12.5, 6.5, -0.5, 12.5, -6.5, -0.5, -12.5, 6.5, -0.5, 12.5, 6.5, -0.5, -12.5, -6.5, -0.5, -12.5)
[node name="Game" type="Node"]
script = ExtResource("1_iox18")
@@ -23,6 +30,14 @@ script = ExtResource("2_xl0he")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, 0, -8)
mesh = SubResource("BoxMesh_ognqx")
[node name="StaticBody3D" type="StaticBody3D" parent="Player1/MeshInstance3D2"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="Player1/MeshInstance3D2/StaticBody3D"]
shape = SubResource("ConcavePolygonShape3D_p3d4e")
[node name="CharacterBody3D" parent="Player1" instance=ExtResource("4_1ipcp")]
transform = Transform3D(1, 0, -3.55271e-15, 0, 1, 0, 3.55271e-15, 0, 1, -1.18815, 0, -11.064)
[node name="Player2" type="Node3D" parent="."]
transform = Transform3D(-0.0154456, -6.75145e-10, -0.999879, -5.21344e-12, 1, -6.75146e-10, 0.999879, -5.2134e-12, -0.0154456, -8, 0, -32)
script = ExtResource("2_xl0he")
@@ -30,3 +45,11 @@ script = ExtResource("2_xl0he")
[node name="MeshInstance3D" type="MeshInstance3D" parent="Player2"]
transform = Transform3D(-0.0154456, -5.21524e-12, 0.999881, -6.75146e-10, 1, -5.21521e-12, -0.999881, -6.75146e-10, -0.0154456, 31.7182, -1.23195e-08, -18.4921)
mesh = SubResource("BoxMesh_ognqx")
[node name="StaticBody3D" type="StaticBody3D" parent="Player2/MeshInstance3D"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="Player2/MeshInstance3D/StaticBody3D"]
shape = SubResource("ConcavePolygonShape3D_l76gd")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.258819, 0.965926, 0, -0.965926, 0.258819, 0, 0, 0)

View File

@@ -69,6 +69,11 @@ config/icon="res://icon.svg"
[input]
test={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":70,"unicode":0,"echo":false,"script":null)
]
}
p1_left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"unicode":0,"echo":false,"script":null)

View File

@@ -8,11 +8,9 @@ var inventory = 0 #1 - full, 0 - empty inventory
var resource = 0
var is_alive = true
@onready var is_player1 : bool
@onready var is_player1 = true
#---------------Methods--------------#
func _init(player_id):
is_player1 = player_id
func _physics_process(delta):
@@ -47,14 +45,15 @@ func check_input():
func check_interaction():
var action
if is_player1:
action = "p1_interaction"
action = "p1_interact"
else:
action = "p2_interaction"
action = "p2_interact"
if Input.is_action_just_pressed(action):
for body in $HitBox.get_overlapping_bodies():
if body.has_method("interact") and body.name == "Storage":
if body is Module:
#Storage interaction
if not inventory:
if not inventory && body is Storage:
body.interact()
elif inventory && not body is Storage:
body.interact()