diff --git a/Assets/Sprites/Props/arena-entrance.ase b/Assets/Sprites/Props/arena-entrance.ase new file mode 100644 index 0000000..ef73eba Binary files /dev/null and b/Assets/Sprites/Props/arena-entrance.ase differ diff --git a/Assets/Sprites/Props/arena-entrance.png b/Assets/Sprites/Props/arena-entrance.png new file mode 100644 index 0000000..9c85d64 Binary files /dev/null and b/Assets/Sprites/Props/arena-entrance.png differ diff --git a/Assets/Sprites/Props/arena-entrance.png.import b/Assets/Sprites/Props/arena-entrance.png.import new file mode 100644 index 0000000..ddb9178 --- /dev/null +++ b/Assets/Sprites/Props/arena-entrance.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dsxoh88caw3cf" +path="res://.godot/imported/arena-entrance.png-3f1feefc685b9eaa6cf3bf809d2019b6.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Sprites/Props/arena-entrance.png" +dest_files=["res://.godot/imported/arena-entrance.png-3f1feefc685b9eaa6cf3bf809d2019b6.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Assets/Sprites/Props/doc-statue.ase b/Assets/Sprites/Props/doc-statue.ase index a995a6b..cbb4896 100644 Binary files a/Assets/Sprites/Props/doc-statue.ase and b/Assets/Sprites/Props/doc-statue.ase differ diff --git a/Assets/Sprites/Props/doc-statue.png b/Assets/Sprites/Props/doc-statue.png index 4f642a2..97899a3 100644 Binary files a/Assets/Sprites/Props/doc-statue.png and b/Assets/Sprites/Props/doc-statue.png differ diff --git a/BoundingBoxes/ConnectorBox.cs b/BoundingBoxes/ConnectorBox.cs index e853b20..eb52921 100644 --- a/BoundingBoxes/ConnectorBox.cs +++ b/BoundingBoxes/ConnectorBox.cs @@ -1,6 +1,8 @@ using Godot; using System; using SupaLidlGame.Characters; +using SupaLidlGame.Extensions; +using SupaLidlGame.Events; namespace SupaLidlGame.BoundingBoxes; @@ -25,7 +27,7 @@ public partial class ConnectorBox : Area2D /// the connector /// [Export] - public bool RequiresInteraction { get; set; } = false; + public InteractionTrigger InteractionTrigger { get; set; } [Export] public CollisionShape2D Collision { get; set; } @@ -41,31 +43,32 @@ public partial class ConnectorBox : Area2D BodyEntered += (Node2D body) => { - if (body is Player player) + if (body is Player && InteractionTrigger is null) { - _player = player; + OnInteraction(); } }; - BodyExited += (Node2D body) => + if (InteractionTrigger is not null) { - if (body is Player) - { - _player = null; - } - }; + InteractionTrigger.Interaction += OnInteraction; + } } public override void _Process(double delta) { - if (Input.IsActionJustReleased("interact")) - { - if (_player is not null) - { - EmitSignal(SignalName.RequestedEnter, this, _player); - } - } - base._Process(delta); } + + protected void OnInteraction() + { + var eventBus = this.GetEventBus(); + System.Diagnostics.Debug.Assert(eventBus is not null); + var args = new Events.RequestAreaArgs + { + Area = ToArea, + Connector = ToConnector, + }; + eventBus.EmitSignal(EventBus.SignalName.RequestMoveToArea, args); + } } diff --git a/Characters/Boss.cs b/Characters/Boss.cs index de30fd4..cd86f72 100644 --- a/Characters/Boss.cs +++ b/Characters/Boss.cs @@ -35,5 +35,16 @@ public abstract partial class Boss : Enemy public override void _Ready() { base._Ready(); + + Death += (Events.HealthChangedArgs args) => + { + UpdateBossStatus(true); + }; + } + + protected void UpdateBossStatus(bool status) + { + GetNode("/root/GlobalState") + .Progression.BossStatus[SceneFilePath] = status; } } diff --git a/Characters/Doc.cs b/Characters/Doc.cs index 9d3c061..1bde845 100644 --- a/Characters/Doc.cs +++ b/Characters/Doc.cs @@ -113,7 +113,7 @@ public partial class Doc : Boss } }; } - + public override void _Process(double delta) { if (IsActive) diff --git a/Characters/Player.tscn b/Characters/Player.tscn index 0b94b59..22b49c0 100644 --- a/Characters/Player.tscn +++ b/Characters/Player.tscn @@ -471,13 +471,14 @@ visible = false current = true [node name="Direction2D" type="Marker2D" parent="."] -visible = false -position = Vector2(0, 6) +position = Vector2(0, -4) [node name="InteractionRay" type="RayCast2D" parent="Direction2D"] target_position = Vector2(16, 0) collision_mask = 64 +hit_from_inside = true collide_with_areas = true +collide_with_bodies = false script = ExtResource("13_hs3u1") [node name="PointLight2D" type="PointLight2D" parent="."] diff --git a/Entities/ArenaEntrance.tscn b/Entities/ArenaEntrance.tscn new file mode 100644 index 0000000..2164bdb --- /dev/null +++ b/Entities/ArenaEntrance.tscn @@ -0,0 +1,36 @@ +[gd_scene load_steps=6 format=3 uid="uid://bou5pccj0147e"] + +[ext_resource type="Texture2D" uid="uid://dsxoh88caw3cf" path="res://Assets/Sprites/Props/arena-entrance.png" id="1_edppa"] +[ext_resource type="PackedScene" uid="uid://dldnp8eunxj3q" path="res://BoundingBoxes/InteractionTrigger.tscn" id="2_87s4g"] +[ext_resource type="Script" path="res://BoundingBoxes/ConnectorBox.cs" id="3_4rsih"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_m4g2i"] +size = Vector2(32, 32) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_djn8q"] + +[node name="ArenaEntrance" type="Node2D"] + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("1_edppa") +offset = Vector2(0, -14) +hframes = 2 + +[node name="InteractionTrigger" parent="." instance=ExtResource("2_87s4g")] + +[node name="CollisionShape2D" parent="InteractionTrigger" index="0"] +shape = SubResource("RectangleShape2D_m4g2i") + +[node name="Area2D" type="Area2D" parent="." node_paths=PackedStringArray("InteractionTrigger", "Collision")] +script = ExtResource("3_4rsih") +ToArea = "res://Scenes/Maps/Arena.tscn" +ToConnector = "entrance" +Identifier = "arena_entrance" +InteractionTrigger = NodePath("../InteractionTrigger") +Collision = NodePath("CollisionShape2D") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] +shape = SubResource("RectangleShape2D_djn8q") +debug_color = Color(0, 0.6, 0.701961, 0.419608) + +[editable path="InteractionTrigger"] diff --git a/Events/EventBus.cs b/Events/EventBus.cs new file mode 100644 index 0000000..7a8d46b --- /dev/null +++ b/Events/EventBus.cs @@ -0,0 +1,9 @@ +using Godot; + +namespace SupaLidlGame.Events; + +public partial class EventBus : Node +{ + [Signal] + public delegate void RequestMoveToAreaEventHandler(RequestAreaArgs args); +} diff --git a/Events/RequestAreaArgs.cs b/Events/RequestAreaArgs.cs new file mode 100644 index 0000000..3c35a33 --- /dev/null +++ b/Events/RequestAreaArgs.cs @@ -0,0 +1,8 @@ +namespace SupaLidlGame.Events; + +public partial class RequestAreaArgs : Args +{ + public string Area { get; set; } + + public string Connector { get; set; } +} diff --git a/Extensions/Node.cs b/Extensions/Node.cs index d29dd43..48ea606 100644 --- a/Extensions/Node.cs +++ b/Extensions/Node.cs @@ -51,4 +51,14 @@ public static class NodeExtensions return null; } + + public static State.Global.GlobalState GetGlobalState(this Node node) + { + return node.GetNode("/root/GlobalState"); + } + + public static Events.EventBus GetEventBus(this Node node) + { + return node.GetNode("/root/EventBus"); + } } diff --git a/Scenes/Maps/Arena.tscn b/Scenes/Maps/Arena.tscn index f874983..a585ca2 100644 --- a/Scenes/Maps/Arena.tscn +++ b/Scenes/Maps/Arena.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=11 format=3 uid="uid://b2x17su05ou5w"] +[gd_scene load_steps=14 format=3 uid="uid://b2x17su05ou5w"] [ext_resource type="PackedScene" uid="uid://clwv2owvk6abe" path="res://Scenes/BaseMap.tscn" id="1_ifiic"] [ext_resource type="TileSet" uid="uid://l61kbx31ug4p" path="res://Scenes/Maps/ArenaTileset.tres" id="2_x0mh7"] @@ -8,8 +8,10 @@ [ext_resource type="PackedScene" uid="uid://ceadk7pam7vab" path="res://Entities/TorchLamp.tscn" id="6_jy3pc"] [ext_resource type="Texture2D" uid="uid://d1ukste16yq6v" path="res://Assets/Sprites/Particles/player-light.png" id="7_y7j0e"] [ext_resource type="AudioStream" uid="uid://dy4qjflo1k28b" path="res://Assets/Sounds/calm-storm-ambient.mp3" id="8_wox7d"] +[ext_resource type="PackedScene" uid="uid://dldnp8eunxj3q" path="res://BoundingBoxes/InteractionTrigger.tscn" id="9_3401j"] +[ext_resource type="Script" path="res://BoundingBoxes/ConnectorBox.cs" id="9_fg062"] -[sub_resource type="ShaderMaterial" id="ShaderMaterial_onuc5"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_rp1a6"] resource_local_to_scene = true shader = ExtResource("5_h8k5p") shader_parameter/color = Quaternion(1, 1, 1, 1) @@ -19,8 +21,10 @@ shader_parameter/alpha_modulate = 1.0 [sub_resource type="RectangleShape2D" id="RectangleShape2D_gwpea"] size = Vector2(256, 256) +[sub_resource type="RectangleShape2D" id="RectangleShape2D_2xagi"] +size = Vector2(40, 20) + [node name="TileMap" instance=ExtResource("1_ifiic")] -position = Vector2(-1, 0) tile_set = ExtResource("2_x0mh7") layer_0/tile_data = PackedInt32Array(-524281, 458752, 0, -524284, 458752, 0, -262152, 458752, 0, -327673, 458752, 0, -131065, 458752, 0, -65544, 458752, 0, 131064, 458752, 0, 65543, 458752, 0, 262151, 458752, 0, 327672, 458752, 0, 524280, 458752, 0, 524283, 458752, 0, 524286, 458752, 0, 458753, 458752, 0, 458756, 458752, 0, 458759, 458752, 0, -458760, 458752, 0, -458757, 458752, 0, -524287, 458752, 0, -458754, 458752, 0, -524292, 458752, 3, -589821, 458752, 2, -589822, 393216, 3, -524291, 393216, 2, -589817, 393216, 0) layer_2/tile_data = PackedInt32Array(1376242, 262144, 2, 1441778, 196608, 3, 1376243, 131072, 2, 1441779, 131072, 1, 1376244, 131072, 2, 1441780, 131072, 1, 1376245, 131072, 2, 1441781, 196608, 1, 1376246, 131072, 2, 1441782, 196608, 1, 1376247, 131072, 2, 1441783, 131072, 1, 1376248, 131072, 2, 1441784, 131072, 1, 1376249, 131072, 2, 1441785, 131072, 1, 1376250, 327680, 2, 1441786, 0, 5, 1441787, 131072, 2, 1441788, 131072, 2, 1441789, 131072, 2, 655358, 196608, 3, 720894, 196608, 3, 786430, 196608, 3, 851966, 196608, 3, 917502, 196608, 3, 983038, 196608, 3, 1048574, 196608, 3, 1114110, 196608, 3, 1179646, 196608, 3, 1245182, 196608, 3, 1310718, 196608, 3, 1376254, 196608, 3, 1441790, 65536, 5, 1507322, 131072, 1, 1507323, 131072, 1, 1507324, 196608, 1, 1507325, 131072, 1, 1507326, 131072, 1, 1507314, 196608, 3, 1572850, 65536, 5, 1638386, 131072, 1, 1900530, 65536, 4, 1966066, 196608, 3, 2031602, 262144, 3, 2031603, 196608, 2, 2031604, 196608, 2, 2031605, 196608, 2, 2031606, 196608, 2, 2031607, 196608, 2, 2031608, 196608, 2, 2031609, 196608, 2, 1703930, 0, 4, 1769466, 131072, 3, 1835002, 131072, 3, 1900538, 131072, 3, 1966074, 131072, 3, 2031610, 327680, 3, 1703931, 196608, 2, 1703932, 196608, 2, 1703933, 196608, 2, 589822, 65536, 4, 1703934, 196608, 2, 1703935, 196608, 2, 1638400, 196608, 2, 524289, 0, 4, 589825, 131072, 3, 655361, 131072, 3, 720897, 131072, 3, 786433, 131072, 3, 851969, 131072, 3, 917505, 131072, 3, 983041, 131072, 3, 1048577, 131072, 3, 1114113, 131072, 3, 1179649, 131072, 3, 1245185, 131072, 3, 1310721, 131072, 3, 1376257, 131072, 3, 1441793, 131072, 3, 1507329, 131072, 3, 1572865, 131072, 3, 1638401, 327680, 3) @@ -31,83 +35,83 @@ ClearColor = Color(0.105882, 0.0470588, 0.117647, 1) AreaName = "The Arena" MapName = "The Arena" -[node name="Static@TorchLamp" parent="." index="0" instance=ExtResource("6_jy3pc")] +[node name="CanvasModulate" parent="." index="0"] +color = Color(0.317647, 0.184314, 0.345098, 1) + +[node name="Static@TorchLamp" parent="Props" index="0" instance=ExtResource("6_jy3pc")] y_sort_enabled = true position = Vector2(-96, -120) -[node name="Static@TorchLamp3" parent="." index="1" instance=ExtResource("6_jy3pc")] +[node name="Static@TorchLamp3" parent="Props" index="1" instance=ExtResource("6_jy3pc")] y_sort_enabled = true position = Vector2(0, -120) -[node name="Static@TorchLamp5" parent="." index="2" instance=ExtResource("6_jy3pc")] +[node name="Static@TorchLamp5" parent="Props" index="2" instance=ExtResource("6_jy3pc")] y_sort_enabled = true position = Vector2(96, -120) -[node name="Static@TorchLamp6" parent="." index="3" instance=ExtResource("6_jy3pc")] +[node name="Static@TorchLamp6" parent="Props" index="3" instance=ExtResource("6_jy3pc")] y_sort_enabled = true position = Vector2(-120, -96) -[node name="Static@TorchLamp7" parent="." index="4" instance=ExtResource("6_jy3pc")] +[node name="Static@TorchLamp7" parent="Props" index="4" instance=ExtResource("6_jy3pc")] y_sort_enabled = true position = Vector2(120, -96) -[node name="Static@TorchLamp9" parent="." index="5" instance=ExtResource("6_jy3pc")] +[node name="Static@TorchLamp9" parent="Props" index="5" instance=ExtResource("6_jy3pc")] y_sort_enabled = true position = Vector2(120, -1) -[node name="Static@TorchLamp11" parent="." index="6" instance=ExtResource("6_jy3pc")] +[node name="Static@TorchLamp11" parent="Props" index="6" instance=ExtResource("6_jy3pc")] y_sort_enabled = true position = Vector2(120, 95) -[node name="Static@TorchLamp12" parent="." index="7" instance=ExtResource("6_jy3pc")] +[node name="Static@TorchLamp12" parent="Props" index="7" instance=ExtResource("6_jy3pc")] y_sort_enabled = true position = Vector2(97, 120) -[node name="Static@TorchLamp14" parent="." index="8" instance=ExtResource("6_jy3pc")] +[node name="Static@TorchLamp14" parent="Props" index="8" instance=ExtResource("6_jy3pc")] y_sort_enabled = true position = Vector2(0, 120) -[node name="Static@TorchLamp16" parent="." index="9" instance=ExtResource("6_jy3pc")] +[node name="Static@TorchLamp16" parent="Props" index="9" instance=ExtResource("6_jy3pc")] y_sort_enabled = true position = Vector2(-96, 120) -[node name="Static@TorchLamp17" parent="." index="10" instance=ExtResource("6_jy3pc")] +[node name="Static@TorchLamp17" parent="Props" index="10" instance=ExtResource("6_jy3pc")] y_sort_enabled = true position = Vector2(-120, 95) -[node name="Static@TorchLamp19" parent="." index="11" instance=ExtResource("6_jy3pc")] +[node name="Static@TorchLamp19" parent="Props" index="11" instance=ExtResource("6_jy3pc")] y_sort_enabled = true position = Vector2(-120, -1) -[node name="Static@Torch" parent="." index="12" instance=ExtResource("6_1wwor")] +[node name="Static@Torch" parent="Props" index="12" instance=ExtResource("6_1wwor")] visible = false position = Vector2(-120, -112) -[node name="Static@Torch2" parent="." index="13" instance=ExtResource("6_1wwor")] +[node name="Static@Torch2" parent="Props" index="13" instance=ExtResource("6_1wwor")] visible = false position = Vector2(-72, -112) -[node name="Static@Torch3" parent="." index="14" instance=ExtResource("6_1wwor")] +[node name="Static@Torch3" parent="Props" index="14" instance=ExtResource("6_1wwor")] visible = false position = Vector2(-24, -113) -[node name="Static@Torch4" parent="." index="15" instance=ExtResource("6_1wwor")] +[node name="Static@Torch4" parent="Props" index="15" instance=ExtResource("6_1wwor")] visible = false position = Vector2(24, -112) -[node name="Static@Torch5" parent="." index="16" instance=ExtResource("6_1wwor")] +[node name="Static@Torch5" parent="Props" index="16" instance=ExtResource("6_1wwor")] visible = false position = Vector2(72, -112) -[node name="Static@Torch6" parent="." index="17" instance=ExtResource("6_1wwor")] +[node name="Static@Torch6" parent="Props" index="17" instance=ExtResource("6_1wwor")] visible = false position = Vector2(120, -112) -[node name="CanvasModulate" parent="." index="18"] -color = Color(0.317647, 0.184314, 0.345098, 1) - [node name="Doc" parent="Entities" index="0" instance=ExtResource("4_ej0f3")] -material = SubResource("ShaderMaterial_onuc5") +material = SubResource("ShaderMaterial_rp1a6") [node name="PointLight2D" type="PointLight2D" parent="Entities" index="1"] position = Vector2(168, -42) @@ -127,10 +131,27 @@ stream = ExtResource("8_wox7d") volume_db = -5.0 autoplay = true -[node name="Areas" parent="." index="21"] -visible = false - [node name="Area2D" type="Area2D" parent="Areas" index="0"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Areas/Area2D" index="0"] shape = SubResource("RectangleShape2D_gwpea") + +[node name="Entrance" type="Node2D" parent="Areas" index="1"] +position = Vector2(0, 360) + +[node name="InteractionTrigger" parent="Areas/Entrance" index="0" instance=ExtResource("9_3401j")] + +[node name="Connector" type="Area2D" parent="Areas/Entrance" index="1" node_paths=PackedStringArray("InteractionTrigger", "Collision")] +collision_layer = 68 +collision_mask = 0 +script = ExtResource("9_fg062") +ToArea = "res://Scenes/Maps/ArenaExterior.tscn" +ToConnector = "arena_entrance" +Identifier = "entrance" +InteractionTrigger = NodePath("../InteractionTrigger") +Collision = NodePath("CollisionShape2D") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Areas/Entrance/Connector" index="0"] +shape = SubResource("RectangleShape2D_2xagi") + +[editable path="Areas/Entrance/InteractionTrigger"] diff --git a/Scenes/Maps/ArenaExterior.tscn b/Scenes/Maps/ArenaExterior.tscn index 8180ca9..93de7c3 100644 --- a/Scenes/Maps/ArenaExterior.tscn +++ b/Scenes/Maps/ArenaExterior.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=37 format=3 uid="uid://c72uqjjtxpi3g"] +[gd_scene load_steps=40 format=3 uid="uid://c72uqjjtxpi3g"] [ext_resource type="PackedScene" uid="uid://clwv2owvk6abe" path="res://Scenes/BaseMap.tscn" id="1_ci4ij"] [ext_resource type="TileSet" uid="uid://l61kbx31ug4p" path="res://Scenes/Maps/ArenaTileset.tres" id="2_m6h7j"] @@ -19,6 +19,7 @@ [ext_resource type="Texture2D" uid="uid://cnbl2513g1aec" path="res://Assets/Sprites/Particles/noise-cell-32.png" id="16_u08sn"] [ext_resource type="Texture2D" uid="uid://pirjyyj5i0c7" path="res://Assets/Sprites/Particles/noise-cell-8.png" id="17_p0trg"] [ext_resource type="Texture2D" uid="uid://jxrytll5j50n" path="res://Assets/Sprites/Props/doc-statue.png" id="19_u6j17"] +[ext_resource type="PackedScene" uid="uid://bou5pccj0147e" path="res://Entities/ArenaEntrance.tscn" id="20_tcd0x"] [sub_resource type="Gradient" id="Gradient_jupxw"] offsets = PackedFloat32Array(0.00740741, 0.2, 1) @@ -127,19 +128,30 @@ light_mode = 1 [sub_resource type="ShaderMaterial" id="ShaderMaterial_6r42m"] shader = ExtResource("15_vlb8v") -shader_parameter/level = 0.0 -shader_parameter/water_albedo = Color(0.6, 0.458824, 0.8, 1) shader_parameter/alpha = 0.75 shader_parameter/water_speed = 0.05 shader_parameter/wave_distortion = 0.2 +shader_parameter/reflection_offset = Vector2(-0.08, 0) shader_parameter/noise_texture = ExtResource("16_u08sn") shader_parameter/noise_texture2 = ExtResource("17_p0trg") [sub_resource type="CanvasTexture" id="CanvasTexture_44wk8"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_vak3n"] +shader = ExtResource("15_vlb8v") +shader_parameter/alpha = 0.75 +shader_parameter/water_speed = 0.05 +shader_parameter/wave_distortion = 0.2 +shader_parameter/reflection_offset = Vector2(0.02, 0) +shader_parameter/noise_texture = ExtResource("16_u08sn") +shader_parameter/noise_texture2 = ExtResource("17_p0trg") + [sub_resource type="RectangleShape2D" id="RectangleShape2D_wi532"] size = Vector2(64, 97) +[sub_resource type="RectangleShape2D" id="RectangleShape2D_5pcme"] +size = Vector2(18, 6) + [node name="TileMap" instance=ExtResource("1_ci4ij")] tile_set = ExtResource("2_m6h7j") layer_0/tile_data = PackedInt32Array(-1703963, 393216, 0, -1703954, 393216, 0, -1703953, 458752, 2, -393224, 196608, 4, -262152, 196608, 4, -131080, 196608, 4, 196600, 196608, 4, 327672, 196608, 4, 458744, 196608, 4, -458759, 131072, 4, 589817, 458752, 4, -458757, 131072, 4, 589819, 458752, 4, -458755, 131072, 4, 589821, 458752, 4, -524286, 131072, 4, 524290, 458752, 4, -524284, 131072, 4, 524292, 458752, 4, -524282, 131072, 4, 524294, 458752, 4, -458744, 327680, 4, -327672, 327680, 4, -196600, 327680, 4, 131080, 327680, 4, 262152, 327680, 4, 393224, 327680, 4, -589819, 458752, 2, -524294, 458752, 2, -524292, 393216, 2, -589821, 393216, 2, 131070, 458752, 0, 131068, 458752, 0, 131066, 458752, 0, 262142, 458752, 0, 393214, 458752, 0, 327681, 458752, 0, 196609, 458752, 0, 65537, 458752, 0, 65539, 458752, 0, 65541, 458752, 0, -131067, 458752, 0, -131069, 458752, 0, -131071, 458752, 0, -262143, 458752, 0, -393215, 458752, 0, -327682, 458752, 0, -196610, 458752, 0, -65538, 458752, 0, -65540, 458752, 0, -65542, 458752, 0, -1638415, 131072, 4, -1638426, 131072, 4, -1507340, 131072, 4, -1572862, 131072, 4, -1507333, 131072, 4, -1703960, 393216, 2, 1900541, 131072, 4, 1835010, 131072, 4, 1835020, 131072, 4, 1835025, 131072, 4, 2883581, 458752, 4, 2818050, 458752, 4, 2818055, 458752, 4, 2818060, 458752, 4, 2818065, 458752, 4, 2097152, 458752, 0, 2097156, 458752, 0, 2097160, 458752, 0, 2097164, 458752, 0, 2490380, 458752, 0, 2490376, 458752, 0, 2490372, 458752, 0, 2490368, 458752, 0, 2097162, 458752, 0, 2097154, 458752, 0, 2490370, 458752, 0, 2490374, 458752, 0, 2097158, 458752, 0, 2490378, 458752, 0, 2097166, 458752, 0, 2228238, 458752, 0, 2359310, 458752, 0, 2490382, 458752, 0, 1835015, 131072, 4, 1835039, 786432, 0, 1835040, 851968, 0) @@ -488,14 +500,13 @@ scale = Vector2(64, 84) texture = SubResource("CanvasTexture_44wk8") [node name="Sprite2D2" type="Sprite2D" parent="Props/Water" index="1"] -material = SubResource("ShaderMaterial_6r42m") +material = SubResource("ShaderMaterial_vak3n") position = Vector2(128, 0) scale = Vector2(64, 84) texture = SubResource("CanvasTexture_44wk8") [node name="Background" type="Sprite2D" parent="Props/Water" index="2"] -visible = false -modulate = Color(0.662745, 0.627451, 0.960784, 1) +modulate = Color(0.819608, 0.988235, 1, 1) z_index = -3 position = Vector2(64, 0) scale = Vector2(192, 84) @@ -520,21 +531,33 @@ visible = false position = Vector2(0, -5.5) shape = SubResource("RectangleShape2D_wi532") -[node name="DocStatue" type="Node2D" parent="Props" index="24"] +[node name="DocStatue" type="StaticBody2D" parent="Props" index="24"] z_index = -1 -position = Vector2(544, 408) +position = Vector2(544, 410) [node name="Sprite2D" type="Sprite2D" parent="Props/DocStatue" index="0"] texture = ExtResource("19_u6j17") -[node name="DocStatue2" type="Node2D" parent="Props" index="25"] +[node name="CollisionShape2D" type="CollisionShape2D" parent="Props/DocStatue" index="1"] +position = Vector2(0, 9) +shape = SubResource("RectangleShape2D_5pcme") + +[node name="DocStatue2" type="StaticBody2D" parent="Props" index="25"] z_index = -1 -position = Vector2(608, 408) +position = Vector2(608, 410) [node name="Sprite2D" type="Sprite2D" parent="Props/DocStatue2" index="0"] texture = ExtResource("19_u6j17") flip_h = true +[node name="CollisionShape2D" type="CollisionShape2D" parent="Props/DocStatue2" index="1"] +position = Vector2(0, 9) +shape = SubResource("RectangleShape2D_5pcme") + +[node name="ArenaEntrance" parent="Entities" index="0" instance=ExtResource("20_tcd0x")] +z_index = -1 +position = Vector2(576, 416) + [editable path="Props/StaticBookshelf"] [editable path="Props/StaticBookshelf2"] [editable path="Props/StaticBookshelf3"] diff --git a/Shaders/Water.gdshader b/Shaders/Water.gdshader index 96d6d03..96ce36a 100644 --- a/Shaders/Water.gdshader +++ b/Shaders/Water.gdshader @@ -1,12 +1,11 @@ shader_type canvas_item; -uniform float level : hint_range(0.0, 1.0) = 0.5; -uniform vec4 water_albedo : source_color = vec4(0.26, 0.23, 0.73, 1.0); uniform float alpha : hint_range(0.0, 1.0) = 0.75; uniform float water_speed = 0.05; uniform float wave_distortion = 0.2; uniform sampler2D noise_texture : repeat_enable; uniform sampler2D noise_texture2 : repeat_enable; +uniform vec2 reflection_offset = vec2(0, 0); uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap; void fragment() { @@ -14,7 +13,8 @@ void fragment() { vec2 scroll2 = vec2(-water_speed); float depth = texture(noise_texture, UV + scroll1 * TIME).r * texture(noise_texture2, UV + scroll2 * TIME).r; - vec4 screen = texture(SCREEN_TEXTURE, SCREEN_UV + wave_distortion * vec2(depth)); + vec4 screen = texture(SCREEN_TEXTURE, + SCREEN_UV + wave_distortion * vec2(depth) + reflection_offset); COLOR = screen; COLOR.a = alpha; } \ No newline at end of file diff --git a/State/Global/Progression.cs b/State/Global/Progression.cs index 187e60a..7df34b1 100644 --- a/State/Global/Progression.cs +++ b/State/Global/Progression.cs @@ -5,5 +5,5 @@ namespace SupaLidlGame.State.Global; public partial class Progression : Resource { - public Dictionary BossStatus { get; set; } + public Dictionary BossStatus { get; set; } } diff --git a/Utils/EventBus.cs b/Utils/EventBus.cs new file mode 100644 index 0000000..e69de29 diff --git a/Utils/World.cs b/Utils/World.cs index 1461115..922ef8d 100644 --- a/Utils/World.cs +++ b/Utils/World.cs @@ -32,6 +32,8 @@ public partial class World : Node2D public State.Global.GlobalState GlobalState { get; set; } + public Events.EventBus EventBus { get; set; } + private Dictionary _maps; private string _currentConnector; @@ -55,7 +57,7 @@ public partial class World : Node2D { // check if world already exists - GlobalState = GetNode("/root/GlobalState"); + GlobalState = this.GetGlobalState(); if (GlobalState.World is not null) { throw new System.InvalidOperationException(); @@ -76,7 +78,7 @@ public partial class World : Node2D CurrentPlayer.Death += (Events.HealthChangedArgs args) => { // TODO: respawn the player at the last campfire. - GetTree().CreateTimer(1).Timeout += () => + GetTree().CreateTimer(3).Timeout += () => { SpawnPlayer(); }; @@ -89,6 +91,13 @@ public partial class World : Node2D bar.ProgressBar.Value = args.NewHealth; }; + EventBus = this.GetEventBus(); + EventBus.RequestMoveToArea += (Events.RequestAreaArgs args) => + { + GD.Print("request move to area"); + MoveToArea(args.Area, args.Connector); + }; + base._Ready(); } @@ -172,14 +181,15 @@ public partial class World : Node2D private void InitTilemap(Map map) { + // this is being replaced with interaction triggers var children = map.Areas.GetChildren(); foreach (Node node in children) { if (node is BoundingBoxes.ConnectorBox connector) { // this reconnects the EventHandler if it is connected - connector.RequestedEnter -= _on_area_2d_requested_enter; - connector.RequestedEnter += _on_area_2d_requested_enter; + //connector.RequestedEnter -= _on_area_2d_requested_enter; + //connector.RequestedEnter += _on_area_2d_requested_enter; } } } @@ -187,16 +197,18 @@ public partial class World : Node2D private void MovePlayerToConnector(string name) { // find the first connector with the specified name - var connector = CurrentMap.Areas.GetChildren().First((child) => - { - if (child is BoundingBoxes.ConnectorBox connector) - { - return connector.Identifier == name; - } - return false; - }) as BoundingBoxes.ConnectorBox; + // TODO: replace this with event buses + //var connector = CurrentMap.Areas.GetChildren().First((child) => + //{ + // if (child is BoundingBoxes.ConnectorBox connector) + // { + // return connector.Identifier == name; + // } + // return false; + //}) as BoundingBoxes.ConnectorBox; - CurrentPlayer.GlobalPosition = connector.GlobalPosition; + //CurrentPlayer.GlobalPosition = connector.GlobalPosition; + CurrentPlayer.GlobalPosition = Vector2.Zero; } public void MoveToArea(string path, string connector) @@ -205,7 +217,7 @@ public partial class World : Node2D if (path != _currentMapResourcePath) { var scene = ResourceLoader.Load(path); - LoadScene(scene); + LoadScene(path); _currentMapResourcePath = path; } diff --git a/project.godot b/project.godot index 187b292..32dc158 100644 --- a/project.godot +++ b/project.godot @@ -20,6 +20,7 @@ config/icon="res://icon.svg" DebugConsole="*res://Debug/DebugConsole.cs" DialogueManager="*res://addons/dialogue_manager/dialogue_manager.gd" GlobalState="*res://State/Global/GlobalState.cs" +EventBus="*res://Events/EventBus.cs" [dialogue_manager]