diff --git a/scenes/HUD/choose_team.tscn b/scenes/HUD/choose_team.tscn index fe8deeb..3f30abd 100644 --- a/scenes/HUD/choose_team.tscn +++ b/scenes/HUD/choose_team.tscn @@ -4,41 +4,13 @@ [node name="ChooseTeam" type="Control"] layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="wallpaper" type="ColorRect" parent="."] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -color = Color(0.0392157, 0.360784, 0.419608, 1) - -[node name="box" type="ColorRect" parent="."] -custom_minimum_size = Vector2(100, 200) -layout_mode = 1 anchors_preset = 8 anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 -offset_left = -250.0 -offset_top = -199.0 -offset_right = 250.0 -offset_bottom = 201.0 grow_horizontal = 2 grow_vertical = 2 -color = Color(0.117647, 0.117647, 0.117647, 1) - -[node name="background" type="Control" parent="."] -anchors_preset = 0 -offset_right = 1152.0 -offset_bottom = 650.0 [node name="Choose_team" type="Control" parent="."] layout_mode = 1 @@ -47,106 +19,92 @@ anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 -offset_left = 13.0 -offset_top = -62.0 -offset_right = 53.0 -offset_bottom = -22.0 +offset_left = -20.0 +offset_top = -20.0 +offset_right = 20.0 +offset_bottom = 20.0 grow_horizontal = 2 grow_vertical = 2 -[node name="TextEdit" type="TextEdit" parent="Choose_team"] -layout_mode = 0 -offset_left = -203.0 -offset_top = -118.0 -offset_right = -143.0 -offset_bottom = -73.0 -theme_override_colors/background_color = Color(0.117647, 0.117647, 0.117647, 1) -text = "Teams" - [node name="CS" type="Control" parent="Choose_team"] layout_mode = 1 anchors_preset = 11 anchor_left = 1.0 anchor_right = 1.0 anchor_bottom = 1.0 -offset_left = -268.0 -offset_top = -46.0 -offset_right = -103.0 -offset_bottom = -56.0 +offset_left = 37.0 +offset_right = 37.0 grow_horizontal = 0 grow_vertical = 2 [node name="Closed source" type="Label" parent="Choose_team/CS"] layout_mode = 0 -offset_top = 4.0 -offset_right = 108.0 -offset_bottom = 27.0 +offset_left = 100.0 +offset_top = -100.0 +offset_right = 208.0 +offset_bottom = -77.0 text = "Closed source " [node name="Select_CS" type="Button" parent="Choose_team/CS"] layout_mode = 0 -offset_left = 110.0 -offset_right = 164.0 -offset_bottom = 31.0 +offset_left = 129.0 +offset_top = -77.0 +offset_right = 183.0 +offset_bottom = -46.0 text = "Select " script = ExtResource("1_nua8c") [node name="OS" type="Control" parent="Choose_team"] layout_mode = 1 -anchors_preset = 11 -anchor_left = 1.0 -anchor_right = 1.0 +anchors_preset = 9 anchor_bottom = 1.0 -offset_left = -268.0 -offset_top = -82.0 -offset_right = -98.0 -offset_bottom = -92.0 -grow_horizontal = 0 +offset_left = -130.0 +offset_right = -130.0 grow_vertical = 2 [node name="Open source" type="Label" parent="Choose_team/OS"] layout_mode = 0 -offset_top = 4.0 -offset_right = 108.0 -offset_bottom = 27.0 -text = "Open source" +offset_left = -150.0 +offset_top = -100.0 +offset_right = -52.0 +offset_bottom = -77.0 +text = "Open source +" [node name="Select_OS" type="Button" parent="Choose_team/OS"] layout_mode = 0 -offset_left = 110.0 -offset_right = 164.0 -offset_bottom = 31.0 +offset_left = -129.0 +offset_top = -77.0 +offset_right = -75.0 +offset_bottom = -46.0 text = "Select " script = ExtResource("1_nua8c") -[node name="SP" type="Control" parent="Choose_team"] +[node name="Spectator" type="Control" parent="Choose_team"] layout_mode = 1 -anchors_preset = 11 -anchor_left = 1.0 +anchors_preset = 12 +anchor_top = 1.0 anchor_right = 1.0 anchor_bottom = 1.0 -offset_left = -268.0 -offset_top = -11.0 -offset_right = -98.0 -offset_bottom = -21.0 -grow_horizontal = 0 -grow_vertical = 2 +grow_horizontal = 2 +grow_vertical = 0 -[node name="Spectator" type="Label" parent="Choose_team/SP"] +[node name="Spectator" type="Label" parent="Choose_team/Spectator"] layout_mode = 0 -offset_top = 4.0 -offset_right = 108.0 -offset_bottom = 27.0 +offset_left = -33.0 +offset_right = 42.0 +offset_bottom = 23.0 text = "Spectator" -[node name="Select_SP" type="Button" parent="Choose_team/SP"] +[node name="Select_SP" type="Button" parent="Choose_team/Spectator"] layout_mode = 0 -offset_left = 110.0 -offset_right = 164.0 -offset_bottom = 31.0 +offset_left = -21.0 +offset_top = 23.0 +offset_right = 33.0 +offset_bottom = 54.0 text = "Select " script = ExtResource("1_nua8c") @@ -154,17 +112,11 @@ script = ExtResource("1_nua8c") [node name="Choose_class_OS" type="Control" parent="."] visible = false layout_mode = 1 -anchors_preset = 8 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = -215.0 -offset_top = -135.0 -offset_right = -215.0 -offset_bottom = -135.0 -grow_horizontal = 2 -grow_vertical = 2 +anchors_preset = 0 +offset_left = -41.0 +offset_top = -139.0 +offset_right = -41.0 +offset_bottom = -139.0 [node name="Class 1" type="Control" parent="Choose_class_OS"] layout_mode = 3 @@ -269,18 +221,16 @@ script = ExtResource("1_nua8c") [node name="Choose_class_CS" type="Control" parent="."] visible = false layout_mode = 1 -anchors_preset = 8 -anchor_left = 0.5 +anchors_preset = 14 anchor_top = 0.5 -anchor_right = 0.5 +anchor_right = 1.0 anchor_bottom = 0.5 -offset_left = -215.0 -offset_top = -135.0 -offset_right = -215.0 -offset_bottom = -135.0 +offset_left = -41.0 +offset_top = -139.0 +offset_right = -41.0 +offset_bottom = -139.0 grow_horizontal = 2 grow_vertical = 2 -metadata/_edit_use_anchors_ = true [node name="Class -1" type="Control" parent="Choose_class_CS"] layout_mode = 3 diff --git a/scenes/HUD/hud.tscn b/scenes/HUD/hud.tscn index 713686b..18e580d 100644 --- a/scenes/HUD/hud.tscn +++ b/scenes/HUD/hud.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=7 format=3 uid="uid://gxfhitfre2fj"] -[ext_resource type="Texture2D" uid="uid://vnk3r1p4ao3n" path="res://textures/prototype-textures/Prototype_symbol_cross_32x32px.png" id="1_g1v70"] +[ext_resource type="Texture2D" uid="uid://c4pah1vj0aa4x" path="res://textures/prototype-textures/Prototype_symbol_cross_32x32px.png" id="1_g1v70"] [sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_mhtpk"] diff --git a/scenes/HUD/menu.tscn b/scenes/HUD/menu.tscn index 5453c64..7cb2a85 100644 --- a/scenes/HUD/menu.tscn +++ b/scenes/HUD/menu.tscn @@ -3,10 +3,10 @@ [ext_resource type="Script" path="res://scripts/ConnectButton.gd" id="1_nhpm2"] [ext_resource type="Script" path="res://scripts/TaskPanelButton.gd" id="1_yn6yn"] [ext_resource type="Script" path="res://scripts/Nickname.gd" id="2_5xejq"] -[ext_resource type="Texture2D" uid="uid://dc6j05jqjwuo6" path="res://icon.png" id="4_ps4pi"] +[ext_resource type="Texture2D" uid="uid://c4pah1vj0aa4x" path="res://textures/prototype-textures/Prototype_symbol_cross_32x32px.png" id="2_mk5ih"] -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8m8o7"] -bg_color = Color(0.541176, 0.0352941, 0.627451, 1) +[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_eqsfo"] +texture = ExtResource("2_mk5ih") [node name="Menu" type="Control"] layout_mode = 3 @@ -36,7 +36,6 @@ offset_top = -28.0 offset_bottom = 2.0 grow_horizontal = 2 grow_vertical = 0 -color = Color(0.117647, 0.117647, 0.117647, 1) [node name="buttons" type="Control" parent="ColorRect"] layout_mode = 1 @@ -95,10 +94,10 @@ anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 -offset_left = -60.0 -offset_top = -40.0 -offset_right = 60.0 -offset_bottom = 40.0 +offset_left = -88.0 +offset_top = -72.0 +offset_right = 88.0 +offset_bottom = 72.0 grow_horizontal = 2 grow_vertical = 2 @@ -109,20 +108,54 @@ anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 -offset_left = -60.0 -offset_top = -40.0 -offset_right = 60.0 -offset_bottom = 40.0 +offset_left = -125.0 +offset_top = -73.0 +offset_right = 75.0 +offset_bottom = 7.0 grow_horizontal = 2 grow_vertical = 2 -color = Color(0.117647, 0.117647, 0.117647, 1) +color = Color(0.509804, 0.509804, 0.509804, 1) + +[node name="ColorRect2" type="ColorRect" parent="DirectMenu"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -125.0 +offset_top = -102.0 +offset_right = 75.0 +offset_bottom = -72.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0.439216, 0.439216, 0.439216, 1) + +[node name="https" type="TextEdit" parent="DirectMenu"] +custom_minimum_size = Vector2(10, 0) +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -123.0 +offset_top = -100.0 +offset_right = -82.0 +offset_bottom = -75.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_colors/background_color = Color(0.231373, 0.231373, 0.231373, 1) +theme_override_colors/font_selected_color = Color(0, 0, 0, 1) +theme_override_font_sizes/font_size = 9 +text = "https://" [node name="IP" type="TextEdit" parent="DirectMenu"] layout_mode = 2 -offset_left = 3.0 -offset_top = 10.0 -offset_right = 63.0 -offset_bottom = 35.0 +offset_left = 2.0 +offset_top = -28.0 +offset_right = 77.0 +offset_bottom = -3.0 pivot_offset = Vector2(1, 0) theme_override_colors/background_color = Color(0.231373, 0.231373, 0.231373, 1) theme_override_colors/font_selected_color = Color(0, 0, 0, 1) @@ -132,10 +165,10 @@ placeholder_text = "IP Address" [node name="Port" type="TextEdit" parent="DirectMenu"] layout_mode = 2 -offset_left = 66.0 -offset_top = 10.0 -offset_right = 116.0 -offset_bottom = 35.0 +offset_left = 95.0 +offset_top = -28.0 +offset_right = 145.0 +offset_bottom = -3.0 theme_override_colors/background_color = Color(0.231373, 0.231373, 0.231373, 1) theme_override_font_sizes/font_size = 9 text = "2390" @@ -144,84 +177,48 @@ placeholder_text = "Port [node name="Connect" type="Button" parent="DirectMenu"] layout_mode = 2 -offset_left = 10.0 -offset_top = 40.0 -offset_right = 110.0 -offset_bottom = 71.0 +offset_left = -25.0 +offset_top = 12.0 +offset_right = 147.0 +offset_bottom = 62.0 pivot_offset = Vector2(88, 24) text = "Connect" script = ExtResource("1_nhpm2") -[node name="SettingsMenu" type="Control" parent="."] -visible = false -layout_mode = 1 -anchors_preset = 8 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = -100.0 -offset_top = -50.0 -offset_right = 100.0 -offset_bottom = 50.0 -grow_horizontal = 2 -grow_vertical = 2 +[node name="Panel" type="Panel" parent="DirectMenu"] +layout_mode = 0 +offset_left = 146.0 +offset_top = -27.0 +offset_right = 161.0 +offset_bottom = -12.0 +theme_override_styles/panel = SubResource("StyleBoxTexture_eqsfo") -[node name="ColorRect2" type="ColorRect" parent="SettingsMenu"] -layout_mode = 1 -anchors_preset = 8 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = -100.0 -offset_top = -50.0 -offset_right = 100.0 -offset_bottom = 50.0 -grow_horizontal = 2 -grow_vertical = 2 -color = Color(0.117647, 0.117647, 0.117647, 1) +[node name="SettingsMenu" type="Control" parent="."] +anchors_preset = 0 +offset_right = 256.0 +offset_bottom = 128.0 [node name="Nickname" type="TextEdit" parent="SettingsMenu"] layout_mode = 0 -offset_left = 3.0 -offset_top = 58.0 -offset_right = 153.0 -offset_bottom = 98.0 +offset_left = 24.0 +offset_top = 56.0 +offset_right = 224.0 +offset_bottom = 96.0 placeholder_text = "Unnamed" [node name="Label" type="Label" parent="SettingsMenu"] layout_mode = 0 -offset_left = 24.0 -offset_top = 17.0 -offset_right = 181.0 -offset_bottom = 40.0 +offset_left = 48.0 +offset_top = 24.0 +offset_right = 205.0 +offset_bottom = 47.0 text = "Set player nickname" [node name="Set" type="Button" parent="SettingsMenu"] layout_mode = 0 -offset_left = 154.0 -offset_top = 57.0 -offset_right = 199.0 -offset_bottom = 97.0 +offset_left = 104.0 +offset_top = 104.0 +offset_right = 152.0 +offset_bottom = 120.0 text = "Set" script = ExtResource("2_5xejq") - -[node name="Panel" type="Panel" parent="."] -layout_mode = 1 -anchors_preset = 8 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = -50.0 -offset_top = -119.0 -offset_right = 50.0 -offset_bottom = -79.0 -grow_horizontal = 2 -grow_vertical = 2 -theme_override_styles/panel = SubResource("StyleBoxFlat_8m8o7") - -[node name="Icon" type="Sprite2D" parent="Panel"] -position = Vector2(45, 20) -texture = ExtResource("4_ps4pi") diff --git a/scenes/maps/training.tscn b/scenes/maps/training.tscn index 89ad1d9..40ab25a 100644 --- a/scenes/maps/training.tscn +++ b/scenes/maps/training.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=15 format=3 uid="uid://dx2v4x2jey55t"] +[gd_scene load_steps=16 format=3 uid="uid://dx2v4x2jey55t"] [ext_resource type="Texture2D" uid="uid://c88oa7ckhmvoh" path="res://textures/prototype-textures/Prototype_grey_32x32px.png" id="1_87a53"] [ext_resource type="Material" uid="uid://bm7dpv2ymo0s" path="res://textures/materials/black.material" id="2_acmnt"] @@ -6,9 +6,10 @@ [ext_resource type="Texture2D" uid="uid://bxmfgknljdw65" path="res://icon.svg" id="4_6thf3"] [ext_resource type="PackedScene" uid="uid://833q6upr0s1k" path="res://scenes/special/spawnpoint.tscn" id="5_4t8n8"] [ext_resource type="Material" uid="uid://lh788k850e21" path="res://textures/materials/red.material" id="5_mri33"] -[ext_resource type="Material" uid="uid://btj7xxav4d6l0" path="res://textures/materials/orange.res" id="6_n8h4m"] +[ext_resource type="Material" path="res://textures/materials/orange.res" id="6_n8h4m"] [ext_resource type="Material" uid="uid://bswen72o66of2" path="res://textures/materials/blue.material" id="7_gt32y"] [ext_resource type="ArrayMesh" uid="uid://bal0u14qxmjfb" path="res://models/ladder.obj" id="8_b1h5c"] +[ext_resource type="PackedScene" uid="uid://ut1ssyeu88ui" path="res://scenes/models/target.tscn" id="10_cjpfc"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_rbwrc"] albedo_texture = ExtResource("1_87a53") @@ -285,3 +286,12 @@ team = 1 [node name="spawnpoint2" parent="." instance=ExtResource("5_4t8n8")] transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, -48.5284, 20.414, -22.8886) + +[node name="target" parent="." instance=ExtResource("10_cjpfc")] +transform = Transform3D(1.5, 0, 0, 0, 2, 0, 0, 0, 1.5, -51.7796, 20.0206, -41.7327) + +[node name="target2" parent="." instance=ExtResource("10_cjpfc")] +transform = Transform3D(1.5, 0, 0, 0, 2, 0, 0, 0, 1.5, -48.9129, 20.0206, -41.368) + +[node name="target3" parent="." instance=ExtResource("10_cjpfc")] +transform = Transform3D(1.5, 0, 0, 0, 2, 0, 0, 0, 1.5, -45.7556, 20.0206, -41.6981) diff --git a/scenes/models/point.tscn b/scenes/models/point.tscn new file mode 100644 index 0000000..e6c4ffc --- /dev/null +++ b/scenes/models/point.tscn @@ -0,0 +1,21 @@ +[gd_scene load_steps=5 format=3 uid="uid://2xfxpyp56wik"] + +[ext_resource type="Script" path="res://scripts/point.gd" id="1_cv6ca"] + +[sub_resource type="SphereShape3D" id="SphereShape3D_4jsrs"] + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_0d60f"] +albedo_color = Color(1, 0, 0, 1) + +[sub_resource type="SphereMesh" id="SphereMesh_bwsgk"] + +[node name="point" type="StaticBody3D"] +transform = Transform3D(0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0) +script = ExtResource("1_cv6ca") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="."] +shape = SubResource("SphereShape3D_4jsrs") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="."] +material_override = SubResource("StandardMaterial3D_0d60f") +mesh = SubResource("SphereMesh_bwsgk") diff --git a/scenes/models/target.tscn b/scenes/models/target.tscn index 7aaa858..75fbed9 100644 --- a/scenes/models/target.tscn +++ b/scenes/models/target.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=4 format=3 uid="uid://ut1ssyeu88ui"] +[gd_scene load_steps=5 format=3 uid="uid://ut1ssyeu88ui"] [ext_resource type="ArrayMesh" uid="uid://cqomvoochvl6s" path="res://models/target.obj" id="1_5q4vg"] +[ext_resource type="Script" path="res://scripts/target.gd" id="1_hd3f1"] [sub_resource type="BoxShape3D" id="BoxShape3D_dliev"] size = Vector3(0.624695, 0.569092, 0.129181) @@ -9,6 +10,8 @@ size = Vector3(0.624695, 0.569092, 0.129181) size = Vector3(0.877014, 1.24915, 0.123413) [node name="target" type="StaticBody3D"] +transform = Transform3D(1.5, 0, 0, 0, 2, 0, 0, 0, 1.5, 0, 0, 0) +script = ExtResource("1_hd3f1") [node name="Mesh" type="MeshInstance3D" parent="."] mesh = ExtResource("1_5q4vg") diff --git a/scripts/Networking.gd b/scripts/Networking.gd index 55099ff..ebf0654 100644 --- a/scripts/Networking.gd +++ b/scripts/Networking.gd @@ -236,25 +236,8 @@ func shot(client_id): var target_client_id = int(clients.find_key(target_client)) var shape_num = weapon_raycast.get_collider_shape() - print("shape num: " + str(shape_num)) - var collision_shapes:Array - for s in target.get_children(): - if s is CollisionShape3D: - collision_shapes.push_back(s) - var shape - for i in range(0, collision_shapes.size()): - if i == shape_num: - shape = collision_shapes[i] - break - #for i in range(0, target.get_children().size()): - #var checking_shape = target.get_children()[i] - #print("Checking shape: " + str(checking_shape)) - #if checking_shape is CollisionShape3D and i == shape_num: - #print("Shape found: " + str(checking_shape)) - #shape = checking_shape - #break - - var shapes:Array = ["head", "body", "hand", "leg"] + var shapes = ["head", "body", "hand", "leg"] + var shape = choose_collision_shape(target, shapes, shape_num) var damage for s in shapes: if s in shape.name: @@ -283,7 +266,23 @@ func shot(client_id): target_client["HP"] = 100 target.teleport.rpc_id(target_client_id, target_client["position"]) target.set_hp.rpc_id(target_client_id, target_client["HP"]) - + elif (target is StaticBody3D): + var shapes = ["head", "body"] + var shape_num = weapon_raycast.get_collider_shape() + var shape = choose_collision_shape(target, shapes, shape_num) + target.shot.rpc_id(client_id, weapon_raycast.get_collision_point()) + send_everyone_except(client_id, [target.shot, weapon_raycast.get_collision_point()]) +func choose_collision_shape(target, shapes, shape_num): + var collision_shapes:Array + for s in target.get_children(): + if s is CollisionShape3D: + collision_shapes.push_back(s) + var shape + for i in range(0, collision_shapes.size()): + if i == shape_num: + shape = collision_shapes[i] + break + return shape @rpc("reliable", "call_remote", "any_peer") func change_weapon(client_id, new_weapon_number): var client = clients[client_id] diff --git a/scripts/point.gd b/scripts/point.gd new file mode 100644 index 0000000..088bd50 --- /dev/null +++ b/scripts/point.gd @@ -0,0 +1,5 @@ +extends StaticBody3D + +func _ready(): + await get_tree().create_timer(1).timeout + free() diff --git a/scripts/target.gd b/scripts/target.gd new file mode 100644 index 0000000..bee8572 --- /dev/null +++ b/scripts/target.gd @@ -0,0 +1,10 @@ +extends StaticBody3D + +var point = load("res://scenes/models/point.tscn") + +@rpc("reliable", "authority") +func shot(pos): + print("Shot to " + str(pos)) + var new_point:StaticBody3D = point.instantiate() + add_child(new_point) + new_point.position = to_local(pos)