From 5dc8015dbf2fef1a51cd05c7cd5281b15707fe3d Mon Sep 17 00:00:00 2001 From: HumanoidSandvichDispenser Date: Tue, 1 Aug 2023 23:49:48 -0700 Subject: [PATCH] interactable arena entrance --- Assets/Sprites/Props/arena-entrance.ase | Bin 0 -> 1947 bytes Assets/Sprites/Props/arena-entrance.png | Bin 0 -> 967 bytes .../Sprites/Props/arena-entrance.png.import | 34 ++++++++ Assets/Sprites/Props/doc-statue.ase | Bin 1153 -> 1154 bytes Assets/Sprites/Props/doc-statue.png | Bin 467 -> 469 bytes BoundingBoxes/ConnectorBox.cs | 37 +++++---- Characters/Boss.cs | 11 +++ Characters/Doc.cs | 2 +- Characters/Player.tscn | 5 +- Entities/ArenaEntrance.tscn | 36 ++++++++ Events/EventBus.cs | 9 ++ Events/RequestAreaArgs.cs | 8 ++ Extensions/Node.cs | 10 +++ Scenes/Maps/Arena.tscn | 77 +++++++++++------- Scenes/Maps/ArenaExterior.tscn | 43 +++++++--- Shaders/Water.gdshader | 6 +- State/Global/Progression.cs | 2 +- Utils/EventBus.cs | 0 Utils/World.cs | 40 +++++---- project.godot | 1 + 20 files changed, 245 insertions(+), 76 deletions(-) create mode 100644 Assets/Sprites/Props/arena-entrance.ase create mode 100644 Assets/Sprites/Props/arena-entrance.png create mode 100644 Assets/Sprites/Props/arena-entrance.png.import create mode 100644 Entities/ArenaEntrance.tscn create mode 100644 Events/EventBus.cs create mode 100644 Events/RequestAreaArgs.cs create mode 100644 Utils/EventBus.cs diff --git a/Assets/Sprites/Props/arena-entrance.ase b/Assets/Sprites/Props/arena-entrance.ase new file mode 100644 index 0000000000000000000000000000000000000000..ef73ebadf64ffb274b48763c0fcae0cf7f93bc26 GIT binary patch literal 1947 zcmcJQX;4#F7>2I~jctO6t)K;ys}_Qe5KzR%LMV$x#06+4#RURUgo?6?ve+glh=_n2 zh+sjh5v{nC2qFSX1)&w%sZcO(lr2~YgDkQYlfD-bY@P96PbSYjb5C-<^FH6rB%MwW ze@Z73ez2QyBHzycX{hRl`I!91ZJ zSRP>j%9E+;&r4h=)`fw+ja0?0+dl_m&9 zHfS8i1?>{~p!fN;U_yy6NUWiDCIezXlOxo3ZHscjFnK9>zWo+BL(c(ZFA#txR-Pc= zWe2$0KNj>lDFyYIEYMh&%D8;KHR!^n3`^XoGoJ{p1TUO=p{_+q4FYYWnug|}GiVEX zf`*_QXa)L!CZGe*5BCrc>rf8gkPXw&495@*yHE?SkP4&F36~HFi%wHWl!%CY2!~{d#imk`6T#PG zJ0^5ul~=fTFlqK`nf7`OSJ)U^Hh=f>l6NmJe)saCI#ilO0vPJC6Osgr2s`;G_eO)- zgv?mF_&u6aPsK}hx9=PQFLl^tZf}z-?FieK8LV58Kr%zPl~tw|1(p`PZQak>4plki z(RC~;8sZXvjN$OQ^P3N~*lgR_730J$co}{Fj;AB-L8G>CxAr`(_+75|8J8N<-NHpp z455m{v0|DVF6DP6YvosxhU)4C#fLjM$HZO9{iQYZvlUwB1~`Vr`{ULIS66@5EEctO z{yrqWrea@GJG84`P5ob36MsE=KIn=#lgJ6g6lffeHI0~sSVt9y|K?g9aOg5R$E%%D zXHybgI)4fK$tsc3@GQ%nZRS6x*+Qf&_nFF59NnZgx?4)v1Wa$aF|y-C>^S9LJL+IZ zsq4?05>w^|iRPiyeU5H>xCcvO4F*Da&eF;21ebr%x)>|s1i5B38Ef|E#u!aYDhv^d zS1hb=abK(O=?=`kdr9oZnA_%(FYsSY%e6AudX??+gxQzkSDrSIkX3h6@tq>-neXn7 zUxzH)52_0pDS3a`m3BrYXZfUf)Mv0y6unT%A~WSp6(RT7e&3$yVK?+E>n)A#28i^z zNwD0y7n_l4Fdo5P5^EP4CF@YE=$%-?;&vz23 zfpWAr3X;TZ6l_T;(frAjx%^W?6tyz@_L|4M9W)(J!em9|?S!Dzs7Plm;n2{`So6gF zH7oho4yZzgJIwDm_Z>`k@BZHTa_V5j)5rTO%S4SYgRH-a&fWPnD_hEpuiCBJS)_j; zM3N{y-ji9kSJOBtJR{L@u&`d}7Z+M7;L8*~*8bJ{zbLGZ*Cd6WD&w1K4U(Lex?Zz3 ziA1Mops37pLmEri%Gr|?Vf)44^LaUaI_$Li;a0iFqU)^8NY4b7Y)hxAy|A`BH!Gq) z(`U(^-&zAZRU6dt>x=uo>{Q9V(jLxet-ooV+vpb_E@&bOMhXSQZB&?*dlrFtXE7UYd zxFC}Gs1OP$)R*FzV|MoYINNXK-P_w|XLe?8?_5Eo>a`?wUBCJ_sl?7XPkzu~4(;}~ zont%gVd2HhgYO(bU?0@Cn4*rD1>bt1UQ1FFn0weH+dZ*Pm=)jHDd8M?cG`6=V11)w zTuh7;X35t&IGn&7y1voD*=ZNQPyT4|o#v4?mM%iNr?+`~bu9q^ zT%1po-*oNbe1flE#!3j&ZUDgRmwy2OCs+5u{2~hBR{`L|`;PzsxdQ|@?fS}cf|cb& zX#-i7! zKJg&hI=@Vr_*xC1L9~lh(N6eLLe@$CEsK$pc_nm^1j=L`}i6F zgyky`Ru77t1Bh=6Yq{GtNBQ_c=K!h!ro0b53lu#EghT+}ZQFQj4XD?W^ybcZ4*>NX zKr-dMd|7&WD;#Tc(ua?FZRznth@B6Z4Ko?)iUJ#d0m$Cl>Aip2r!dJ2;oFK{8T^Xx zzqW2~TZ;gjWMuHqP(>BGt2X%@RjJpK)b#nejK!1sgO=9E=XdeTaDa pF{bqmz$D4=rogmA(5Gqh{{wOMS=l*_6JG!T002ovPDHLkV1f~=*BSr- literal 0 HcmV?d00001 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 a995a6bb57b8219b97c7a6f7f2c9a7cb490fe22c..cbb4896fc797cfc4c634f4d6cdc1c9c67c9857ab 100644 GIT binary patch delta 96 zcmZqVY~o~Wn#fqs$h5JMmsv7~fq{Wlfq{V$2>&wyIba~fAU=6Hvzo?6wc87ssySK( u*nWv9o^DvvCa~c+!!{QNh8MRr(%pedSrr%=SQxk_e_?iGWSVTv;syZva~7BY delta 95 zcmZqTY~*BYoXA+u$hfhQmsv8Jfq{Wlfq{XMfr;Ti6OaQ2LJVS)mouxW|5Urp$T)+6 ud4d1KoD~L>7?^G(Gej#fF!*1Vf9noZ$*RD}z{0>i`75&L078J_> diff --git a/Assets/Sprites/Props/doc-statue.png b/Assets/Sprites/Props/doc-statue.png index 4f642a2b65693bdcb7d0a1e936609954334170f7..97899a31ffdb7f8c4691ab0a1023fbd54885820c 100644 GIT binary patch delta 146 zcmV;D0B!%%1JwhtOaXs%Nkl [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]