diff --git a/Assets/Sounds/splat-player.ogg b/Assets/Sounds/splat-player.ogg new file mode 100644 index 0000000..9dfeb19 Binary files /dev/null and b/Assets/Sounds/splat-player.ogg differ diff --git a/Assets/Sounds/splat-player.ogg.import b/Assets/Sounds/splat-player.ogg.import new file mode 100644 index 0000000..4207ee0 --- /dev/null +++ b/Assets/Sounds/splat-player.ogg.import @@ -0,0 +1,19 @@ +[remap] + +importer="oggvorbisstr" +type="AudioStreamOggVorbis" +uid="uid://bkeyg8weaqnuu" +path="res://.godot/imported/splat-player.ogg-b9195de7bb7ca34678fd41a9159d6c3d.oggvorbisstr" + +[deps] + +source_file="res://Assets/Sounds/splat-player.ogg" +dest_files=["res://.godot/imported/splat-player.ogg-b9195de7bb7ca34678fd41a9159d6c3d.oggvorbisstr"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/Assets/Sounds/splat.ogg b/Assets/Sounds/splat.ogg new file mode 100644 index 0000000..c981436 Binary files /dev/null and b/Assets/Sounds/splat.ogg differ diff --git a/Assets/Sounds/splat.ogg.import b/Assets/Sounds/splat.ogg.import new file mode 100644 index 0000000..7d694e9 --- /dev/null +++ b/Assets/Sounds/splat.ogg.import @@ -0,0 +1,19 @@ +[remap] + +importer="oggvorbisstr" +type="AudioStreamOggVorbis" +uid="uid://k6kpdj1kv0jg" +path="res://.godot/imported/splat.ogg-3afac4e48ba675494c2bad9f16c4bde8.oggvorbisstr" + +[deps] + +source_file="res://Assets/Sounds/splat.ogg" +dest_files=["res://.godot/imported/splat.ogg-3afac4e48ba675494c2bad9f16c4bde8.oggvorbisstr"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/Assets/Sprites/Characters/doc.ase b/Assets/Sprites/Characters/doc.ase new file mode 100644 index 0000000..2fd3a93 Binary files /dev/null and b/Assets/Sprites/Characters/doc.ase differ diff --git a/Assets/Sprites/Characters/doc.png b/Assets/Sprites/Characters/doc.png new file mode 100644 index 0000000..cd4c281 Binary files /dev/null and b/Assets/Sprites/Characters/doc.png differ diff --git a/Assets/Sprites/Characters/doc.png.import b/Assets/Sprites/Characters/doc.png.import new file mode 100644 index 0000000..170a85c --- /dev/null +++ b/Assets/Sprites/Characters/doc.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://baiuqgrqipppt" +path="res://.godot/imported/doc.png-044b4c8c4ee17602696518fdf8def758.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Sprites/Characters/doc.png" +dest_files=["res://.godot/imported/doc.png-044b4c8c4ee17602696518fdf8def758.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/Misc/mini-shungite.ase b/Assets/Sprites/Misc/mini-shungite.ase new file mode 100644 index 0000000..cc704c9 Binary files /dev/null and b/Assets/Sprites/Misc/mini-shungite.ase differ diff --git a/Assets/Sprites/Misc/mini-shungite.png b/Assets/Sprites/Misc/mini-shungite.png new file mode 100644 index 0000000..365d408 Binary files /dev/null and b/Assets/Sprites/Misc/mini-shungite.png differ diff --git a/Assets/Sprites/Misc/mini-shungite.png.import b/Assets/Sprites/Misc/mini-shungite.png.import new file mode 100644 index 0000000..6aeb4a9 --- /dev/null +++ b/Assets/Sprites/Misc/mini-shungite.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://debqunpkdemj2" +path="res://.godot/imported/mini-shungite.png-01bdbec41fe54ed8fc826d4314ec257e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Sprites/Misc/mini-shungite.png" +dest_files=["res://.godot/imported/mini-shungite.png-01bdbec41fe54ed8fc826d4314ec257e.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/Misc/shungite-spike.ase b/Assets/Sprites/Misc/shungite-spike.ase new file mode 100644 index 0000000..2d02919 Binary files /dev/null and b/Assets/Sprites/Misc/shungite-spike.ase differ diff --git a/Assets/Sprites/Misc/shungite-spike.png b/Assets/Sprites/Misc/shungite-spike.png new file mode 100644 index 0000000..7b0591a Binary files /dev/null and b/Assets/Sprites/Misc/shungite-spike.png differ diff --git a/Assets/Sprites/Misc/shungite-spike.png.import b/Assets/Sprites/Misc/shungite-spike.png.import new file mode 100644 index 0000000..2fd120b --- /dev/null +++ b/Assets/Sprites/Misc/shungite-spike.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dvx2b0y6dup53" +path="res://.godot/imported/shungite-spike.png-3c88db04670aa56f0aed81fe7332990b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Sprites/Misc/shungite-spike.png" +dest_files=["res://.godot/imported/shungite-spike.png-3c88db04670aa56f0aed81fe7332990b.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/Misc/shungite.ase b/Assets/Sprites/Misc/shungite.ase new file mode 100644 index 0000000..793dc93 Binary files /dev/null and b/Assets/Sprites/Misc/shungite.ase differ diff --git a/Assets/Sprites/Misc/shungite.png b/Assets/Sprites/Misc/shungite.png new file mode 100644 index 0000000..491c22a Binary files /dev/null and b/Assets/Sprites/Misc/shungite.png differ diff --git a/Assets/Sprites/Misc/shungite.png.import b/Assets/Sprites/Misc/shungite.png.import new file mode 100644 index 0000000..1830fc6 --- /dev/null +++ b/Assets/Sprites/Misc/shungite.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dmeqjcc3uu4xi" +path="res://.godot/imported/shungite.png-b3a7d7db0635944f7318920460aea95b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Sprites/Misc/shungite.png" +dest_files=["res://.godot/imported/shungite.png-b3a7d7db0635944f7318920460aea95b.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/arena-tileset-normal.png b/Assets/Sprites/arena-tileset-normal.png new file mode 100644 index 0000000..2082f9e Binary files /dev/null and b/Assets/Sprites/arena-tileset-normal.png differ diff --git a/Assets/Sprites/arena-tileset-normal.png.import b/Assets/Sprites/arena-tileset-normal.png.import new file mode 100644 index 0000000..64e9064 --- /dev/null +++ b/Assets/Sprites/arena-tileset-normal.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://5k0o7d7j65a4" +path="res://.godot/imported/arena-tileset-normal.png-9466546ce6c631f7ed3196f7d2a888b3.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Sprites/arena-tileset-normal.png" +dest_files=["res://.godot/imported/arena-tileset-normal.png-9466546ce6c631f7ed3196f7d2a888b3.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/arena-tileset.ase b/Assets/Sprites/arena-tileset.ase new file mode 100644 index 0000000..7a34fb5 Binary files /dev/null and b/Assets/Sprites/arena-tileset.ase differ diff --git a/Assets/Sprites/arena-tileset.png b/Assets/Sprites/arena-tileset.png new file mode 100644 index 0000000..37205f5 Binary files /dev/null and b/Assets/Sprites/arena-tileset.png differ diff --git a/Assets/Sprites/arena-tileset.png.import b/Assets/Sprites/arena-tileset.png.import new file mode 100644 index 0000000..d6c9bc5 --- /dev/null +++ b/Assets/Sprites/arena-tileset.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b0yiy7w8nxmas" +path="res://.godot/imported/arena-tileset.png-a3c9cd5d13a16cc6a35727d6d51ff6f7.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Sprites/arena-tileset.png" +dest_files=["res://.godot/imported/arena-tileset.png-a3c9cd5d13a16cc6a35727d6d51ff6f7.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/BoundingBoxes/InteractionRay.cs b/BoundingBoxes/InteractionRay.cs new file mode 100644 index 0000000..8ca963e --- /dev/null +++ b/BoundingBoxes/InteractionRay.cs @@ -0,0 +1,54 @@ +using Godot; + +namespace SupaLidlGame.BoundingBoxes; + +public partial class InteractionRay : RayCast2D +{ + private InteractionTrigger _trigger; + + public InteractionTrigger Trigger + { + get => _trigger; + protected set + { + if (_trigger != value) + { + EmitSignal(SignalName.TriggerHit, value); + } + + if (_trigger is not null) + { + LastValidTrigger = value; + } + + _trigger = value; + } + } + + public InteractionTrigger LastValidTrigger { get; set; } + + [Signal] + public delegate void TriggerHitEventHandler(InteractionTrigger trigger); + + public override void _Ready() + { + + } + + public override void _PhysicsProcess(double delta) + { + if (IsColliding()) + { + var obj = GetCollider(); + // if obj is an InteractionTrigger then we signal hit + if (obj is InteractionTrigger trigger) + { + Trigger = trigger; + } + } + else + { + Trigger = null; + } + } +} diff --git a/BoundingBoxes/InteractionReceiver.cs b/BoundingBoxes/InteractionReceiver.cs new file mode 100644 index 0000000..a568339 --- /dev/null +++ b/BoundingBoxes/InteractionReceiver.cs @@ -0,0 +1,8 @@ +using Godot; +using System.Collections.Generic; + +namespace SupaLidlGame.BoundingBoxes; + +public partial class InteractionReceiver : Area2D +{ +} diff --git a/BoundingBoxes/InteractionReceiver.tscn b/BoundingBoxes/InteractionReceiver.tscn new file mode 100644 index 0000000..a2d86bc --- /dev/null +++ b/BoundingBoxes/InteractionReceiver.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=3 format=3 uid="uid://cdxiutj5jdnvo"] + +[ext_resource type="Script" path="res://BoundingBoxes/InteractionReceiver.cs" id="1_y2pab"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_vcbnn"] +radius = 16.0 + +[node name="InteractionReceiver" type="Area2D"] +collision_layer = 32 +collision_mask = 64 +script = ExtResource("1_y2pab") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_vcbnn") +debug_color = Color(0.792157, 0.0705882, 1, 0.419608) + +[connection signal="area_entered" from="." to="." method="_on_area_entered"] +[connection signal="area_exited" from="." to="." method="_on_area_exited"] diff --git a/BoundingBoxes/InteractionTrigger.cs b/BoundingBoxes/InteractionTrigger.cs new file mode 100644 index 0000000..1e7b830 --- /dev/null +++ b/BoundingBoxes/InteractionTrigger.cs @@ -0,0 +1,24 @@ +using Godot; +using SupaLidlGame.Characters; + +namespace SupaLidlGame.BoundingBoxes; + +public partial class InteractionTrigger : Area2D +{ + [Signal] + public delegate void InteractionEventHandler(); + + [Signal] + public delegate void TargetEventHandler(); + + [Signal] + public delegate void UntargetEventHandler(); + + /// + /// Invokes or triggers an interaction to occur. + /// + public void InvokeInteraction() + { + EmitSignal(SignalName.Interaction); + } +} diff --git a/BoundingBoxes/InteractionTrigger.tscn b/BoundingBoxes/InteractionTrigger.tscn new file mode 100644 index 0000000..48e8d89 --- /dev/null +++ b/BoundingBoxes/InteractionTrigger.tscn @@ -0,0 +1,14 @@ +[gd_scene load_steps=3 format=3 uid="uid://dldnp8eunxj3q"] + +[ext_resource type="Script" path="res://BoundingBoxes/InteractionTrigger.cs" id="1_uoemj"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_dfj3a"] + +[node name="InteractionTrigger" type="Area2D"] +collision_layer = 64 +collision_mask = 0 +script = ExtResource("1_uoemj") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("RectangleShape2D_dfj3a") +debug_color = Color(0.905882, 0, 0.745098, 0.419608) diff --git a/Characters/Character.cs b/Characters/Character.cs index 74fdbe6..e986353 100644 --- a/Characters/Character.cs +++ b/Characters/Character.cs @@ -1,4 +1,5 @@ using Godot; +using GodotUtilities; using SupaLidlGame.Extensions; using SupaLidlGame.Items; using SupaLidlGame.Utils; @@ -25,6 +26,12 @@ public partial class Character : CharacterBody2D, IFaction } } + [Signal] + public delegate void HurtEventHandler(Events.HealthChangedArgs args); + + [Signal] + public delegate void DeathEventHandler(Events.HealthChangedArgs args); + protected float _mass = 1.0f; public Vector2 NetImpulse { get; set; } = Vector2.Zero; @@ -67,9 +74,17 @@ public partial class Character : CharacterBody2D, IFaction [Export] public CharacterStateMachine StateMachine { get; set; } + [Export] + public BoundingBoxes.Hurtbox Hurtbox { get; set; } + [Export] public ushort Faction { get; set; } + public override void _Ready() + { + Hurtbox.ReceivedDamage += OnReceivedDamage; + } + public override void _Process(double delta) { if (StateMachine != null) @@ -81,14 +96,6 @@ public partial class Character : CharacterBody2D, IFaction DrawTarget(); } - public override void _Input(InputEvent @event) - { - if (StateMachine != null) - { - StateMachine.Input(@event); - } - } - public override void _PhysicsProcess(double delta) { if (StateMachine != null) @@ -127,7 +134,7 @@ public partial class Character : CharacterBody2D, IFaction StunTime += time; } - protected void DrawTarget() + protected virtual void DrawTarget() { Vector2 target = Target; float angle = Mathf.Atan2(target.Y, Mathf.Abs(target.X)); @@ -167,13 +174,19 @@ public partial class Character : CharacterBody2D, IFaction } } - public virtual void _on_hurtbox_received_damage( + public virtual void OnReceivedDamage( float damage, Character inflictor, float knockback, Vector2 knockbackOrigin = default, Vector2 knockbackVector = default) { + if (Health <= 0) + { + return; + } + + float oldHealth = Health; Health -= damage; // create damage text @@ -189,7 +202,14 @@ public partial class Character : CharacterBody2D, IFaction { if (knockbackOrigin == default) { - knockbackOrigin = inflictor.GlobalPosition; + if (inflictor is null) + { + knockbackOrigin = GlobalPosition + Vector2.Down; + } + else + { + knockbackOrigin = inflictor.GlobalPosition; + } } knockbackDir = knockbackOrigin.DirectionTo(GlobalPosition); @@ -217,7 +237,25 @@ public partial class Character : CharacterBody2D, IFaction if (this.GetNode("HurtSound") is AudioStreamPlayer2D sound) { // very small pitch deviation - sound.At(GlobalPosition).WithPitchDeviation(0.125f).Play(); + sound.At(GlobalPosition).WithPitchDeviation(0.125f).PlayOneShot(); + } + + Events.HealthChangedArgs args = new Events.HealthChangedArgs + { + Attacker = inflictor, + OldHealth = oldHealth, + NewHealth = Health, + Damage = damage, + }; + + EmitSignal(SignalName.Hurt, args); + + if (Health <= 0) + { + EmitSignal(SignalName.Death, args); + GetNode("DeathParticles") + .CloneOnWorld() + .EmitOneShot(); } } } diff --git a/Characters/Doc.cs b/Characters/Doc.cs new file mode 100644 index 0000000..67d9a2b --- /dev/null +++ b/Characters/Doc.cs @@ -0,0 +1,37 @@ +using Godot; + +namespace SupaLidlGame.Characters; + +public partial class Doc : Enemy +{ + [Export] + public State.NPC.NPCStateMachine BossStateMachine { get; set; } + + public int Intensity + { + get + { + switch (Health) + { + case < 250: + return 3; + case < 500: + return 2; + default: + return 1; + } + } + } + + public override void _Ready() + { + GD.Print(Health); + base._Ready(); + } + + public override void _Process(double delta) + { + BossStateMachine.Process(delta); + base._Process(delta); + } +} diff --git a/Characters/Doc.tscn b/Characters/Doc.tscn new file mode 100644 index 0000000..fef7ca4 --- /dev/null +++ b/Characters/Doc.tscn @@ -0,0 +1,316 @@ +[gd_scene load_steps=36 format=3 uid="uid://d2skjvvx6fal0"] + +[ext_resource type="Script" path="res://Characters/Doc.cs" id="2_3elet"] +[ext_resource type="Shader" path="res://Shaders/Flash.gdshader" id="2_5jxom"] +[ext_resource type="Texture2D" uid="uid://baiuqgrqipppt" path="res://Assets/Sprites/Characters/doc.png" id="3_rs44f"] +[ext_resource type="Script" path="res://State/Character/CharacterStateMachine.cs" id="3_t5jjc"] +[ext_resource type="Script" path="res://State/Character/NPCIdleState.cs" id="4_b35px"] +[ext_resource type="Script" path="res://State/Character/NPCMoveState.cs" id="5_pejsd"] +[ext_resource type="Script" path="res://State/NPC/NPCStateMachine.cs" id="6_kjpug"] +[ext_resource type="Script" path="res://State/NPC/Doc/DocTelegraphState.cs" id="7_tfwbh"] +[ext_resource type="PackedScene" uid="uid://cjgxyhgcyvsv7" path="res://BoundingBoxes/Hurtbox.tscn" id="7_tnve0"] +[ext_resource type="Script" path="res://State/NPC/Doc/DocShungiteDartState.cs" id="8_1hoax"] +[ext_resource type="Script" path="res://Items/Inventory.cs" id="8_r8ejq"] +[ext_resource type="Script" path="res://State/NPC/Doc/DocExitState.cs" id="9_6com1"] +[ext_resource type="PackedScene" uid="uid://1tiswf3gtyvv" path="res://Entities/ShungiteSpike.tscn" id="9_7kavk"] +[ext_resource type="PackedScene" uid="uid://djaljmco3xo4g" path="res://Entities/ShungiteDart.tscn" id="9_kthpr"] +[ext_resource type="AudioStream" uid="uid://k6kpdj1kv0jg" path="res://Assets/Sounds/splat.ogg" id="9_stm0e"] +[ext_resource type="Script" path="res://State/NPC/Doc/DocShungiteSpikeState.cs" id="10_bgs6o"] +[ext_resource type="Script" path="res://State/NPC/Doc/DocChooseAttackState.cs" id="12_45x13"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_7n7iy"] +resource_local_to_scene = true +shader = ExtResource("2_5jxom") +shader_parameter/color = Quaternion(1, 1, 1, 1) +shader_parameter/intensity = 0.0 + +[sub_resource type="Animation" id="Animation_7oukw"] +resource_name = "enter_in" +length = 0.5 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("../Sprite:scale") +tracks/0/interp = 2 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.4), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Vector2(2, 0.5), Vector2(1, 1)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("../Sprite:modulate") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 0.5), +"transitions": PackedFloat32Array(2, 1), +"update": 0, +"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 0.5)] +} + +[sub_resource type="Animation" id="Animation_j3s0y"] +resource_name = "exit_out" +length = 0.5 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("../Sprite:scale") +tracks/0/interp = 2 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.4), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Vector2(1, 1), Vector2(2, 0.5)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("../Sprite:modulate") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 0.5), +"transitions": PackedFloat32Array(1, 2), +"update": 0, +"values": [Color(1, 1, 1, 0.5), Color(1, 1, 1, 0)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_rpply"] +_data = { +"enter_in": SubResource("Animation_7oukw"), +"exit_out": SubResource("Animation_j3s0y") +} + +[sub_resource type="AtlasTexture" id="AtlasTexture_dib6t"] +atlas = ExtResource("3_rs44f") +region = Rect2(0, 0, 12, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_cwqre"] +atlas = ExtResource("3_rs44f") +region = Rect2(12, 0, 12, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_r8xjl"] +atlas = ExtResource("3_rs44f") +region = Rect2(24, 0, 12, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_7hkj4"] +atlas = ExtResource("3_rs44f") +region = Rect2(36, 0, 12, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_w04w0"] +atlas = ExtResource("3_rs44f") +region = Rect2(48, 0, 12, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ym6tg"] +atlas = ExtResource("3_rs44f") +region = Rect2(60, 0, 12, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_3rbas"] +atlas = ExtResource("3_rs44f") +region = Rect2(72, 0, 12, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_63wkp"] +atlas = ExtResource("3_rs44f") +region = Rect2(84, 0, 12, 16) + +[sub_resource type="SpriteFrames" id="SpriteFrames_kb0pl"] +resource_local_to_scene = true +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_dib6t") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_cwqre") +}], +"loop": true, +"name": &"idle", +"speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_r8xjl") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_7hkj4") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_w04w0") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ym6tg") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_3rbas") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_63wkp") +}], +"loop": true, +"name": &"move", +"speed": 12.0 +}] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_uict5"] +size = Vector2(16, 8) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_8lxmf"] +size = Vector2(16, 18) + +[sub_resource type="Animation" id="Animation_dxevc"] +resource_name = "Hurt" +length = 0.6 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:material:shader_parameter/intensity") +tracks/0/interp = 2 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6), +"transitions": PackedFloat32Array(4, 4, 4, 4, 4, 4, 4), +"update": 0, +"values": [0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0] +} + +[sub_resource type="Animation" id="Animation_k6l16"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:material:shader_parameter/intensity") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [0.0] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_xe5eq"] +_data = { +"Hurt": SubResource("Animation_dxevc"), +"RESET": SubResource("Animation_k6l16") +} + +[node name="Doc" type="CharacterBody2D" node_paths=PackedStringArray("BossStateMachine", "Sprite", "Inventory", "StateMachine", "Hurtbox")] +y_sort_enabled = true +texture_filter = 3 +material = SubResource("ShaderMaterial_7n7iy") +collision_layer = 10 +collision_mask = 17 +script = ExtResource("2_3elet") +BossStateMachine = NodePath("BossStateMachine") +Health = 1000.0 +Sprite = NodePath("Sprite") +Inventory = NodePath("Inventory") +StateMachine = NodePath("StateMachine") +Hurtbox = NodePath("Hurtbox") +Faction = 2 + +[node name="StateMachine" type="Node" parent="." node_paths=PackedStringArray("InitialState", "Character")] +script = ExtResource("3_t5jjc") +InitialState = NodePath("Idle") +Character = NodePath("..") + +[node name="Idle" type="Node" parent="StateMachine" node_paths=PackedStringArray("MoveState", "Character")] +script = ExtResource("4_b35px") +MoveState = NodePath("../Move") +Character = NodePath("../..") + +[node name="Move" type="Node" parent="StateMachine" node_paths=PackedStringArray("IdleState", "Character")] +script = ExtResource("5_pejsd") +IdleState = NodePath("../Idle") +Character = NodePath("../..") + +[node name="BossStateMachine" type="Node" parent="." node_paths=PackedStringArray("InitialState")] +script = ExtResource("6_kjpug") +InitialState = NodePath("Telegraph") + +[node name="Telegraph" type="Node" parent="BossStateMachine" node_paths=PackedStringArray("TelegraphAnimationPlayer", "AttackState", "NPC")] +script = ExtResource("7_tfwbh") +TelegraphAnimationPlayer = NodePath("../../Animations/Telegraph") +AttackState = NodePath("../ChooseAttack") +NPC = NodePath("../..") + +[node name="Dart" type="Node" parent="BossStateMachine" node_paths=PackedStringArray("ChooseAttackState", "Doc", "NPC")] +script = ExtResource("8_1hoax") +Duration = 8.0 +AttackDuration = 1.0 +Projectile = ExtResource("9_kthpr") +ChooseAttackState = NodePath("../ChooseAttack") +Doc = NodePath("../..") +NPC = NodePath("../..") + +[node name="Spike" type="Node" parent="BossStateMachine" node_paths=PackedStringArray("ChooseAttackState", "Doc", "NPC")] +script = ExtResource("10_bgs6o") +Duration = 8.0 +AttackDuration = 1.0 +Projectile = ExtResource("9_7kavk") +ChooseAttackState = NodePath("../ChooseAttack") +Doc = NodePath("../..") +NPC = NodePath("../..") + +[node name="ChooseAttack" type="Node" parent="BossStateMachine" node_paths=PackedStringArray("DartState", "SpikeState", "ExitState", "NPC")] +script = ExtResource("12_45x13") +DartState = NodePath("../Dart") +SpikeState = NodePath("../Spike") +ExitState = NodePath("../Exit") +NPC = NodePath("../..") + +[node name="Exit" type="Node" parent="BossStateMachine" node_paths=PackedStringArray("TelegraphAnimationPlayer", "TelegraphState", "NPC")] +script = ExtResource("9_6com1") +TelegraphAnimationPlayer = NodePath("../../Animations/Telegraph") +TelegraphState = NodePath("../Telegraph") +NPC = NodePath("../..") + +[node name="Animations" type="Node" parent="."] + +[node name="Telegraph" type="AnimationPlayer" parent="Animations"] +libraries = { +"": SubResource("AnimationLibrary_rpply") +} + +[node name="Sprite" type="AnimatedSprite2D" parent="."] +modulate = Color(1, 1, 1, 0.5) +use_parent_material = true +position = Vector2(0, -4) +sprite_frames = SubResource("SpriteFrames_kb0pl") +animation = &"move" +frame_progress = 0.563144 +offset = Vector2(0, 4) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +visible = false +position = Vector2(0, 4) +shape = SubResource("RectangleShape2D_uict5") + +[node name="Hurtbox" parent="." instance=ExtResource("7_tnve0")] +visible = false +position = Vector2(0, -4) +Faction = 2 + +[node name="CollisionShape2D" parent="Hurtbox" index="0"] +position = Vector2(0, 4) +shape = SubResource("RectangleShape2D_8lxmf") + +[node name="Inventory" type="Node2D" parent="."] +y_sort_enabled = true +script = ExtResource("8_r8ejq") +Items = Array[Node2D]([]) + +[node name="FlashAnimation" type="AnimationPlayer" parent="."] +libraries = { +"": SubResource("AnimationLibrary_xe5eq") +} + +[node name="HurtSound" type="AudioStreamPlayer2D" parent="."] +stream = ExtResource("9_stm0e") + +[editable path="Hurtbox"] diff --git a/Characters/Enemy.cs b/Characters/Enemy.cs index 4d5b335..a508679 100644 --- a/Characters/Enemy.cs +++ b/Characters/Enemy.cs @@ -5,12 +5,6 @@ namespace SupaLidlGame.Characters; public partial class Enemy : NPC { - public override void _Ready() - { - Inventory.SelectedItem = Inventory.GetNode("Sword"); - base._Ready(); - } - public override void Die() { base.Die(); diff --git a/Characters/ExampleEnemy.tscn b/Characters/ExampleEnemy.tscn index cbf1c2e..88734cd 100644 --- a/Characters/ExampleEnemy.tscn +++ b/Characters/ExampleEnemy.tscn @@ -130,7 +130,7 @@ _data = { "RESET": SubResource("Animation_k6l16") } -[node name="ExampleEnemy" type="CharacterBody2D" node_paths=PackedStringArray("Sprite", "Inventory", "StateMachine")] +[node name="ExampleEnemy" type="CharacterBody2D" node_paths=PackedStringArray("Sprite", "Inventory", "StateMachine", "Hurtbox")] y_sort_enabled = true texture_filter = 3 material = SubResource("ShaderMaterial_ms3xg") @@ -141,6 +141,7 @@ Health = 50.0 Sprite = NodePath("Sprite") Inventory = NodePath("Inventory") StateMachine = NodePath("StateMachine") +Hurtbox = NodePath("Hurtbox") Faction = 2 [node name="StateMachine" type="Node" parent="." node_paths=PackedStringArray("InitialState", "Character")] @@ -191,6 +192,4 @@ libraries = { [node name="HurtSound" type="AudioStreamPlayer2D" parent="."] stream = ExtResource("10_n1e64") -[connection signal="ReceivedDamage" from="Hurtbox" to="." method="_on_hurtbox_received_damage"] - [editable path="Hurtbox"] diff --git a/Characters/NPC.cs b/Characters/NPC.cs index 1e34d27..96ecb65 100644 --- a/Characters/NPC.cs +++ b/Characters/NPC.cs @@ -92,8 +92,13 @@ public partial class NPC : Character Character bestChar = null; foreach (Node node in GetParent().GetChildren()) { - if (node is Character character && character.Faction != Faction) + if (node is Character character) { + if (character.Faction == Faction || character.Health <= 0) + { + continue; + } + float dist = Position.DistanceTo(character.Position); if (dist < bestDist) { diff --git a/Characters/Player.cs b/Characters/Player.cs index 755fbab..1891a2f 100644 --- a/Characters/Player.cs +++ b/Characters/Player.cs @@ -1,9 +1,12 @@ using Godot; +using GodotUtilities; using SupaLidlGame.Utils; +using SupaLidlGame.BoundingBoxes; namespace SupaLidlGame.Characters; -public partial class Player : Character +[Scene] +public sealed partial class Player : Character { private AnimatedSprite2D _sprite; private string _spriteAnim; @@ -11,6 +14,11 @@ public partial class Player : Character [Export] public PlayerCamera Camera { get; set; } + [Export] + public Marker2D DirectionMarker { get; private set; } + + public InteractionRay InteractionRay { get; private set; } + public string Animation { get => _sprite.Animation; @@ -32,11 +40,31 @@ public partial class Player : Character public override void _Ready() { + InteractionRay = GetNode("Direction2D/InteractionRay"); _sprite = GetNode("Sprite"); if (_spriteAnim != default) { _sprite.Animation = _spriteAnim; } + base._Ready(); + Death += (Events.HealthChangedArgs args) => + { + Visible = false; + }; + } + + public override void _Input(InputEvent @event) + { + if (StateMachine != null) + { + StateMachine.Input(@event); + } + } + + public void Spawn() + { + Health = 100; + Visible = true; } public override void ModifyVelocity() @@ -61,4 +89,12 @@ public partial class Player : Character GD.Print("died"); //base.Die(); } + + protected override void DrawTarget() + { + base.DrawTarget(); + DirectionMarker.GlobalRotation = DirectionMarker.GlobalPosition + .DirectionTo(GetGlobalMousePosition()) + .Angle(); + } } diff --git a/Characters/Player.tscn b/Characters/Player.tscn index cb23d86..b3a2f7e 100644 --- a/Characters/Player.tscn +++ b/Characters/Player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=30 format=3 uid="uid://b2254pup8k161"] +[gd_scene load_steps=39 format=3 uid="uid://b2254pup8k161"] [ext_resource type="Script" path="res://Characters/Player.cs" id="1_flygr"] [ext_resource type="Shader" path="res://Shaders/Flash.gdshader" id="2_ngsgt"] @@ -11,8 +11,10 @@ [ext_resource type="Script" path="res://Items/Inventory.cs" id="7_xyenu"] [ext_resource type="Script" path="res://State/Character/PlayerRollState.cs" id="8_fy0v5"] [ext_resource type="PackedScene" uid="uid://cjgxyhgcyvsv7" path="res://BoundingBoxes/Hurtbox.tscn" id="9_avyu4"] -[ext_resource type="PackedScene" uid="uid://g7wfcubs6bdd" path="res://Items/Weapons/Railgun.tscn" id="10_7kb8b"] -[ext_resource type="AudioStream" uid="uid://njun3e6v4854" path="res://Assets/Sounds/hurt.wav" id="12_h0x0g"] +[ext_resource type="AudioStream" uid="uid://bkeyg8weaqnuu" path="res://Assets/Sounds/splat-player.ogg" id="12_vvem5"] +[ext_resource type="Script" path="res://BoundingBoxes/InteractionRay.cs" id="13_hs3u1"] +[ext_resource type="Texture2D" uid="uid://coarr28adgo1u" path="res://Assets/Sprites/Particles/point-light.png" id="14_l4ekh"] +[ext_resource type="Script" path="res://Utils/DamageTime.cs" id="15_4xl06"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_h78y7"] shader = ExtResource("2_ngsgt") @@ -89,7 +91,7 @@ animations = [{ }] [sub_resource type="RectangleShape2D" id="RectangleShape2D_bfqew"] -size = Vector2(16, 8) +size = Vector2(12, 8) [sub_resource type="LabelSettings" id="LabelSettings_q5h1n"] font_size = 24 @@ -134,19 +136,83 @@ _data = { "RESET": SubResource("Animation_k6l16") } -[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("Camera", "Sprite", "Inventory", "StateMachine")] +[sub_resource type="Animation" id="Animation_yejx2"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite:rotation") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [0.0] +} + +[sub_resource type="Animation" id="Animation_rx2pj"] +resource_name = "roll" +length = 0.5 +step = 0.05 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite:rotation") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.25, 0.5), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [0.0, 3.14159, 6.28319] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_jai06"] +_data = { +"RESET": SubResource("Animation_yejx2"), +"roll": SubResource("Animation_rx2pj") +} + +[sub_resource type="Gradient" id="Gradient_3tax5"] +offsets = PackedFloat32Array(0.533333, 1) +colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0) + +[sub_resource type="GradientTexture1D" id="GradientTexture1D_pjeh8"] +gradient = SubResource("Gradient_3tax5") + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_humq0"] +emission_shape = 1 +emission_sphere_radius = 1.0 +particle_flag_disable_z = true +direction = Vector3(0, 0, 0) +spread = 180.0 +gravity = Vector3(0, 0, 0) +initial_velocity_min = 32.0 +initial_velocity_max = 32.0 +orbit_velocity_min = 0.0 +orbit_velocity_max = 0.1 +tangential_accel_min = 64.0 +tangential_accel_max = 64.0 +color_ramp = SubResource("GradientTexture1D_pjeh8") + +[sub_resource type="CanvasTexture" id="CanvasTexture_pited"] + +[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("Camera", "DirectionMarker", "Sprite", "Inventory", "StateMachine", "Hurtbox")] y_sort_enabled = true texture_filter = 3 material = SubResource("ShaderMaterial_h78y7") -position = Vector2(0, -12) +position = Vector2(1, -12) collision_layer = 6 collision_mask = 17 script = ExtResource("1_flygr") Camera = NodePath("Camera2D") +DirectionMarker = NodePath("Direction2D") Speed = 64.0 Sprite = NodePath("Sprite") Inventory = NodePath("Inventory") StateMachine = NodePath("StateMachine") +Hurtbox = NodePath("Hurtbox") Faction = 1 [node name="StateMachine" type="Node" parent="." node_paths=PackedStringArray("InitialState", "Character")] @@ -176,8 +242,10 @@ position_smoothing_speed = 8.0 [node name="Sprite" type="AnimatedSprite2D" parent="."] use_parent_material = true +position = Vector2(0, 4) sprite_frames = SubResource("SpriteFrames_2h7cf") animation = &"idle" +offset = Vector2(0, -4) [node name="CollisionShape2D" type="CollisionShape2D" parent="."] position = Vector2(0, 8) @@ -201,7 +269,6 @@ horizontal_alignment = 1 [node name="Node" type="Node" parent="."] [node name="Inventory" type="Node2D" parent="."] -y_sort_enabled = true position = Vector2(0, 4) script = ExtResource("7_xyenu") InventoryMap = { @@ -209,9 +276,8 @@ InventoryMap = { "equip_2": 1 } -[node name="Railgun" parent="Inventory" instance=ExtResource("10_7kb8b")] - [node name="Node2D" parent="Inventory" instance=ExtResource("7_4rxuv")] +visible = false ShouldHideIdle = false [node name="Hurtbox" parent="." instance=ExtResource("9_avyu4")] @@ -226,13 +292,44 @@ libraries = { "": SubResource("AnimationLibrary_xe5eq") } +[node name="RollAnimation" type="AnimationPlayer" parent="."] +libraries = { +"": SubResource("AnimationLibrary_jai06") +} + [node name="HurtSound" type="AudioStreamPlayer2D" parent="."] -stream = ExtResource("12_h0x0g") +stream = ExtResource("12_vvem5") max_distance = 64.0 [node name="AudioListener2D" type="AudioListener2D" parent="."] current = true -[connection signal="ReceivedDamage" from="Hurtbox" to="." method="_on_hurtbox_received_damage"] +[node name="Direction2D" type="Marker2D" parent="."] +position = Vector2(0, 6) + +[node name="InteractionRay" type="RayCast2D" parent="Direction2D"] +target_position = Vector2(16, 0) +collision_mask = 64 +collide_with_areas = true +script = ExtResource("13_hs3u1") + +[node name="DeathParticles" type="GPUParticles2D" parent="."] +emitting = false +amount = 16 +process_material = SubResource("ParticleProcessMaterial_humq0") +texture = SubResource("CanvasTexture_pited") +one_shot = true +explosiveness = 0.9 + +[node name="PointLight2D" type="PointLight2D" parent="."] +blend_mode = 2 +shadow_enabled = true +shadow_filter = 2 +shadow_filter_smooth = 3.0 +texture = ExtResource("14_l4ekh") +texture_scale = 0.5 + +[node name="DamageTime" type="Node" parent="."] +script = ExtResource("15_4xl06") [editable path="Hurtbox"] diff --git a/Entities/Campfire.cs b/Entities/Campfire.cs index 5572dbb..3e22de4 100644 --- a/Entities/Campfire.cs +++ b/Entities/Campfire.cs @@ -1,23 +1,35 @@ using Godot; -using System; +using GodotUtilities; +using SupaLidlGame.BoundingBoxes; namespace SupaLidlGame.Entities; -public partial class Campfire : StaticBody2D +[Scene] +public partial class Campfire : StaticBody2D, Utils.IInteractive { private PointLight2D _light; + public InteractionTrigger InteractionTrigger { get; set; } + [Signal] - public delegate void OnCampfireUseEventHandler(); + public delegate void UseEventHandler(); public override void _Ready() { + InteractionTrigger = GetNode("InteractionTrigger"); _light = GetNode("PointLight2D"); + InteractionTrigger.Interaction += () => + { + // save the player's spawn position to be their position on interaction + EmitSignal(SignalName.Use); + + this.GetAncestor().SetSpawn(GlobalPosition); + }; } public override void _Process(double delta) { _light.Energy += (GD.Randf() - 0.5f) * 8 * (float)delta; - _light.Energy = Math.Clamp(_light.Energy, 1.2f, 2.0f); + _light.Energy = Mathf.Clamp(_light.Energy, 1.8f, 2f); } } diff --git a/Entities/Campfire.tscn b/Entities/Campfire.tscn index d5c10ce..03bf26c 100644 --- a/Entities/Campfire.tscn +++ b/Entities/Campfire.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=11 format=3 uid="uid://dhl071rj5wyvx"] +[gd_scene load_steps=18 format=3 uid="uid://dhl071rj5wyvx"] [ext_resource type="Texture2D" uid="uid://yqet0b22i70d" path="res://Assets/Sprites/campfire.png" id="1_7eor7"] [ext_resource type="Script" path="res://Entities/Campfire.cs" id="1_w4gfp"] [ext_resource type="Texture2D" uid="uid://coarr28adgo1u" path="res://Assets/Sprites/Particles/point-light.png" id="3_lm3vq"] +[ext_resource type="PackedScene" uid="uid://dldnp8eunxj3q" path="res://BoundingBoxes/InteractionTrigger.tscn" id="4_yoo3p"] [sub_resource type="AtlasTexture" id="AtlasTexture_68qj1"] atlas = ExtResource("1_7eor7") @@ -55,6 +56,41 @@ animations = [{ [sub_resource type="RectangleShape2D" id="RectangleShape2D_ubam4"] size = Vector2(16, 4) +[sub_resource type="RectangleShape2D" id="RectangleShape2D_p0hsm"] +size = Vector2(20, 10) + +[sub_resource type="Gradient" id="Gradient_cr0xb"] +offsets = PackedFloat32Array(0, 0.644444, 1) +colors = PackedColorArray(2, 1.6, 0.8, 1, 0.863171, 0.393552, 0.380535, 1, 0.304405, 0.24341, 0.229614, 1) + +[sub_resource type="GradientTexture1D" id="GradientTexture1D_pjqf7"] +gradient = SubResource("Gradient_cr0xb") + +[sub_resource type="Curve" id="Curve_jm83f"] +_data = [Vector2(0.144578, 1), 0.0, 0.0, 0, 0, Vector2(1, 0.4), 0.0, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="CurveTexture" id="CurveTexture_jpefi"] +curve = SubResource("Curve_jm83f") + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_xtx2m"] +emission_shape = 1 +emission_sphere_radius = 5.0 +particle_flag_disable_z = true +direction = Vector3(0, -1, 0) +spread = 0.0 +gravity = Vector3(0, -16, 0) +initial_velocity_min = 16.0 +initial_velocity_max = 16.0 +orbit_velocity_min = 0.0 +orbit_velocity_max = 0.0 +radial_accel_min = -40.0 +radial_accel_max = -20.0 +scale_min = 2.0 +scale_max = 4.0 +scale_curve = SubResource("CurveTexture_jpefi") +color_ramp = SubResource("GradientTexture1D_pjqf7") + [node name="Campfire" type="StaticBody2D"] texture_filter = 3 position = Vector2(0, -8) @@ -62,15 +98,29 @@ script = ExtResource("1_w4gfp") [node name="Sprite2D" type="AnimatedSprite2D" parent="."] sprite_frames = SubResource("SpriteFrames_o6lfi") -frame_progress = 0.387757 +animation = &"active" +frame_progress = 0.343741 [node name="PointLight2D" type="PointLight2D" parent="."] color = Color(0.996078, 0.780392, 0.615686, 1) energy = 2.0 blend_mode = 2 +shadow_enabled = true texture = ExtResource("3_lm3vq") texture_scale = 0.25 [node name="CollisionShape2D" type="CollisionShape2D" parent="."] position = Vector2(0, 6) shape = SubResource("RectangleShape2D_ubam4") + +[node name="InteractionTrigger" parent="." instance=ExtResource("4_yoo3p")] + +[node name="CollisionShape2D" parent="InteractionTrigger" index="0"] +position = Vector2(0, 5) +shape = SubResource("RectangleShape2D_p0hsm") + +[node name="GPUParticles2D" type="GPUParticles2D" parent="."] +amount = 40 +process_material = SubResource("ParticleProcessMaterial_xtx2m") + +[editable path="InteractionTrigger"] diff --git a/Entities/Projectile.cs b/Entities/Projectile.cs index 06c1f71..3e1a40c 100644 --- a/Entities/Projectile.cs +++ b/Entities/Projectile.cs @@ -20,10 +20,22 @@ public partial class Projectile : RigidBody2D [Export] public double Lifetime { get; set; } = 10; + [Export] + public double Delay { get; set; } = 0; + public Character Character { get; set; } + public override void _Ready() + { + Hitbox.Hit += OnHit; + } + public override void _Process(double delta) { + if (Delay > 0) + { + Delay -= delta; + } if ((Lifetime -= delta) <= 0) { QueueFree(); @@ -32,11 +44,11 @@ public partial class Projectile : RigidBody2D public override void _PhysicsProcess(double delta) { - Vector2 velocity = Velocity; + Vector2 velocity = Delay <= 0 ? Velocity : Vector2.Zero; MoveAndCollide(velocity * (float)delta); } - public void _on_hitbox_hit(BoundingBox box) + public void OnHit(BoundingBox box) { if (box is Hurtbox hurtbox) { diff --git a/Entities/RailBeam.tscn b/Entities/RailBeam.tscn index 1a41828..49eeafb 100644 --- a/Entities/RailBeam.tscn +++ b/Entities/RailBeam.tscn @@ -27,6 +27,4 @@ Knockback = 256.0 [node name="CollisionShape2D" parent="Hitbox" index="0"] shape = SubResource("RectangleShape2D_j0tne") -[connection signal="Hit" from="Hitbox" to="." method="_on_hitbox_hit"] - [editable path="Hitbox"] diff --git a/Entities/ShungiteDart.cs b/Entities/ShungiteDart.cs new file mode 100644 index 0000000..302c3db --- /dev/null +++ b/Entities/ShungiteDart.cs @@ -0,0 +1,17 @@ +using Godot; + +namespace SupaLidlGame.Entities; + +public partial class ShungiteDart : Projectile +{ + public override void _Ready() + { + var player = GetNode("AnimationPlayer"); + if (Delay > 0) + { + player.Play("spin"); + player.SpeedScale = (float)(1 / Delay); + } + base._Ready(); + } +} diff --git a/Entities/ShungiteDart.tscn b/Entities/ShungiteDart.tscn new file mode 100644 index 0000000..302dd9e --- /dev/null +++ b/Entities/ShungiteDart.tscn @@ -0,0 +1,303 @@ +[gd_scene load_steps=41 format=3 uid="uid://djaljmco3xo4g"] + +[ext_resource type="Script" path="res://Entities/ShungiteDart.cs" id="1_jbgb8"] +[ext_resource type="Texture2D" uid="uid://dmeqjcc3uu4xi" path="res://Assets/Sprites/Misc/shungite.png" id="2_eh4e1"] +[ext_resource type="PackedScene" uid="uid://du5vhccg75nrq" path="res://BoundingBoxes/Hitbox.tscn" id="3_gdyk8"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_xmjp8"] +atlas = ExtResource("2_eh4e1") +region = Rect2(0, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_8i61s"] +atlas = ExtResource("2_eh4e1") +region = Rect2(8, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_q000r"] +atlas = ExtResource("2_eh4e1") +region = Rect2(16, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_0f7fg"] +atlas = ExtResource("2_eh4e1") +region = Rect2(24, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_d34ii"] +atlas = ExtResource("2_eh4e1") +region = Rect2(32, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_iybvf"] +atlas = ExtResource("2_eh4e1") +region = Rect2(40, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_rninu"] +atlas = ExtResource("2_eh4e1") +region = Rect2(48, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_8vok2"] +atlas = ExtResource("2_eh4e1") +region = Rect2(56, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_7tcc7"] +atlas = ExtResource("2_eh4e1") +region = Rect2(64, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_sfa0w"] +atlas = ExtResource("2_eh4e1") +region = Rect2(72, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_21chc"] +atlas = ExtResource("2_eh4e1") +region = Rect2(80, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_iroma"] +atlas = ExtResource("2_eh4e1") +region = Rect2(88, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_hbl5e"] +atlas = ExtResource("2_eh4e1") +region = Rect2(96, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_qlpso"] +atlas = ExtResource("2_eh4e1") +region = Rect2(104, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_v65pa"] +atlas = ExtResource("2_eh4e1") +region = Rect2(112, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_jotwh"] +atlas = ExtResource("2_eh4e1") +region = Rect2(120, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_lu113"] +atlas = ExtResource("2_eh4e1") +region = Rect2(128, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_w332l"] +atlas = ExtResource("2_eh4e1") +region = Rect2(136, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_mg73k"] +atlas = ExtResource("2_eh4e1") +region = Rect2(144, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_m0ogr"] +atlas = ExtResource("2_eh4e1") +region = Rect2(152, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_py1jk"] +atlas = ExtResource("2_eh4e1") +region = Rect2(160, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_0a8wd"] +atlas = ExtResource("2_eh4e1") +region = Rect2(168, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_8ut6e"] +atlas = ExtResource("2_eh4e1") +region = Rect2(176, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_x5ucf"] +atlas = ExtResource("2_eh4e1") +region = Rect2(184, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_13nfm"] +atlas = ExtResource("2_eh4e1") +region = Rect2(192, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_uhjdb"] +atlas = ExtResource("2_eh4e1") +region = Rect2(200, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_4vrn8"] +atlas = ExtResource("2_eh4e1") +region = Rect2(208, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_4aa2t"] +atlas = ExtResource("2_eh4e1") +region = Rect2(216, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_tn6f5"] +atlas = ExtResource("2_eh4e1") +region = Rect2(224, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_60mwy"] +atlas = ExtResource("2_eh4e1") +region = Rect2(232, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_d0xqb"] +atlas = ExtResource("2_eh4e1") +region = Rect2(240, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_j2hu2"] +atlas = ExtResource("2_eh4e1") +region = Rect2(248, 0, 8, 8) + +[sub_resource type="SpriteFrames" id="SpriteFrames_6a2jq"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_xmjp8") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_8i61s") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_q000r") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_0f7fg") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_d34ii") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_iybvf") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_rninu") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_8vok2") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_7tcc7") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_sfa0w") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_21chc") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_iroma") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_hbl5e") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_qlpso") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_v65pa") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_jotwh") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_lu113") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_w332l") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_mg73k") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_m0ogr") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_py1jk") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_0a8wd") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_8ut6e") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_x5ucf") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_13nfm") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_uhjdb") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_4vrn8") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_4aa2t") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_tn6f5") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_60mwy") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_d0xqb") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_j2hu2") +}], +"loop": true, +"name": &"default", +"speed": 5.0 +}] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_fa7yf"] +size = Vector2(8, 4) + +[sub_resource type="Animation" id="Animation_tcdo0"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:rotation") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [1.5708] +} + +[sub_resource type="Animation" id="Animation_tgj7f"] +resource_name = "spin" +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:rotation") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.5), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [-4.71239, 1.5708] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_pehte"] +_data = { +"RESET": SubResource("Animation_tcdo0"), +"spin": SubResource("Animation_tgj7f") +} + +[node name="ShungiteDart" type="RigidBody2D" node_paths=PackedStringArray("Hitbox")] +script = ExtResource("1_jbgb8") +Speed = 256.0 +Hitbox = NodePath("Hitbox") +Delay = 1.0 + +[node name="Sprite2D" type="AnimatedSprite2D" parent="."] +texture_filter = 1 +rotation = 1.5708 +sprite_frames = SubResource("SpriteFrames_6a2jq") +frame_progress = 0.227702 +speed_scale = 4.0 + +[node name="Hitbox" parent="." instance=ExtResource("3_gdyk8")] +Damage = 25.0 +Knockback = 128.0 + +[node name="CollisionShape2D" parent="Hitbox" index="0"] +shape = SubResource("RectangleShape2D_fa7yf") + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +libraries = { +"": SubResource("AnimationLibrary_pehte") +} + +[editable path="Hitbox"] diff --git a/Entities/ShungiteSpike.cs b/Entities/ShungiteSpike.cs new file mode 100644 index 0000000..c2d8d90 --- /dev/null +++ b/Entities/ShungiteSpike.cs @@ -0,0 +1,72 @@ +using Godot; +using GodotUtilities; +using SupaLidlGame.Extensions; + +namespace SupaLidlGame.Entities; + +public partial class ShungiteSpike : Projectile +{ + [Export] + public PackedScene Dart { get; set; } + + [Export] + public double ExplodeTime { get; set; } = 6; + + [Export] + public BoundingBoxes.Hurtbox Hurtbox { get; set; } + + [Export] + public AudioStreamPlayer2D HitSound { get; set; } + + [Export] + public AnimationPlayer AnimationPlayer { get; set; } + + private double _currentExplodeTime; + + private Scenes.Map _map; + + public override void _Ready() + { + _currentExplodeTime = ExplodeTime; + _map = this.GetAncestor(); + + Hurtbox.ReceivedDamage += OnReceivedDamage; + AnimationPlayer.Play("spin"); + + base._Ready(); + } + + private void OnReceivedDamage( + float damage, + Characters.Character inflictor, + float knockback, + Vector2 knockbackOrigin = default, + Vector2 knockbackVector = default) + { + HitSound.At(GlobalPosition).PlayOneShot(); + QueueFree(); + } + + + private Entities.ShungiteDart CreateDart(Vector2 direction) + { + var dart = _map.SpawnEntity(Dart); + dart.Direction = direction; + dart.Hitbox.Faction = Hitbox.Faction; + dart.GlobalPosition = GlobalPosition; + dart.Delay = 0; + return dart; + } + + public override void _Process(double delta) + { + if ((_currentExplodeTime -= delta) <= 0) + { + CreateDart(Vector2.Up); + CreateDart(Vector2.Down); + CreateDart(Vector2.Left); + CreateDart(Vector2.Right); + QueueFree(); + } + } +} diff --git a/Entities/ShungiteSpike.tscn b/Entities/ShungiteSpike.tscn new file mode 100644 index 0000000..9393476 --- /dev/null +++ b/Entities/ShungiteSpike.tscn @@ -0,0 +1,87 @@ +[gd_scene load_steps=12 format=3 uid="uid://1tiswf3gtyvv"] + +[ext_resource type="Script" path="res://Entities/ShungiteSpike.cs" id="1_pclpe"] +[ext_resource type="PackedScene" uid="uid://djaljmco3xo4g" path="res://Entities/ShungiteDart.tscn" id="2_hinxt"] +[ext_resource type="Texture2D" uid="uid://dvx2b0y6dup53" path="res://Assets/Sprites/Misc/shungite-spike.png" id="2_klp8v"] +[ext_resource type="PackedScene" uid="uid://du5vhccg75nrq" path="res://BoundingBoxes/Hitbox.tscn" id="3_kojrj"] +[ext_resource type="PackedScene" uid="uid://cjgxyhgcyvsv7" path="res://BoundingBoxes/Hurtbox.tscn" id="4_d8dl4"] +[ext_resource type="AudioStream" uid="uid://c4n7ioxpukdwi" path="res://Assets/Sounds/parry.wav" id="6_fepye"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_konb7"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_kumrg"] +radius = 20.0 + +[sub_resource type="Animation" id="Animation_dlpaa"] +resource_name = "spin" +length = 0.5 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:rotation") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.5), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [0.0, 6.28319] +} + +[sub_resource type="Animation" id="Animation_0vfvo"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:rotation") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [0.0] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_jj1qe"] +_data = { +"RESET": SubResource("Animation_0vfvo"), +"spin": SubResource("Animation_dlpaa") +} + +[node name="ShungiteSpike" type="RigidBody2D" node_paths=PackedStringArray("Hurtbox", "HitSound", "Hitbox")] +script = ExtResource("1_pclpe") +Dart = ExtResource("2_hinxt") +Hurtbox = NodePath("Hurtbox") +HitSound = NodePath("AudioStreamPlayer2D") +Hitbox = NodePath("Hitbox") + +[node name="Sprite2D" type="Sprite2D" parent="."] +modulate = Color(1.4, 0, 1.2, 1) +self_modulate = Color(2, 2, 2, 1) +texture_filter = 1 +texture = ExtResource("2_klp8v") + +[node name="Hitbox" parent="." instance=ExtResource("3_kojrj")] +Damage = 10.0 +Knockback = 256.0 + +[node name="CollisionShape2D" parent="Hitbox" index="0"] +shape = SubResource("RectangleShape2D_konb7") + +[node name="Hurtbox" parent="." instance=ExtResource("4_d8dl4")] + +[node name="CollisionShape2D" parent="Hurtbox" index="0"] +shape = SubResource("CircleShape2D_kumrg") + +[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."] +stream = ExtResource("6_fepye") + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +libraries = { +"": SubResource("AnimationLibrary_jj1qe") +} + +[editable path="Hitbox"] +[editable path="Hurtbox"] diff --git a/Events/Args.cs b/Events/Args.cs new file mode 100644 index 0000000..3deb8b1 --- /dev/null +++ b/Events/Args.cs @@ -0,0 +1,8 @@ +using Godot; + +namespace SupaLidlGame.Events; + +public abstract partial class Args : GodotObject +{ + +} diff --git a/Events/HealthChangedArgs.cs b/Events/HealthChangedArgs.cs new file mode 100644 index 0000000..ae6b957 --- /dev/null +++ b/Events/HealthChangedArgs.cs @@ -0,0 +1,14 @@ +namespace SupaLidlGame.Events; + +public partial class HealthChangedArgs : Args +{ + public Characters.Character Attacker { get; set; } + + public Items.Weapon Weapon { get; set; } + + public float OldHealth { get; set; } + + public float NewHealth { get; set; } + + public float Damage { get; set; } +} diff --git a/Extensions/AudioStreamPlayer2D.cs b/Extensions/AudioStreamPlayer2D.cs index 23339e7..0258eb3 100644 --- a/Extensions/AudioStreamPlayer2D.cs +++ b/Extensions/AudioStreamPlayer2D.cs @@ -1,6 +1,6 @@ using Godot; +using GodotUtilities; using System; -using SupaLidlGame.Utils; namespace SupaLidlGame.Extensions; @@ -44,7 +44,7 @@ public static class AudioStreamPlayer2DExtensions this AudioStreamPlayer2D audio, Vector2 globalPosition) { - var world = audio.GetTree().Root.GetNode("World/TileMap"); + var world = audio.GetAncestor(); if (world is null) { throw new NullReferenceException("World does not exist"); @@ -62,6 +62,15 @@ public static class AudioStreamPlayer2DExtensions return clone; } + public static AudioStreamPlayer2D PlayOneShot( + this AudioStreamPlayer2D audio, + float fromPosition = 0) + { + audio.Finished += () => audio.QueueFree(); + audio.Play(fromPosition); + return audio; + } + public static AudioStreamPlayer2D WithPitchDeviation( this AudioStreamPlayer2D audio, float deviation) diff --git a/Extensions/Node.cs b/Extensions/Node.cs index ee52e80..cf7191c 100644 --- a/Extensions/Node.cs +++ b/Extensions/Node.cs @@ -8,7 +8,8 @@ public static class NodeExtensions /// Iterates through each ancestor until it finds an ancestor of type /// T /// - public static T GetAncestor(this Node node) where T : Node + [System.Obsolete] + public static T GetAncestorDeprecated(this Node node) where T : Node { Node parent; diff --git a/Extensions/Node2DExtensions.cs b/Extensions/Node2DExtensions.cs index 694fb45..ab70549 100644 --- a/Extensions/Node2DExtensions.cs +++ b/Extensions/Node2DExtensions.cs @@ -1,4 +1,5 @@ using Godot; +using GodotUtilities; namespace SupaLidlGame.Extensions; @@ -9,4 +10,32 @@ public static class Node2DExtensions //var spaceState = node.GetWorld2d().DirectSpaceState; //var result = spaceState.IntersectRay(); } + + public static Node CloneOnWorld(this Node2D node) + { + return CloneOnWorld(node); + } + + public static T CloneOnWorld(this Node2D node) where T : Node2D + { + var world = node.GetAncestor(); + if (world is null) + { + throw new System.NullReferenceException("World does not exist"); + } + + //var parent = new Node2D(); + //world.AddChild(parent); + //parent.GlobalPosition = node.GlobalPosition; + var clone = node.Duplicate() as T; + world.AddChild(clone); + clone.GlobalPosition = node.GlobalPosition; + return clone; + } + + public static Node AtPosition(this Node2D node, Vector2 position) + { + node.GlobalPosition = position; + return node; + } } diff --git a/Extensions/Particles2D.cs b/Extensions/Particles2D.cs new file mode 100644 index 0000000..fb76d57 --- /dev/null +++ b/Extensions/Particles2D.cs @@ -0,0 +1,14 @@ +using Godot; + +namespace SupaLidlGame.Extensions; + +public static class Particles2D +{ + public static void EmitOneShot(this GpuParticles2D particles) + { + particles.GetTree().CreateTimer(particles.Lifetime).Timeout += () => + { + particles.QueueFree(); + }; + } +} diff --git a/Items/Weapons/Railgun.cs b/Items/Weapons/Railgun.cs index 4ebed2a..d6f93d0 100644 --- a/Items/Weapons/Railgun.cs +++ b/Items/Weapons/Railgun.cs @@ -1,5 +1,5 @@ using Godot; -using SupaLidlGame.Extensions; +using GodotUtilities; namespace SupaLidlGame.Items.Weapons; diff --git a/Items/Weapons/Sword.cs b/Items/Weapons/Sword.cs index 826116a..12a719d 100644 --- a/Items/Weapons/Sword.cs +++ b/Items/Weapons/Sword.cs @@ -1,4 +1,5 @@ using Godot; +using GodotUtilities; using SupaLidlGame.BoundingBoxes; using SupaLidlGame.Characters; using SupaLidlGame.Extensions; @@ -197,7 +198,7 @@ public partial class Sword : Weapon, IParryable IsParried = true; AnimationPlayer.SpeedScale = 0.25f; Character.Stun(1.5f); - GetNode("ParrySound").OnWorld().Play(); + GetNode("ParrySound").OnWorld().PlayOneShot(); } public override void _on_hitbox_hit(BoundingBox box) diff --git a/Items/Weapons/Sword.tscn b/Items/Weapons/Sword.tscn index b200c38..69f13b2 100644 --- a/Items/Weapons/Sword.tscn +++ b/Items/Weapons/Sword.tscn @@ -340,13 +340,13 @@ Hitbox = NodePath("Hitbox") AnimationPlayer = NodePath("AnimationPlayer") AnimationTree = NodePath("AnimationTree") AttackTime = 0.2 -AttackAnimationDuration = 1.0 +AttackAnimationDuration = 0.75 ParryParticles = NodePath("Anchor/Node2D/Sprite2D/ParryParticles") NPCAnticipateTime = 0.3 StateMachine = NodePath("State") Anchor = NodePath("Anchor") Damage = 20.0 -UseTime = 0.8 +UseTime = 0.55 Knockback = 64.0 ShouldHideIdle = true diff --git a/Scenes/Level.tscn b/Scenes/Level.tscn index efb08ee..910e672 100644 --- a/Scenes/Level.tscn +++ b/Scenes/Level.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=3 format=3 uid="uid://1pb3mpmrl7lc"] [ext_resource type="Script" path="res://Utils/World.cs" id="1_1k6ew"] -[ext_resource type="PackedScene" uid="uid://bxtpv6jqodj4v" path="res://Scenes/Maps/Hills.tscn" id="2_juio7"] +[ext_resource type="PackedScene" uid="uid://b2x17su05ou5w" path="res://Scenes/Maps/Arena.tscn" id="2_avsrq"] [node name="World" type="Node2D"] script = ExtResource("1_1k6ew") -StartingArea = ExtResource("2_juio7") +StartingArea = ExtResource("2_avsrq") diff --git a/Scenes/Map.cs b/Scenes/Map.cs index a51bcdb..3432ec2 100644 --- a/Scenes/Map.cs +++ b/Scenes/Map.cs @@ -1,5 +1,4 @@ using Godot; -using System; namespace SupaLidlGame.Scenes; @@ -30,7 +29,7 @@ public partial class Map : TileMap } set { - _active = Visible = value; + _active = Visible = value; SetProcess(value); } } @@ -44,4 +43,16 @@ public partial class Map : TileMap { base._Process(delta); } + + public Node SpawnEntity(PackedScene scene) + { + var instance = scene.Instantiate(); + Entities.AddChild(instance); + return instance; + } + + public T SpawnEntity(PackedScene scene) where T : Node + { + return SpawnEntity(scene) as T; + } } diff --git a/Scenes/Maps/Arena.tscn b/Scenes/Maps/Arena.tscn new file mode 100644 index 0000000..c5db8f1 --- /dev/null +++ b/Scenes/Maps/Arena.tscn @@ -0,0 +1,273 @@ +[gd_scene load_steps=13 format=3 uid="uid://b2x17su05ou5w"] + +[ext_resource type="PackedScene" uid="uid://clwv2owvk6abe" path="res://Scenes/BaseMap.tscn" id="1_ifiic"] +[ext_resource type="Texture2D" uid="uid://b0yiy7w8nxmas" path="res://Assets/Sprites/arena-tileset.png" id="2_wnjm0"] +[ext_resource type="Texture2D" uid="uid://5k0o7d7j65a4" path="res://Assets/Sprites/arena-tileset-normal.png" id="3_iitgk"] +[ext_resource type="PackedScene" uid="uid://dsr5kkbthpwpl" path="res://Characters/Doc.tscn" id="4_c0csw"] +[ext_resource type="Shader" path="res://Shaders/Flash.gdshader" id="5_aevwf"] + +[sub_resource type="OccluderPolygon2D" id="OccluderPolygon2D_8jil2"] +polygon = PackedVector2Array(-8, -4, -6, -5, -6, -18, 6, -18, 6, -5, 8, -4, 8, 4, 4, 8, -4, 8, -8, 3.5) + +[sub_resource type="CanvasTexture" id="CanvasTexture_dnsyd"] +diffuse_texture = ExtResource("2_wnjm0") +normal_texture = ExtResource("3_iitgk") + +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_fcd6d"] +texture = SubResource("CanvasTexture_dnsyd") +0:0/0 = 0 +0:0/0/physics_layer_0/linear_velocity = Vector2(0, 0) +0:0/0/physics_layer_0/angular_velocity = 0.0 +1:0/0 = 0 +1:0/0/physics_layer_0/linear_velocity = Vector2(0, 0) +1:0/0/physics_layer_0/angular_velocity = 0.0 +2:0/0 = 0 +2:0/0/physics_layer_0/linear_velocity = Vector2(0, 0) +2:0/0/physics_layer_0/angular_velocity = 0.0 +3:0/0 = 0 +3:0/0/physics_layer_0/linear_velocity = Vector2(0, 0) +3:0/0/physics_layer_0/angular_velocity = 0.0 +4:0/0 = 0 +4:0/0/physics_layer_0/linear_velocity = Vector2(0, 0) +4:0/0/physics_layer_0/angular_velocity = 0.0 +4:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +5:0/0 = 0 +5:0/0/physics_layer_0/linear_velocity = Vector2(0, 0) +5:0/0/physics_layer_0/angular_velocity = 0.0 +5:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +6:0/0 = 0 +6:0/0/physics_layer_0/linear_velocity = Vector2(0, 0) +6:0/0/physics_layer_0/angular_velocity = 0.0 +7:0/size_in_atlas = Vector2i(1, 2) +7:0/0 = 0 +7:0/0/texture_origin = Vector2i(0, 8) +7:0/0/occlusion_layer_0/polygon = SubResource("OccluderPolygon2D_8jil2") +7:0/0/physics_layer_0/linear_velocity = Vector2(0, 0) +7:0/0/physics_layer_0/angular_velocity = 0.0 +7:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -4, 8, -4, 8, 3.5, 4.5, 8, -4, 8, -8, 4) +0:1/0 = 0 +0:1/0/physics_layer_0/linear_velocity = Vector2(0, 0) +0:1/0/physics_layer_0/angular_velocity = 0.0 +1:1/0 = 0 +1:1/0/physics_layer_0/linear_velocity = Vector2(0, 0) +1:1/0/physics_layer_0/angular_velocity = 0.0 +2:1/0 = 0 +2:1/0/physics_layer_0/linear_velocity = Vector2(0, 0) +2:1/0/physics_layer_0/angular_velocity = 0.0 +2:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +3:1/0 = 0 +3:1/0/physics_layer_0/linear_velocity = Vector2(0, 0) +3:1/0/physics_layer_0/angular_velocity = 0.0 +3:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +4:1/0 = 0 +4:1/0/physics_layer_0/linear_velocity = Vector2(0, 0) +4:1/0/physics_layer_0/angular_velocity = 0.0 +4:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +5:1/0 = 0 +5:1/0/physics_layer_0/linear_velocity = Vector2(0, 0) +5:1/0/physics_layer_0/angular_velocity = 0.0 +5:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +6:1/0 = 0 +6:1/0/physics_layer_0/linear_velocity = Vector2(0, 0) +6:1/0/physics_layer_0/angular_velocity = 0.0 +6:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +0:2/0 = 0 +0:2/0/physics_layer_0/linear_velocity = Vector2(0, 0) +0:2/0/physics_layer_0/angular_velocity = 0.0 +0:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +1:2/0 = 0 +1:2/0/physics_layer_0/linear_velocity = Vector2(0, 0) +1:2/0/physics_layer_0/angular_velocity = 0.0 +1:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +2:2/0 = 0 +2:2/0/physics_layer_0/linear_velocity = Vector2(0, 0) +2:2/0/physics_layer_0/angular_velocity = 0.0 +3:2/0 = 0 +3:2/0/physics_layer_0/linear_velocity = Vector2(0, 0) +3:2/0/physics_layer_0/angular_velocity = 0.0 +3:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +4:2/0 = 0 +4:2/0/physics_layer_0/linear_velocity = Vector2(0, 0) +4:2/0/physics_layer_0/angular_velocity = 0.0 +5:2/0 = 0 +5:2/0/physics_layer_0/linear_velocity = Vector2(0, 0) +5:2/0/physics_layer_0/angular_velocity = 0.0 +6:2/0 = 0 +6:2/0/physics_layer_0/linear_velocity = Vector2(0, 0) +6:2/0/physics_layer_0/angular_velocity = 0.0 +7:2/0 = 0 +7:2/0/physics_layer_0/linear_velocity = Vector2(0, 0) +7:2/0/physics_layer_0/angular_velocity = 0.0 +0:3/0 = 0 +0:3/0/physics_layer_0/linear_velocity = Vector2(0, 0) +0:3/0/physics_layer_0/angular_velocity = 0.0 +0:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +1:3/0 = 0 +1:3/0/physics_layer_0/linear_velocity = Vector2(0, 0) +1:3/0/physics_layer_0/angular_velocity = 0.0 +1:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +2:3/0 = 0 +2:3/0/physics_layer_0/linear_velocity = Vector2(0, 0) +2:3/0/physics_layer_0/angular_velocity = 0.0 +2:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +3:3/0 = 0 +3:3/0/physics_layer_0/linear_velocity = Vector2(0, 0) +3:3/0/physics_layer_0/angular_velocity = 0.0 +3:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +4:3/0 = 0 +4:3/0/physics_layer_0/linear_velocity = Vector2(0, 0) +4:3/0/physics_layer_0/angular_velocity = 0.0 +5:3/0 = 0 +5:3/0/physics_layer_0/linear_velocity = Vector2(0, 0) +5:3/0/physics_layer_0/angular_velocity = 0.0 +6:3/0 = 0 +6:3/0/physics_layer_0/linear_velocity = Vector2(0, 0) +6:3/0/physics_layer_0/angular_velocity = 0.0 +7:3/0 = 0 +7:3/0/physics_layer_0/linear_velocity = Vector2(0, 0) +7:3/0/physics_layer_0/angular_velocity = 0.0 + +[sub_resource type="OccluderPolygon2D" id="OccluderPolygon2D_kbvre"] +polygon = PackedVector2Array(-4, 8, -8, 4, -8, -4, -6, -4, -6, -20, 6, -20, 6, -4, 8, -4, 8, 4, 4, 8) + +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_5yxvt"] +texture = ExtResource("2_wnjm0") +0:0/0 = 0 +0:0/0/physics_layer_0/linear_velocity = Vector2(0, 0) +0:0/0/physics_layer_0/angular_velocity = 0.0 +1:0/0 = 0 +1:0/0/physics_layer_0/linear_velocity = Vector2(0, 0) +1:0/0/physics_layer_0/angular_velocity = 0.0 +2:0/0 = 0 +2:0/0/physics_layer_0/linear_velocity = Vector2(0, 0) +2:0/0/physics_layer_0/angular_velocity = 0.0 +3:0/0 = 0 +3:0/0/physics_layer_0/linear_velocity = Vector2(0, 0) +3:0/0/physics_layer_0/angular_velocity = 0.0 +4:0/0 = 0 +4:0/0/physics_layer_0/linear_velocity = Vector2(0, 0) +4:0/0/physics_layer_0/angular_velocity = 0.0 +4:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +5:0/0 = 0 +5:0/0/physics_layer_0/linear_velocity = Vector2(0, 0) +5:0/0/physics_layer_0/angular_velocity = 0.0 +5:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +6:0/0 = 0 +6:0/0/physics_layer_0/linear_velocity = Vector2(0, 0) +6:0/0/physics_layer_0/angular_velocity = 0.0 +0:1/0 = 0 +0:1/0/physics_layer_0/linear_velocity = Vector2(0, 0) +0:1/0/physics_layer_0/angular_velocity = 0.0 +1:1/0 = 0 +1:1/0/physics_layer_0/linear_velocity = Vector2(0, 0) +1:1/0/physics_layer_0/angular_velocity = 0.0 +2:1/0 = 0 +2:1/0/physics_layer_0/linear_velocity = Vector2(0, 0) +2:1/0/physics_layer_0/angular_velocity = 0.0 +2:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +3:1/0 = 0 +3:1/0/physics_layer_0/linear_velocity = Vector2(0, 0) +3:1/0/physics_layer_0/angular_velocity = 0.0 +3:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +4:1/0 = 0 +4:1/0/physics_layer_0/linear_velocity = Vector2(0, 0) +4:1/0/physics_layer_0/angular_velocity = 0.0 +4:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +5:1/0 = 0 +5:1/0/physics_layer_0/linear_velocity = Vector2(0, 0) +5:1/0/physics_layer_0/angular_velocity = 0.0 +5:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +6:1/0 = 0 +6:1/0/physics_layer_0/linear_velocity = Vector2(0, 0) +6:1/0/physics_layer_0/angular_velocity = 0.0 +6:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +0:2/0 = 0 +0:2/0/physics_layer_0/linear_velocity = Vector2(0, 0) +0:2/0/physics_layer_0/angular_velocity = 0.0 +0:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +1:2/0 = 0 +1:2/0/physics_layer_0/linear_velocity = Vector2(0, 0) +1:2/0/physics_layer_0/angular_velocity = 0.0 +1:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +2:2/0 = 0 +2:2/0/physics_layer_0/linear_velocity = Vector2(0, 0) +2:2/0/physics_layer_0/angular_velocity = 0.0 +3:2/0 = 0 +3:2/0/physics_layer_0/linear_velocity = Vector2(0, 0) +3:2/0/physics_layer_0/angular_velocity = 0.0 +3:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 0, -8, 0) +4:2/0 = 0 +4:2/0/physics_layer_0/linear_velocity = Vector2(0, 0) +4:2/0/physics_layer_0/angular_velocity = 0.0 +5:2/0 = 0 +5:2/0/physics_layer_0/linear_velocity = Vector2(0, 0) +5:2/0/physics_layer_0/angular_velocity = 0.0 +6:2/0 = 0 +6:2/0/physics_layer_0/linear_velocity = Vector2(0, 0) +6:2/0/physics_layer_0/angular_velocity = 0.0 +7:2/0 = 0 +7:2/0/physics_layer_0/linear_velocity = Vector2(0, 0) +7:2/0/physics_layer_0/angular_velocity = 0.0 +0:3/0 = 0 +0:3/0/physics_layer_0/linear_velocity = Vector2(0, 0) +0:3/0/physics_layer_0/angular_velocity = 0.0 +0:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +1:3/0 = 0 +1:3/0/physics_layer_0/linear_velocity = Vector2(0, 0) +1:3/0/physics_layer_0/angular_velocity = 0.0 +1:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) +2:3/0 = 0 +2:3/0/physics_layer_0/linear_velocity = Vector2(0, 0) +2:3/0/physics_layer_0/angular_velocity = 0.0 +2:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 0, -8, 0, 8, -8, 8) +3:3/0 = 0 +3:3/0/physics_layer_0/linear_velocity = Vector2(0, 0) +3:3/0/physics_layer_0/angular_velocity = 0.0 +3:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(0, -8, 8, -8, 8, 8, 0, 8) +4:3/0 = 0 +4:3/0/physics_layer_0/linear_velocity = Vector2(0, 0) +4:3/0/physics_layer_0/angular_velocity = 0.0 +4:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(0, -8, 8, -8, 8, 0, 0, 0) +5:3/0 = 0 +5:3/0/physics_layer_0/linear_velocity = Vector2(0, 0) +5:3/0/physics_layer_0/angular_velocity = 0.0 +5:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 0, -8, 0, 0, -8, 0) +6:3/0 = 0 +6:3/0/physics_layer_0/linear_velocity = Vector2(0, 0) +6:3/0/physics_layer_0/angular_velocity = 0.0 +7:3/0 = 0 +7:3/0/physics_layer_0/linear_velocity = Vector2(0, 0) +7:3/0/physics_layer_0/angular_velocity = 0.0 +7:0/size_in_atlas = Vector2i(1, 2) +7:0/0 = 0 +7:0/0/texture_origin = Vector2i(0, 8) +7:0/0/occlusion_layer_0/polygon = SubResource("OccluderPolygon2D_kbvre") +7:0/0/physics_layer_0/linear_velocity = Vector2(0, 0) +7:0/0/physics_layer_0/angular_velocity = 0.0 +7:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8) + +[sub_resource type="TileSet" id="TileSet_k1u48"] +occlusion_layer_0/light_mask = 1 +physics_layer_0/collision_layer = 1 +sources/2 = SubResource("TileSetAtlasSource_5yxvt") +sources/0 = SubResource("TileSetAtlasSource_fcd6d") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_4g4ap"] +resource_local_to_scene = true +shader = ExtResource("5_aevwf") +shader_parameter/color = Quaternion(1, 1, 1, 1) +shader_parameter/intensity = 0.0 + +[node name="TileMap" instance=ExtResource("1_ifiic")] +tile_set = SubResource("TileSet_k1u48") +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_3/tile_data = PackedInt32Array(-196612, 65536, 1, -131076, 65536, 1, -65540, 196608, 0, -4, 131072, 0, -196611, 65536, 1, -131075, 65536, 0, -65539, 131072, 0, -3, 196608, 0, -196610, 65536, 0, -131074, 65536, 1, -65538, 0, 0, -2, 65536, 0, -196609, 65536, 1, -131073, 65536, 1, -65537, 65536, 0, -1, 65536, 1, -458760, 0, 0, -393224, 196608, 0, -327688, 196608, 0, -262152, 0, 0, -196616, 65536, 0, -131080, 131072, 0, -65544, 196608, 0, -8, 131072, 0, 65528, 131072, 0, 131064, 196608, 0, 196600, 131072, 0, 262136, 65536, 0, 327672, 65536, 0, 393208, 65536, 0, 458744, 0, 0, 524280, 65536, 0, -458759, 0, 1, -393223, 131072, 0, -327687, 131072, 0, -262151, 65536, 0, -196615, 65536, 1, -131079, 131072, 0, -65543, 131072, 0, -7, 196608, 0, 65529, 196608, 0, 131065, 196608, 0, 196601, 131072, 0, 262137, 65536, 1, 327673, 0, 0, 393209, 65536, 1, 458745, 65536, 0, 524281, 65536, 1, -458758, 0, 0, -393222, 65536, 0, -327686, 0, 0, -262150, 65536, 0, -196614, 0, 0, -131078, 0, 1, -65542, 196608, 0, -6, 196608, 0, 65530, 65536, 1, 131066, 65536, 1, 196602, 65536, 1, 262138, 0, 0, 327674, 65536, 1, 393210, 65536, 0, 458746, 131072, 0, 524282, 131072, 0, -458757, 65536, 0, -393221, 65536, 1, -327685, 65536, 0, -262149, 65536, 0, -196613, 0, 1, -131077, 0, 1, -65541, 131072, 0, -5, 131072, 0, 65531, 65536, 0, 131067, 0, 1, 196603, 0, 0, 262139, 0, 1, 327675, 0, 0, 393211, 65536, 0, 458747, 131072, 0, 524283, 196608, 0, -458756, 0, 0, -393220, 0, 1, -327684, 0, 0, -262148, 0, 0, 65532, 65536, 0, 131068, 65536, 0, 196604, 65536, 1, 262140, 0, 1, 327676, 131072, 0, 393212, 196608, 0, 458748, 196608, 0, 524284, 196608, 0, -458755, 0, 1, -393219, 0, 1, -327683, 0, 1, -262147, 0, 0, 65533, 65536, 0, 131069, 65536, 1, 196605, 65536, 1, 262141, 0, 1, 327677, 196608, 0, 393213, 131072, 0, 458749, 196608, 0, 524285, 131072, 0, -458754, 65536, 1, -393218, 65536, 1, -327682, 131072, 0, -262146, 196608, 0, 65534, 0, 1, 131070, 65536, 0, 196606, 196608, 0, 262142, 131072, 0, 327678, 196608, 0, 393214, 131072, 0, 458750, 65536, 0, 524286, 0, 0, -458753, 0, 1, -393217, 0, 1, -327681, 196608, 0, -262145, 131072, 0, 65535, 0, 1, 131071, 65536, 1, 196607, 131072, 0, 262143, 196608, 0, 327679, 131072, 0, 393215, 131072, 0, 458751, 65536, 1, 524287, 0, 0, -524288, 65536, 1, -458752, 65536, 1, -393216, 196608, 0, -327680, 196608, 0, -262144, 65536, 0, -196608, 0, 1, -131072, 65536, 0, -65536, 65536, 0, 0, 65536, 0, 65536, 65536, 1, 131072, 65536, 0, 196608, 65536, 1, 262144, 65536, 0, 327680, 0, 1, 393216, 0, 0, 458752, 0, 1, -524287, 65536, 1, -458751, 0, 0, -393215, 196608, 0, -327679, 196608, 0, -262143, 0, 0, -196607, 65536, 1, -131071, 0, 1, -65535, 65536, 1, 1, 0, 0, 65537, 65536, 1, 131073, 65536, 0, 196609, 65536, 0, 262145, 65536, 1, 327681, 65536, 1, 393217, 0, 1, 458753, 65536, 1, -524286, 65536, 0, -458750, 65536, 0, -393214, 131072, 0, -327678, 196608, 0, -262142, 0, 0, -196606, 65536, 0, -131070, 196608, 0, -65534, 131072, 0, 2, 131072, 0, 65538, 196608, 0, 131074, 65536, 0, 196610, 0, 0, 262146, 0, 1, 327682, 65536, 0, 393218, 131072, 0, 458754, 131072, 0, -524285, 65536, 0, -458749, 65536, 0, -393213, 131072, 0, -327677, 196608, 0, -262141, 0, 0, -196605, 65536, 0, -131069, 131072, 0, -65533, 131072, 0, 3, 196608, 0, 65539, 196608, 0, 131075, 0, 0, 196611, 0, 1, 262147, 65536, 1, 327683, 65536, 1, 393219, 196608, 0, 458755, 196608, 0, -524284, 0, 1, -458748, 65536, 0, -393212, 65536, 0, -327676, 0, 0, -262140, 65536, 1, -196604, 0, 1, -131068, 0, 1, -65532, 0, 1, 4, 0, 0, 65540, 65536, 1, 131076, 0, 0, 196612, 65536, 0, 262148, 131072, 0, 327684, 196608, 0, 393220, 196608, 0, 458756, 196608, 0, -524283, 65536, 1, -458747, 65536, 0, -393211, 65536, 1, -327675, 0, 0, -262139, 0, 1, -196603, 0, 1, -131067, 0, 1, -65531, 65536, 1, 5, 65536, 0, 65541, 65536, 0, 131077, 65536, 0, 196613, 0, 0, 262149, 196608, 0, 327685, 196608, 0, 393221, 131072, 0, 458757, 131072, 0, -524282, 0, 1, -458746, 0, 1, -393210, 0, 0, -327674, 65536, 0, -262138, 0, 0, -196602, 0, 1, -131066, 131072, 0, -65530, 196608, 0, 6, 65536, 0, 65542, 65536, 0, 131078, 0, 0, 196614, 0, 1, 262150, 65536, 0, 327686, 65536, 1, 393222, 0, 1, 458758, 0, 1, -524281, 65536, 0, -458745, 65536, 0, -393209, 196608, 0, -327673, 196608, 0, -262137, 196608, 0, -196601, 131072, 0, -131065, 196608, 0, -65529, 131072, 0, 7, 0, 1, 65543, 65536, 1, 131079, 0, 1, 196615, 0, 0, 262151, 0, 0, 327687, 0, 1, 393223, 65536, 0, 458759, 0, 1) +layer_4/tile_data = PackedInt32Array(-524296, 327680, 0, -589818, 262144, 0, -589817, 262144, 1, -589819, 327680, 0, -589820, 196608, 1, -589821, 327680, 1, -589822, 131072, 1, -589823, 262144, 1, -589824, 327680, 0, -524289, 131072, 1, -524290, 327680, 0, -524291, 327680, 1, -524292, 327680, 1, -524293, 327680, 0, -524294, 131072, 1, -524295, 262144, 1, -589832, 131072, 2, -589831, 131072, 2, -589830, 131072, 2, -589829, 131072, 2, -589828, 131072, 2, -589827, 131072, 2, -589826, 131072, 2, -589825, 131072, 2, -655360, 131072, 2, -655359, 131072, 2, -655358, 131072, 2, -655357, 131072, 2, -655356, 131072, 2, -655355, 131072, 2, -655354, 131072, 2, -655353, 131072, 2, -655352, 327680, 2, -589833, 262144, 2, -524297, 196608, 3, -458761, 196608, 3, -393225, 196608, 3, -327689, 196608, 3, -262153, 196608, 3, -196617, 196608, 3, -131081, 196608, 3, -65545, 196608, 3, -9, 196608, 3, 65527, 196608, 3, 131063, 196608, 3, 196599, 196608, 3, 262135, 196608, 3, 327671, 196608, 3, 393207, 196608, 3, 458743, 196608, 3, 524279, 196608, 3, 262152, 131072, 3, 327688, 131072, 3, 393224, 131072, 3, 458760, 131072, 3, 196616, 131072, 3, 131080, 131072, 3, 65544, 131072, 3, 8, 131072, 3, -65528, 131072, 3, -131064, 131072, 3, -196600, 131072, 3, -262136, 131072, 3, -589816, 131072, 3, -524280, 131072, 3, -458744, 131072, 3, -393208, 131072, 3, -327672, 131072, 3, 589816, 196608, 2, 589817, 196608, 2, 589818, 196608, 2, 589819, 196608, 2, 589820, 196608, 2, 589821, 196608, 2, 589822, 196608, 2, 589823, 196608, 2, 524288, 196608, 2, 524289, 196608, 2, 524290, 196608, 2, 524291, 196608, 2, 524292, 196608, 2, 524293, 196608, 2, 524294, 196608, 2, 524295, 196608, 2, 524296, 327680, 3, 589815, 262144, 3) + +[node name="CanvasModulate" parent="." index="0"] +color = Color(0.753984, 0.753984, 0.753984, 1) + +[node name="Doc" parent="Entities" index="0" instance=ExtResource("4_c0csw")] +material = SubResource("ShaderMaterial_4g4ap") +PreferredWeightDistance = 256.0 +MaxWeightDistance = 32.0 diff --git a/Scenes/Maps/Hills.tscn b/Scenes/Maps/Hills.tscn index f1a84a6..896b900 100644 --- a/Scenes/Maps/Hills.tscn +++ b/Scenes/Maps/Hills.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=14 format=3 uid="uid://bxtpv6jqodj4v"] +[gd_scene load_steps=18 format=3 uid="uid://bxtpv6jqodj4v"] [ext_resource type="PackedScene" uid="uid://clwv2owvk6abe" path="res://Scenes/BaseMap.tscn" id="1_vly6f"] [ext_resource type="Texture2D" uid="uid://dl2h266oa2x31" path="res://Assets/Sprites/night-grass.png" id="2_ote21"] [ext_resource type="PackedScene" uid="uid://bf55wbq7m1gpp" path="res://Characters/ExampleEnemy.tscn" id="3_hwof6"] [ext_resource type="Shader" path="res://Shaders/Flash.gdshader" id="4_mwgaq"] [ext_resource type="PackedScene" uid="uid://5nvn1tw56m8e" path="res://Utils/Spawner.tscn" id="4_pi4df"] +[ext_resource type="PackedScene" uid="uid://dhl071rj5wyvx" path="res://Entities/Campfire.tscn" id="6_r6kxn"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_dvbe3"] texture = ExtResource("2_ote21") @@ -211,31 +212,31 @@ physics_layer_0/collision_mask = 16 physics_layer_1/collision_layer = 1 sources/0 = SubResource("TileSetAtlasSource_dvbe3") -[sub_resource type="ShaderMaterial" id="ShaderMaterial_kq7i3"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_5ho8d"] resource_local_to_scene = true shader = ExtResource("4_mwgaq") shader_parameter/color = Quaternion(1, 1, 1, 1) shader_parameter/intensity = 0.0 -[sub_resource type="ShaderMaterial" id="ShaderMaterial_ck37u"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_tic7i"] resource_local_to_scene = true shader = ExtResource("4_mwgaq") shader_parameter/color = Quaternion(1, 1, 1, 1) shader_parameter/intensity = 0.0 -[sub_resource type="ShaderMaterial" id="ShaderMaterial_3i2mi"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_oh7dr"] resource_local_to_scene = true shader = ExtResource("4_mwgaq") shader_parameter/color = Quaternion(1, 1, 1, 1) shader_parameter/intensity = 0.0 -[sub_resource type="ShaderMaterial" id="ShaderMaterial_trolh"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_x6kxt"] resource_local_to_scene = true shader = ExtResource("4_mwgaq") shader_parameter/color = Quaternion(1, 1, 1, 1) shader_parameter/intensity = 0.0 -[sub_resource type="ShaderMaterial" id="ShaderMaterial_vuv4g"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_uuq2q"] resource_local_to_scene = true shader = ExtResource("4_mwgaq") shader_parameter/color = Quaternion(1, 1, 1, 1) @@ -244,6 +245,22 @@ shader_parameter/intensity = 0.0 [sub_resource type="RectangleShape2D" id="RectangleShape2D_oods2"] size = Vector2(128, 64) +[sub_resource type="Gradient" id="Gradient_rg6hp"] +colors = PackedColorArray(0.941579, 6.06447e-06, 0.603405, 1, 1, 1, 1, 1) + +[sub_resource type="GradientTexture1D" id="GradientTexture1D_pdu88"] +gradient = SubResource("Gradient_rg6hp") + +[sub_resource type="Environment" id="Environment_c0b2h"] +background_mode = 3 +glow_enabled = true +glow_intensity = 1.2 +glow_strength = 0.8 +glow_bloom = 0.1 +glow_blend_mode = 0 +adjustment_enabled = true +adjustment_color_correction = SubResource("GradientTexture1D_pdu88") + [node name="TileMap" instance=ExtResource("1_vly6f")] tile_set = SubResource("TileSet_7f7fo") layer_3/tile_data = PackedInt32Array(786426, 262144, 1, 851962, 262144, 1, 917498, 262144, 1, 983034, 262144, 1, 786427, 262144, 1, 851963, 262144, 1, 917499, 262144, 1, 983035, 262144, 1, 786428, 262144, 1, 851964, 262144, 1, 917500, 262144, 1, 983036, 262144, 1, 786429, 262144, 1, 851965, 262144, 1, 917501, 262144, 1, 983037, 262144, 1, 786430, 262144, 1, 851966, 262144, 1, 917502, 262144, 1, 983038, 262144, 1, 786431, 262144, 1, 851967, 262144, 1, 917503, 262144, 1, 983039, 262144, 1, 720896, 262144, 1, 786432, 262144, 1, 851968, 262144, 1, 917504, 262144, 1, 1048573, 262144, 1, 1048574, 262144, 1, 1048575, 262144, 1, 983040, 262144, 1, 1048576, 262144, 1, 1114112, 262144, 1, 1179647, 262144, 1, 1179646, 262144, 1, 1179645, 262144, 1, 1114109, 262144, 1, 1114110, 262144, 1, 1114111, 262144, 1, 1245183, 262144, 1, 1310719, 262144, 1, 1376255, 262144, 1, 1310720, 131072, 3, 1376256, 262144, 1, 1441791, 262144, 1, 1245184, 131072, 3, 1179648, 131072, 3, 1179649, 131072, 3, 1179650, 131072, 3, 1179651, 131072, 3, 1114115, 262144, 1, 1114114, 262144, 1, 1114113, 262144, 1, 1114116, 262144, 1, 1114117, 262144, 1, 1114118, 262144, 1, 1114119, 262144, 1, 1114120, 262144, 1, 1114121, 262144, 1, 1114122, 262144, 1, 1114123, 262144, 1, 1179659, 262144, 1, 1245195, 262144, 1, 1310731, 262144, 1, 1376266, 262144, 1, 1376265, 262144, 1, 1376264, 262144, 1, 1376263, 262144, 1, 1376262, 262144, 1, 1376261, 262144, 1, 1376260, 262144, 1, 1376259, 131072, 3, 1376258, 131072, 3, 1376257, 262144, 1, 1310721, 131072, 3, 1245185, 131072, 4, 1245186, 131072, 4, 1310722, 131072, 3, 1245187, 131072, 3, 1179652, 262144, 1, 1179653, 262144, 1, 1179654, 262144, 1, 1179655, 262144, 1, 1179656, 262144, 1, 1179657, 262144, 1, 1179658, 262144, 1, 1376267, 262144, 1, 1310728, 262144, 1, 1310727, 262144, 1, 1310726, 262144, 1, 1310725, 131072, 3, 1310724, 131072, 3, 1310723, 131072, 3, 1245188, 131072, 3, 1245189, 131072, 3, 1245190, 262144, 1, 1245191, 262144, 1, 1245192, 262144, 1, 1245193, 262144, 1, 1245194, 262144, 1, 1310730, 262144, 1, 1310729, 262144, 1, 524285, 262144, 1, 589821, 262144, 1, 655357, 262144, 1, 720893, 262144, 1, 720894, 262144, 1, 655358, 131072, 3, 589822, 262144, 1, 524286, 262144, 1, 524287, 262144, 1, 458752, 262144, 1, 458753, 262144, 1, 458754, 262144, 1, 458755, 262144, 1, 458756, 262144, 1, 458757, 262144, 1, 458758, 262144, 1, 458759, 262144, 1, 458760, 262144, 1, 458764, 262144, 1, 524300, 262144, 1, 589836, 262144, 1, 655372, 262144, 1, 720908, 262144, 1, 786444, 131072, 3, 851980, 131072, 4, 851981, 131072, 4, 851982, 262144, 1, 786446, 262144, 1, 720910, 262144, 1, 720909, 262144, 1, 786445, 262144, 1, 851979, 131072, 4, 851978, 262144, 1, 851977, 262144, 1, 851976, 262144, 1, 851975, 262144, 1, 786439, 262144, 1, 786440, 262144, 1, 786441, 262144, 1, 786442, 131072, 3, 786443, 131072, 3, 720907, 262144, 1, 655371, 262144, 1, 589834, 131072, 3, 524298, 262144, 1, 524297, 131072, 3, 524294, 262144, 1, 524293, 262144, 1, 524292, 262144, 1, 524291, 262144, 1, 524290, 262144, 1, 524289, 131072, 3, 524288, 131072, 3, 589824, 131072, 3, 655359, 131072, 4, 720895, 131072, 3, 589823, 131072, 3, 655360, 131072, 3, 655361, 131072, 3, 655362, 131072, 3, 655363, 262144, 1, 655364, 262144, 1, 655366, 262144, 1, 655367, 131072, 3, 655368, 131072, 3, 655369, 131072, 3, 655370, 131072, 3, 720906, 262144, 1, 720905, 262144, 1, 720904, 262144, 1, 720903, 262144, 1, 720902, 262144, 1, 720901, 262144, 1, 720900, 262144, 1, 589828, 262144, 1, 589827, 262144, 1, 589826, 262144, 1, 589825, 131072, 3, 589829, 262144, 1, 589832, 131072, 4, 589833, 131072, 4, 589835, 131072, 3, 524299, 262144, 1, 393220, 262144, 1, 393221, 262144, 1, 393222, 262144, 1, 393223, 262144, 1, 393224, 262144, 1, 393225, 262144, 1, 393226, 262144, 1, 393227, 262144, 1, 393229, 262144, 1, 393230, 262144, 1, 327694, 262144, 1, 327692, 262144, 1, 327691, 262144, 1, 262155, 262144, 1, 262156, 262144, 1, 196621, 131072, 4, 196622, 262144, 1, 262157, 262144, 1, -131063, 262144, 1, -65527, 262144, 1, -65526, 262144, 1, 9, 262144, 1, -131062, 262144, 1, -131061, 262144, 1, -65525, 262144, 1, 10, 262144, 1, 11, 131072, 3, 65547, 262144, 1, 131083, 262144, 1, 196619, 262144, 1, 196620, 262144, 1, 131084, 131072, 3, 131085, 131072, 4, 65549, 131072, 4, 13, 131072, 3, 12, 131072, 3, -65524, 131072, 3, -131060, 262144, 1, -131059, 262144, 1, -131058, 262144, 1, -65522, 262144, 1, 14, 262144, 1, 65550, 262144, 1, 131086, 262144, 1, -65523, 262144, 1, 65548, 131072, 3, 8, 262144, 1, 7, 262144, 1, 6, 262144, 1, 5, 262144, 1, 4, 262144, 1, 3, 131072, 3, 2, 131072, 3, 1, 131072, 3, 0, 131072, 3, 65535, 262144, 1, 65534, 262144, 1, 65533, 262144, 1, -3, 262144, 1, -2, 262144, 1, -1, 262144, 1, -65536, 262144, 1, -65535, 262144, 1, -65534, 262144, 1, 65538, 262144, 1, 65537, 131072, 3, 65536, 131072, 3, 131071, 262144, 1, 131070, 262144, 1, 131069, 262144, 1, 720889, 196608, 0, 786425, 196608, 1, 851961, 196608, 1, 917497, 196608, 1, 983033, 196608, 1, 1048569, 196608, 2, 720890, 262144, 0, 1048570, 262144, 2, 720891, 262144, 0, 1048571, 262144, 2, -65540, 196608, 0, -4, 196608, 1, 65532, 196608, 1, 131068, 196608, 1, 196604, 196608, 2, 458748, 196608, 0, 524284, 196608, 1, 589820, 196608, 1, 655356, 196608, 1, 720892, 65536, 4, 1048572, 65536, 3, 1114108, 196608, 1, 1179644, 196608, 1, 1245180, 196608, 2, -65539, 262144, 0, 196605, 262144, 2, 458749, 262144, 0, 1245181, 262144, 2, -65538, 262144, 0, 196606, 262144, 2, 458750, 262144, 0, 1245182, 65536, 3, 1310718, 196608, 1, 1376254, 196608, 1, 1441790, 196608, 1, 1507326, 196608, 2, -65537, 262144, 0, 196607, 262144, 2, 458751, 262144, 0, 1507327, 262144, 2, -131072, 262144, 0, 131072, 262144, 2, 393216, 262144, 0, 1441792, 262144, 2, -131071, 262144, 0, 131073, 262144, 2, 393217, 262144, 0, 720897, 0, 3, 786433, 327680, 1, 851969, 327680, 1, 917505, 327680, 1, 983041, 327680, 1, 1048577, 0, 4, 1441793, 262144, 2, -131070, 262144, 0, 131074, 262144, 2, 393218, 262144, 0, 720898, 262144, 2, 1048578, 262144, 0, 1441794, 262144, 2, -131069, 327680, 0, -65533, 0, 4, 65539, 0, 3, 131075, 327680, 2, 327683, 196608, 0, 393219, 65536, 4, 720899, 65536, 3, 786435, 196608, 2, 1048579, 262144, 0, 1441795, 262144, 2, -65532, 262144, 0, 65540, 262144, 2, 327684, 262144, 0, 786436, 262144, 2, 1048580, 262144, 0, 1441796, 262144, 2, -65531, 262144, 0, 65541, 262144, 2, 327685, 262144, 0, 786437, 262144, 2, 1048581, 262144, 0, 1441797, 262144, 2, -65530, 262144, 0, 65542, 262144, 2, 327686, 262144, 0, 786438, 65536, 3, 851974, 196608, 1, 917510, 196608, 2, 1048582, 262144, 0, 1441798, 262144, 2, -65529, 262144, 0, 65543, 262144, 2, 327687, 262144, 0, 917511, 262144, 2, 1048583, 262144, 0, 1441799, 65536, 3, -196600, 196608, 0, -131064, 196608, 1, -65528, 65536, 4, 65544, 262144, 2, 327688, 262144, 0, 917512, 262144, 2, 1048584, 262144, 0, 1441800, 262144, 1, -196599, 262144, 0, 65545, 262144, 2, 327689, 262144, 0, 917513, 262144, 2, 1048585, 262144, 0, 1441801, 262144, 1, -196598, 262144, 0, 65546, 65536, 3, 131082, 196608, 1, 196618, 196608, 1, 262154, 196608, 1, 327690, 65536, 4, 917514, 262144, 2, 1048586, 262144, 0, 1441802, 262144, 1, -196597, 262144, 0, 917515, 262144, 2, 1048587, 262144, 0, 1441803, 262144, 1, -196596, 262144, 0, 917516, 262144, 2, 1048588, 327680, 0, 1114124, 327680, 1, 1179660, 327680, 1, 1245196, 327680, 1, 1310732, 327680, 1, 1376268, 0, 4, 1441804, 262144, 1, -196595, 262144, 0, 458765, 0, 3, 524301, 327680, 1, 589837, 327680, 1, 655373, 0, 4, 917517, 262144, 2, -196594, 262144, 0, 458766, 262144, 2, 655374, 262144, 0, 917518, 262144, 2, -196593, 327680, 0, -131057, 327680, 1, -65521, 327680, 1, 15, 0, 4, 65551, 262144, 1, 131087, 262144, 1, 196623, 262144, 1, 327695, 262144, 1, 393231, 0, 3, 458767, 327680, 2, 655375, 327680, 0, 720911, 327680, 1, 786447, 327680, 1, 851983, 327680, 1, 917519, 327680, 2, 262159, 262144, 1, 262158, 262144, 1, 327693, 262144, 1, 393228, 262144, 1, 458763, 262144, 1, 458762, 262144, 1, 458761, 262144, 1, 524296, 131072, 3, 524295, 131072, 3, 589831, 131072, 3, 589830, 131072, 3, 655365, 262144, 1, 851989, 262144, 1, 917525, 262144, 1, 983061, 262144, 1, 1048597, 262144, 1, 1114133, 262144, 1, 1179669, 262144, 1, 1245205, 262144, 1, 1310741, 262144, 1, 1376277, 262144, 1, 1441813, 262144, 1, 1507349, 262144, 1, 1572885, 262144, 1, 1638421, 262144, 1, 851990, 262144, 1, 917526, 262144, 1, 983062, 262144, 1, 1048598, 262144, 1, 1114134, 262144, 1, 1179670, 262144, 1, 1245206, 262144, 1, 1310742, 262144, 1, 1376278, 262144, 1, 1441814, 262144, 1, 1507350, 262144, 1, 1572886, 262144, 1, 1638422, 262144, 1, 851991, 262144, 1, 917527, 262144, 1, 983063, 262144, 1, 1048599, 262144, 1, 1114135, 262144, 1, 1179671, 262144, 1, 1245207, 262144, 1, 1310743, 262144, 1, 1376279, 262144, 1, 1441815, 262144, 1, 1507351, 262144, 1, 1572887, 262144, 1, 1638423, 262144, 1, 851992, 262144, 1, 917528, 262144, 1, 983064, 262144, 1, 1048600, 262144, 1, 1114136, 262144, 1, 1179672, 262144, 1, 1245208, 262144, 1, 1310744, 262144, 1, 1376280, 262144, 1, 1441816, 262144, 1, 1507352, 262144, 1, 1572888, 262144, 1, 1638424, 262144, 1, 851993, 262144, 1, 917529, 262144, 1, 983065, 262144, 1, 1048601, 262144, 1, 1114137, 262144, 1, 1179673, 262144, 1, 1245209, 262144, 1, 1310745, 262144, 1, 1376281, 262144, 1, 1441817, 262144, 1, 1507353, 262144, 1, 1572889, 262144, 1, 1638425, 262144, 1, 851994, 262144, 1, 917530, 262144, 1, 983066, 262144, 1, 1048602, 262144, 1, 1114138, 262144, 1, 1179674, 262144, 1, 1245210, 262144, 1, 1310746, 262144, 1, 1376282, 262144, 1, 1441818, 262144, 1, 1507354, 262144, 1, 1572890, 262144, 1, 1638426, 262144, 1, 851995, 262144, 1, 917531, 262144, 1, 983067, 262144, 1, 1048603, 262144, 1, 1114139, 262144, 1, 1179675, 262144, 1, 1245211, 262144, 1, 1310747, 262144, 1, 1376283, 262144, 1, 1441819, 262144, 1, 1507355, 262144, 1, 1572891, 262144, 1, 1638427, 262144, 1, 851996, 262144, 1, 917532, 262144, 1, 983068, 262144, 1, 1048604, 262144, 1, 1114140, 262144, 1, 1179676, 262144, 1, 1245212, 262144, 1, 1310748, 262144, 1, 1376284, 262144, 1, 1441820, 262144, 1, 1507356, 262144, 1, 1572892, 262144, 1, 1638428, 262144, 1, 65555, 262144, 1, 131091, 262144, 1, 196627, 262144, 1, 262163, 262144, 1, 327699, 262144, 1, 65556, 262144, 1, 131092, 262144, 1, 196628, 262144, 1, 262164, 262144, 1, 327700, 262144, 1, 65557, 262144, 1, 131093, 262144, 1, 196629, 262144, 1, 262165, 262144, 1, 327701, 262144, 1, 65558, 262144, 1, 131094, 262144, 1, 196630, 262144, 1, 262166, 262144, 1, 327702, 262144, 1, 65559, 262144, 1, 131095, 262144, 1, 196631, 262144, 1, 262167, 262144, 1, 327703, 262144, 1, 65560, 262144, 1, 131096, 262144, 1, 196632, 262144, 1, 262168, 262144, 1, 327704, 262144, 1, 65561, 262144, 1, 131097, 262144, 1, 196633, 262144, 1, 262169, 262144, 1, 327705, 262144, 1, 393237, 262144, 1, 458773, 262144, 1, 524309, 262144, 1, 589845, 262144, 1, 655381, 262144, 1, 720917, 262144, 1, 786453, 262144, 1, 393238, 262144, 1, 458774, 262144, 1, 524310, 262144, 1, 589846, 262144, 1, 655382, 262144, 1, 720918, 262144, 1, 786454, 262144, 1, 393239, 262144, 1, 458775, 262144, 1, 524311, 262144, 1, 589847, 262144, 1, 655383, 262144, 1, 720919, 262144, 1, 786455, 262144, 1, 393240, 262144, 1, 458776, 262144, 1, 524312, 262144, 1, 589848, 262144, 1, 655384, 262144, 1, 720920, 262144, 1, 786456, 262144, 1, 393241, 262144, 1, 458777, 262144, 1, 524313, 262144, 1, 589849, 262144, 1, 655385, 262144, 1, 720921, 262144, 1, 786457, 262144, 1, 65552, 262144, 1, 131088, 262144, 1, 196624, 262144, 1, 262160, 262144, 1, 327696, 262144, 1, 65553, 262144, 1, 131089, 262144, 1, 196625, 262144, 1, 262161, 262144, 1, 327697, 262144, 1, 65554, 262144, 1, 131090, 262144, 1, 196626, 262144, 1, 262162, 262144, 1, 327698, 262144, 1, 1507336, 262144, 1, 1572872, 262144, 1, 1638408, 262144, 1, 1507337, 262144, 1, 1572873, 262144, 1, 1638409, 262144, 1, 1507338, 262144, 1, 1572874, 262144, 1, 1638410, 262144, 1, 1507339, 262144, 1, 1572875, 262144, 1, 1638411, 262144, 1, 1507340, 262144, 1, 1572876, 262144, 1, 1638412, 262144, 1, 1441805, 262144, 1, 1507341, 262144, 1, 1572877, 262144, 1, 1638413, 262144, 1, 1441806, 262144, 1, 1507342, 262144, 1, 1572878, 262144, 1, 1638414, 262144, 1, 1441807, 262144, 1, 1507343, 262144, 1, 1572879, 262144, 1, 1638415, 262144, 1, 1441808, 262144, 1, 1507344, 262144, 1, 1572880, 262144, 1, 1638416, 262144, 1, 1441809, 262144, 1, 1507345, 262144, 1, 1572881, 262144, 1, 1638417, 262144, 1, 1441810, 262144, 1, 1507346, 262144, 1, 1572882, 262144, 1, 1638418, 262144, 1, 1441811, 262144, 1, 1507347, 262144, 1, 1572883, 262144, 1, 1638419, 262144, 1, 1441812, 262144, 1, 1507348, 262144, 1, 1572884, 262144, 1, 1638420, 262144, 1, 1507335, 196608, 1, 1572871, 196608, 1, 1638407, 196608, 1, 1703944, 262144, 2, 1703945, 262144, 2, 1703946, 65536, 3, 1703947, 262144, 1, 1703948, 262144, 1, 1703949, 262144, 1, 1703950, 262144, 1, 1703951, 262144, 1, 1703952, 262144, 1, 1703953, 262144, 1, 1703954, 262144, 1, 1703955, 262144, 1, 1703956, 262144, 1, 1703957, 262144, 1, 1703958, 262144, 1, 1703959, 262144, 1, 1703960, 262144, 1, 1703961, 262144, 1, 1703962, 0, 3, 1703963, 262144, 2, 1703964, 262144, 2, 1703965, 327680, 2, 1114141, 327680, 1, 1179677, 327680, 1, 1245213, 327680, 1, 1310749, 327680, 1, 1376285, 327680, 1, 1441821, 327680, 1, 1507357, 327680, 1, 1572893, 327680, 1, 1638429, 327680, 1, 851997, 327680, 1, 917533, 327680, 1, 983069, 327680, 1, 1048605, 327680, 1, 65562, 327680, 1, 131098, 327680, 1, 196634, 327680, 1, 262170, 327680, 1, 327706, 327680, 1, 393242, 327680, 1, 458778, 327680, 1, 524314, 327680, 1, 589850, 327680, 1, 655386, 327680, 1, 720922, 327680, 1, 786458, 0, 4, 786459, 262144, 0, 786460, 262144, 0, 786461, 327680, 0, 16, 262144, 0, 17, 262144, 0, 18, 262144, 0, 19, 262144, 0, 20, 262144, 0, 21, 262144, 0, 22, 262144, 0, 23, 262144, 0, 24, 262144, 0, 25, 262144, 0, 26, 327680, 0, 393236, 65536, 3, 393232, 262144, 2, 393233, 262144, 2, 393234, 262144, 2, 393235, 262144, 2, 458772, 196608, 1, 524308, 196608, 1, 589844, 196608, 1, 655380, 196608, 1, 720916, 196608, 1, 786452, 196608, 1, 851988, 196608, 1, 917524, 196608, 1, 983060, 196608, 1, 1048596, 196608, 1, 1114132, 196608, 1, 1179668, 196608, 1, 1245204, 196608, 1, 1310740, 196608, 1, 1376276, 65536, 4, 1376269, 262144, 0, 1376270, 262144, 0, 1376271, 262144, 0, 1376272, 262144, 0, 1376273, 262144, 0, 1376274, 262144, 0, 1376275, 262144, 0, 1769484, 262144, 1, 1769485, 262144, 1, 1769486, 262144, 1, 1769487, 262144, 1, 1769488, 262144, 1, 1769489, 262144, 1, 1769490, 262144, 1, 1769491, 262144, 1, 1769492, 262144, 1, 1769493, 262144, 1, 1769494, 262144, 1, 1835022, 262144, 1, 1835023, 262144, 1, 1835024, 262144, 1, 1835025, 262144, 1, 1769483, 65536, 3, 1835021, 65536, 3, 1835026, 0, 3, 1769495, 0, 3, 1900562, 262144, 1, 1835031, 327680, 2, 1900557, 262144, 1, 1835019, 196608, 2, 1769482, 196608, 2, 1835020, 262144, 2, 1900560, 262144, 1, 1900561, 262144, 1, 1835027, 262144, 2, 1835028, 262144, 2, 1835029, 262144, 2, 1835030, 262144, 2, 1769496, 262144, 2, 1769497, 262144, 2, 1769498, 327680, 2, 1835016, 262144, 0, 1835017, 262144, 0, 1835018, 262144, 0, 1900552, 262144, 1, 1900553, 262144, 1, 1900554, 262144, 1, 1900555, 262144, 1, 1900556, 262144, 1, 1966088, 262144, 1, 1966089, 262144, 1, 1966090, 262144, 1, 1966091, 262144, 1, 1966092, 262144, 1, 1966093, 262144, 1, 1966094, 262144, 1, 1966095, 262144, 1, 1966096, 262144, 1, 1966097, 262144, 1, 1966098, 262144, 1, 1966099, 262144, 1, 1966100, 262144, 1, 1966101, 262144, 1, 1900563, 262144, 1, 1900564, 262144, 1, 1900565, 262144, 1, 1900566, 262144, 1, 1900567, 262144, 1, 1966102, 262144, 1, 1966103, 262144, 1, 1835032, 262144, 1, 1900568, 262144, 1, 1966104, 262144, 1, 2031626, 262144, 1, 2031627, 262144, 1, 2031628, 262144, 1, 2031629, 262144, 1, 2031630, 262144, 1, 2031631, 262144, 1, 2031632, 262144, 1, 2031633, 262144, 1, 2031634, 262144, 1, 2031635, 262144, 1, 2031636, 262144, 1, 2097172, 262144, 1, 2097171, 262144, 1, 2097170, 262144, 1, 2097169, 262144, 1, 2097168, 262144, 1, 2097167, 262144, 1, 2097166, 262144, 1, 2097165, 262144, 1, 2097164, 262144, 1, 2097163, 262144, 1, 2097162, 262144, 1, 2031637, 262144, 1, 2097173, 262144, 1, 2097174, 262144, 1, 2031638, 262144, 1, 2031639, 262144, 1, 2097175, 262144, 1, 2097176, 262144, 1, 2031640, 262144, 1, 2162699, 262144, 1, 2162700, 262144, 1, 2162701, 262144, 1, 2162702, 262144, 1, 2162703, 262144, 1, 2162704, 262144, 1, 2162705, 262144, 1, 2162709, 262144, 1, 2162710, 262144, 1, 2162711, 262144, 1, 2162708, 262144, 1, 2162707, 262144, 1, 2162706, 262144, 1, 2162698, 262144, 1, 2228234, 262144, 1, 2228235, 262144, 1, 2228236, 262144, 1, 2228237, 262144, 1, 2228238, 262144, 1, 2228239, 262144, 1, 2228240, 262144, 1, 2228241, 262144, 1, 2228242, 262144, 1, 2228243, 262144, 1, 2228244, 262144, 1, 2228245, 262144, 1, 2228246, 262144, 1, 2228247, 262144, 1, 2293769, 196608, 2, 2031623, 196608, 2, 2293784, 327680, 2, 2162713, 327680, 2, 1835033, 327680, 1, 1900569, 327680, 1, 1966105, 327680, 1, 2031641, 327680, 1, 2097177, 327680, 1, 2162712, 0, 3, 2031625, 65536, 3, 2031624, 262144, 2, 2097161, 196608, 1, 2162697, 196608, 1, 2228233, 196608, 1, 2293770, 262144, 2, 2293771, 262144, 2, 2293772, 262144, 2, 2293773, 262144, 2, 2293774, 262144, 2, 2293775, 262144, 2, 2293776, 262144, 2, 2293777, 262144, 2, 2293778, 262144, 2, 2293779, 262144, 2, 2293780, 262144, 2, 2293781, 262144, 2, 2293782, 262144, 2, 2293783, 262144, 2, 2228248, 327680, 1, 1966087, 196608, 1, 1900551, 196608, 1, 1835015, 196608, 0, 1703943, 196608, 2, 1900559, 262144, 1, 1900558, 262144, 1) @@ -251,26 +268,32 @@ layer_4/tile_data = PackedInt32Array(1114105, 196608, 3, 1114106, 262144, 3, 111 layer_5/tile_data = PackedInt32Array(786438, 262144, 3, 720899, 262144, 3, 851971, 458752, 3, 196611, 458752, 3, 1835019, 262144, 3, 1835034, 458752, 3) [node name="ExampleEnemy" parent="Entities" index="0" instance=ExtResource("3_hwof6")] -material = SubResource("ShaderMaterial_kq7i3") +material = SubResource("ShaderMaterial_5ho8d") position = Vector2(169, 115) [node name="ExampleEnemy2" parent="Entities" index="1" instance=ExtResource("3_hwof6")] -material = SubResource("ShaderMaterial_ck37u") +material = SubResource("ShaderMaterial_tic7i") position = Vector2(75, 130) [node name="ExampleEnemy3" parent="Entities" index="2" instance=ExtResource("3_hwof6")] -material = SubResource("ShaderMaterial_3i2mi") +material = SubResource("ShaderMaterial_oh7dr") position = Vector2(140, 177) [node name="ExampleEnemy4" parent="Entities" index="3" instance=ExtResource("3_hwof6")] -material = SubResource("ShaderMaterial_trolh") +material = SubResource("ShaderMaterial_x6kxt") position = Vector2(14, 159) [node name="ExampleEnemy5" parent="Entities" index="4" instance=ExtResource("3_hwof6")] -material = SubResource("ShaderMaterial_vuv4g") +material = SubResource("ShaderMaterial_uuq2q") position = Vector2(10, 22) Faction = 1 +[node name="Campfire" parent="Entities" index="5" instance=ExtResource("6_r6kxn")] +position = Vector2(155, -27) + +[node name="PointLight2D" parent="Entities/Campfire" index="1"] +color = Color(0.996078, 0.780392, 0.501961, 1) + [node name="Spawner" parent="Spawners" index="0" instance=ExtResource("4_pi4df")] position = Vector2(250, 512) Character = ExtResource("3_hwof6") @@ -279,4 +302,9 @@ SpawnTime = 5.0 [node name="CollisionShape2D" parent="Spawners/Spawner/Area2D" index="0"] shape = SubResource("RectangleShape2D_oods2") +[node name="WorldEnvironment" parent="." index="5"] +environment = SubResource("Environment_c0b2h") + +[editable path="Entities/Campfire"] +[editable path="Entities/Campfire/InteractionTrigger"] [editable path="Spawners/Spawner"] diff --git a/State/Character/CharacterState.cs b/State/Character/CharacterState.cs index 08fc94e..7632a4a 100644 --- a/State/Character/CharacterState.cs +++ b/State/Character/CharacterState.cs @@ -46,6 +46,13 @@ public abstract partial class CharacterState : Node, IState public virtual CharacterState PhysicsProcess(double delta) { + if (Character.Health < 0) + { + Character.Velocity = Vector2.Zero; + Character.MoveAndSlide(); + return null; + } + Character.Velocity = Character.NetImpulse; if (Character.NetImpulse.LengthSquared() < Mathf.Pow(Character.Speed, 2)) diff --git a/State/Character/PlayerRollState.cs b/State/Character/PlayerRollState.cs index 57b6c87..4c0ddbc 100644 --- a/State/Character/PlayerRollState.cs +++ b/State/Character/PlayerRollState.cs @@ -8,12 +8,28 @@ public partial class PlayerRollState : PlayerState private Vector2 _rollDirection = Vector2.Zero; + private AnimationPlayer _rollAnimation; + + public override void _Ready() + { + _rollAnimation = _player.GetNode("RollAnimation"); + base._Ready(); + } + public override IState Enter(IState previousState) { _timeLeftToRoll = 0.5; // roll the direction we were previously moving in _rollDirection = Character.Direction; Character.Target = Character.Direction; + if (Character.Direction.X >= 0) + { + _rollAnimation.Play("roll"); + } + else + { + _rollAnimation.PlayBackwards("roll"); + } return base.Enter(previousState); } @@ -23,13 +39,14 @@ public partial class PlayerRollState : PlayerState // this state (e.g. from death) _timeLeftToRoll = 0; _rollDirection = Character.Direction; + _rollAnimation.Stop(); base.Exit(nextState); } public override CharacterState Process(double delta) { Character.Direction = _rollDirection; - if ((_timeLeftToRoll -= delta) <= 0) + if ((_timeLeftToRoll -= delta) <= 0 || _player.Health <= 0) { return IdleState; } diff --git a/State/Character/PlayerState.cs b/State/Character/PlayerState.cs index 648d2e7..ed57644 100644 --- a/State/Character/PlayerState.cs +++ b/State/Character/PlayerState.cs @@ -13,14 +13,26 @@ public abstract partial class PlayerState : CharacterState public override CharacterState Input(InputEvent @event) { var inventory = Character.Inventory; + var player = _player; if (this is PlayerIdleState or PlayerMoveState && - !_player.Inventory.IsUsingItem) + !player.Inventory.IsUsingItem) { if (@event.IsActionPressed("equip_1")) { inventory.SelectedItem = inventory.GetItemByMap("equip_1"); } + else if (@event.IsActionPressed("equip_2")) + { + inventory.SelectedItem = inventory.GetItemByMap("equip_2"); + } + + if (@event.IsActionPressed("interact")) + { + // if looking at a trigger then interact with it + GD.Print("interacting"); + player.InteractionRay.Trigger?.InvokeInteraction(); + } } return base.Input(@event); diff --git a/State/Health/AliveState.cs b/State/Health/AliveState.cs new file mode 100644 index 0000000..5cc71dd --- /dev/null +++ b/State/Health/AliveState.cs @@ -0,0 +1,6 @@ +namespace SupaLidlGame.State.Health; + +public partial class AliveState : HealthState +{ + +} diff --git a/State/Health/DeadState.cs b/State/Health/DeadState.cs new file mode 100644 index 0000000..bcf71b1 --- /dev/null +++ b/State/Health/DeadState.cs @@ -0,0 +1 @@ +namespace SupaLidlGame.State.Health; diff --git a/State/Health/HealthState.cs b/State/Health/HealthState.cs new file mode 100644 index 0000000..f0f5ab1 --- /dev/null +++ b/State/Health/HealthState.cs @@ -0,0 +1,13 @@ +using Godot; + +namespace SupaLidlGame.State.Health; + +public abstract partial class HealthState : Node, IState +{ + public virtual IState Enter(IState prev) => null; + + public virtual void Exit(IState next) + { + + } +} diff --git a/State/NPC/Doc/DocAttackState.cs b/State/NPC/Doc/DocAttackState.cs new file mode 100644 index 0000000..2caf1ec --- /dev/null +++ b/State/NPC/Doc/DocAttackState.cs @@ -0,0 +1,16 @@ +using Godot; + +namespace SupaLidlGame.State.NPC.Doc; + +public abstract partial class DocAttackState : NPCState +{ + public abstract double Duration { get; set; } + + public abstract double AttackDuration { get; set; } + + public abstract PackedScene Projectile { get; set; } + + public abstract DocChooseAttackState ChooseAttackState { get; set; } + + protected abstract void Attack(); +} diff --git a/State/NPC/Doc/DocChooseAttackState.cs b/State/NPC/Doc/DocChooseAttackState.cs new file mode 100644 index 0000000..6959bd7 --- /dev/null +++ b/State/NPC/Doc/DocChooseAttackState.cs @@ -0,0 +1,51 @@ +using Godot; +using System.Collections.Generic; + +namespace SupaLidlGame.State.NPC.Doc; + +public partial class DocChooseAttackState : NPCState +{ + [Export] + public DocShungiteDartState DartState { get; set; } + + [Export] + public DocShungiteSpikeState SpikeState { get; set; } + + [Export] + public DocExitState ExitState { get; set; } + + public Characters.Doc Doc => NPC as Characters.Doc; + + private List _states = new List(); + + private int _consecutiveAttacks = 0; + + public override void _Ready() + { + _states.Add(DartState); + _states.Add(SpikeState); + base._Ready(); + } + + public override NPCState Enter(IState previous) + { + if (previous is not DocTelegraphState) + { + _consecutiveAttacks++; + } + else + { + _consecutiveAttacks = 0; + } + + if (_consecutiveAttacks > Doc.Intensity) + { + _consecutiveAttacks = 0; + return ExitState; + } + + // choose random attack + var random = new System.Random(); + return _states[random.Next(_states.Count)]; + } +} diff --git a/State/NPC/Doc/DocExitState.cs b/State/NPC/Doc/DocExitState.cs new file mode 100644 index 0000000..b924cc1 --- /dev/null +++ b/State/NPC/Doc/DocExitState.cs @@ -0,0 +1,38 @@ +using Godot; + +namespace SupaLidlGame.State.NPC.Doc; + +public partial class DocExitState : NPCState +{ + [Export] + public AnimationPlayer TelegraphAnimationPlayer { get; set; } + + [Export] + public DocTelegraphState TelegraphState { get; set; } + + [Export] + public double Duration { get; set; } = 1; + + private double _currentDuration = 0; + + public override NPCState Enter(IState previousState) + { + _currentDuration = Duration; + TelegraphAnimationPlayer.Play("exit_out"); + return null; + } + + public override void Exit(IState nextState) + { + + } + + public override NPCState Process(double delta) + { + if ((_currentDuration -= delta) <= 0) + { + return TelegraphState; + } + return null; + } +} diff --git a/State/NPC/Doc/DocShungiteDartState.cs b/State/NPC/Doc/DocShungiteDartState.cs new file mode 100644 index 0000000..f2b2601 --- /dev/null +++ b/State/NPC/Doc/DocShungiteDartState.cs @@ -0,0 +1,86 @@ +using Godot; +using GodotUtilities; +using SupaLidlGame.Entities; + +namespace SupaLidlGame.State.NPC.Doc; + +public partial class DocShungiteDartState : DocAttackState +{ + protected Scenes.Map _map; + protected Utils.World _world; + + protected double _currentDuration = 0; + protected double _currentAttackDuration = 0; + + [Export] + public override double Duration { get; set; } + + [Export] + public override double AttackDuration { get; set; } + + [Export] + public override PackedScene Projectile { get; set; } + + [Export] + public override DocChooseAttackState ChooseAttackState { get; set; } + + [Export] + public Characters.Doc Doc { get; set; } + + public override NPCState Enter(IState previousState) + { + _map = this.GetAncestor(); + _world = this.GetAncestor(); + _currentDuration = Duration; + _currentAttackDuration = AttackDuration; + return null; + } + + public override void Exit(IState nextState) + { + + } + + protected virtual Projectile SpawnProjectile( + Vector2 position, + Vector2 direction) + { + var projectile = _map.SpawnEntity(Projectile); + projectile.Hitbox.Faction = NPC.Faction; + // global position is (from npc to player) * 2 = (2 * npc) - player + //projectile.GlobalPosition = 2 * NPC.GlobalPosition - playerPos; + projectile.GlobalPosition = position; + projectile.Direction = direction; + projectile.GlobalRotation = direction.Angle(); + projectile.Delay = 1.0 / Doc.Intensity; + return projectile; + } + + protected override void Attack() + { + var player = _world.CurrentPlayer; + var playerPos = player.GlobalPosition; + Vector2 position1 = 2 * NPC.GlobalPosition - playerPos; + Vector2 position2 = 2 * playerPos - NPC.GlobalPosition; + Vector2 direction1 = position1.DirectionTo(playerPos); + Vector2 direction2 = -direction1; + SpawnProjectile(position1, direction1); + SpawnProjectile(position2, direction2); + _currentAttackDuration = AttackDuration / Doc.Intensity; + } + + public override NPCState Process(double delta) + { + if ((_currentDuration -= delta) <= 0) + { + return ChooseAttackState; + } + + if ((_currentAttackDuration -= delta) <= 0) + { + Attack(); + } + + return null; + } +} diff --git a/State/NPC/Doc/DocShungiteSpikeState.cs b/State/NPC/Doc/DocShungiteSpikeState.cs new file mode 100644 index 0000000..6f76bcb --- /dev/null +++ b/State/NPC/Doc/DocShungiteSpikeState.cs @@ -0,0 +1,61 @@ +using Godot; +using SupaLidlGame.Entities; + +namespace SupaLidlGame.State.NPC.Doc; + +public partial class DocShungiteSpikeState : DocShungiteDartState +{ + private float _intensity = 1; + + public override NPCState Enter(IState previous) + { + // subtract from total state time by intensity + Duration = _currentDuration = 9 - 2 * Doc.Intensity; + return base.Enter(previous); + } + + protected override Projectile SpawnProjectile( + Vector2 position, + Vector2 direction) + { + var projectile = base.SpawnProjectile(position, direction) + as ShungiteSpike; + projectile.GlobalRotation = 0; + projectile.Delay = 0; + projectile.ExplodeTime = 6 - 2 * Doc.Intensity; + projectile.Hitbox.Faction = projectile.Hurtbox.Faction = Doc.Faction; + return projectile; + } + + protected override void Attack() + { + var player = _world.CurrentPlayer; + var playerPos = player.GlobalPosition; + Vector2 left = playerPos + Vector2.Left * 64; + Vector2 right = playerPos + Vector2.Right * 64; + Vector2 up = playerPos + Vector2.Up * 64; + Vector2 down = playerPos + Vector2.Down * 64; + SpawnProjectile(left, Vector2.Zero); + SpawnProjectile(right, Vector2.Zero); + SpawnProjectile(up, Vector2.Zero); + SpawnProjectile(down, Vector2.Zero); + + // only attack once and stop (but keep in this state for 8 seconds) + _currentAttackDuration += 8; + } + + public override NPCState Process(double delta) + { + if ((_currentDuration -= delta) <= 0) + { + return ChooseAttackState; + } + + if ((_currentAttackDuration -= delta) <= 0) + { + Attack(); + } + + return null; + } +} diff --git a/State/NPC/Doc/DocTelegraphState.cs b/State/NPC/Doc/DocTelegraphState.cs new file mode 100644 index 0000000..33649af --- /dev/null +++ b/State/NPC/Doc/DocTelegraphState.cs @@ -0,0 +1,41 @@ +using Godot; + +namespace SupaLidlGame.State.NPC.Doc; + +public partial class DocTelegraphState : NPCState +{ + [Export] + public AnimationPlayer TelegraphAnimationPlayer { get; set; } + + [Export] + public DocChooseAttackState AttackState { get; set; } + + [Export] + public double Duration { get; set; } = 1; + + private double _currentDuration = 1; + + public override NPCState Enter(IState previousState) + { + _currentDuration = Duration; + TelegraphAnimationPlayer.Play("enter_in"); + float randX = GD.RandRange(-128, 128); + float randY = GD.RandRange(-128, 128); + NPC.GlobalPosition = new Vector2(randX, randY); + return null; + } + + public override void Exit(IState nextState) + { + + } + + public override NPCState Process(double delta) + { + if ((_currentDuration -= delta) <= 0) + { + return AttackState; + } + return null; + } +} diff --git a/State/NPC/NPCState.cs b/State/NPC/NPCState.cs new file mode 100644 index 0000000..44564a8 --- /dev/null +++ b/State/NPC/NPCState.cs @@ -0,0 +1,18 @@ +using Godot; + +namespace SupaLidlGame.State.NPC; + +public abstract partial class NPCState : Node, IState +{ + [Export] + public SupaLidlGame.Characters.NPC NPC { get; set; } + + public abstract IState Enter(IState previousState); + + public virtual void Exit(IState nextState) + { + + } + + public virtual IState Process(double delta) => null; +} diff --git a/State/NPC/NPCStateMachine.cs b/State/NPC/NPCStateMachine.cs new file mode 100644 index 0000000..8905a58 --- /dev/null +++ b/State/NPC/NPCStateMachine.cs @@ -0,0 +1,18 @@ +using Godot; + +namespace SupaLidlGame.State.NPC; + +public partial class NPCStateMachine : StateMachine +{ + [Export] + public override NPCState InitialState { get; set; } + + public void Process(double delta) + { + var state = CurrentState.Process(delta); + if (state is NPCState s) + { + ChangeState(s); + } + } +} diff --git a/State/NPC/TelegraphState.cs b/State/NPC/TelegraphState.cs new file mode 100644 index 0000000..ee35116 --- /dev/null +++ b/State/NPC/TelegraphState.cs @@ -0,0 +1,19 @@ +using Godot; + +namespace SupaLidlGame.State.NPC; + +public partial class NPCTelegraphState : NPCState +{ + [Export] + public double Duration { get; set; } + + public override NPCState Enter(IState previousState) + { + return null; + } + + public override void Exit(IState nextState) + { + + } +} diff --git a/SupaLidlGame.csproj b/SupaLidlGame.csproj index c9adce8..e7f1627 100644 --- a/SupaLidlGame.csproj +++ b/SupaLidlGame.csproj @@ -3,4 +3,7 @@ net6.0 true + + + \ No newline at end of file diff --git a/SupaLidlGame.sln b/SupaLidlGame.sln index d222077..f6135a2 100644 --- a/SupaLidlGame.sln +++ b/SupaLidlGame.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SupaLidlGame", "SupaLidlGame.csproj", "{AF3A4D72-D276-44C3-A64F-EAB32D2B9B97}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SupaLidlGame", "SupaLidlGame.csproj", "{BC071CA6-9462-4CEC-AA20-B0CA618321E5}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -9,11 +9,11 @@ Global ExportRelease|Any CPU = ExportRelease|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AF3A4D72-D276-44C3-A64F-EAB32D2B9B97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AF3A4D72-D276-44C3-A64F-EAB32D2B9B97}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AF3A4D72-D276-44C3-A64F-EAB32D2B9B97}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU - {AF3A4D72-D276-44C3-A64F-EAB32D2B9B97}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU - {AF3A4D72-D276-44C3-A64F-EAB32D2B9B97}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU - {AF3A4D72-D276-44C3-A64F-EAB32D2B9B97}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU + {BC071CA6-9462-4CEC-AA20-B0CA618321E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BC071CA6-9462-4CEC-AA20-B0CA618321E5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BC071CA6-9462-4CEC-AA20-B0CA618321E5}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU + {BC071CA6-9462-4CEC-AA20-B0CA618321E5}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU + {BC071CA6-9462-4CEC-AA20-B0CA618321E5}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU + {BC071CA6-9462-4CEC-AA20-B0CA618321E5}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU EndGlobalSection EndGlobal diff --git a/Utils/DamageTime.cs b/Utils/DamageTime.cs new file mode 100644 index 0000000..ff213bf --- /dev/null +++ b/Utils/DamageTime.cs @@ -0,0 +1,41 @@ +using Godot; + +namespace SupaLidlGame.Utils; + +public partial class DamageTime : Node +{ + private double _duration = 0.1; + + private double _currentDuration = 0; + + private double _startValue = 0; + + public override void _Ready() + { + if (GetParent() is Characters.Player player) + { + player.Hurt += PlayerHurt; + } + } + + private void PlayerHurt(Events.HealthChangedArgs args) + { + if (args.Damage > 10) + { + // temp + //float strength = 0.8f; + //_startValue = 1 - strength; + //_currentDuration = 0; + _currentDuration = _duration; + Engine.TimeScale = 0.1; + } + } + + public override void _Process(double delta) + { + if ((_currentDuration -= delta) < 0) + { + Engine.TimeScale = 1; + } + } +} diff --git a/Utils/IInteractive.cs b/Utils/IInteractive.cs new file mode 100644 index 0000000..d094081 --- /dev/null +++ b/Utils/IInteractive.cs @@ -0,0 +1,6 @@ +namespace SupaLidlGame.Utils; + +public interface IInteractive +{ + public BoundingBoxes.InteractionTrigger InteractionTrigger { get; set; } +} diff --git a/Utils/Spawner.cs b/Utils/Spawner.cs index 0d642ca..07a5351 100644 --- a/Utils/Spawner.cs +++ b/Utils/Spawner.cs @@ -1,5 +1,6 @@ using Godot; using Godot.Collections; +using GodotUtilities; using SupaLidlGame.Extensions; namespace SupaLidlGame.Utils; diff --git a/Utils/World.cs b/Utils/World.cs index 4ffe2d6..8e426d7 100644 --- a/Utils/World.cs +++ b/Utils/World.cs @@ -1,7 +1,6 @@ using Godot; using SupaLidlGame.Characters; using SupaLidlGame.Scenes; -using SupaLidlGame.Extensions; using System.Collections.Generic; using System.Linq; @@ -24,6 +23,10 @@ public partial class World : Node2D private string _currentMapResourcePath; + //private Entities.Campfire _lastCampfire = null; + public Vector2 SaveLocation { get; set; } + public string SaveMapKey { get; set; } + private const string PLAYER_PATH = "res://Characters/Player.tscn"; private PackedScene _playerScene; @@ -43,23 +46,21 @@ public partial class World : Node2D // spawn the player in CreatePlayer(); + CurrentPlayer.Death += (Events.HealthChangedArgs args) => + { + // TODO: respawn the player at the last campfire. + GetTree().CreateTimer(1).Timeout += () => + { + SpawnPlayer(); + }; + }; + base._Ready(); } - public void LoadScene(PackedScene scene) + private void LoadMap(Map map) { - GD.Print("Loading map " + scene.ResourcePath); - - Map map; - if (_maps.ContainsKey(scene.ResourcePath)) - { - map = _maps[scene.ResourcePath]; - } - else - { - map = scene.Instantiate(); - _maps.Add(scene.ResourcePath, map); - } + GD.Print("Loading map " + map.Name); if (CurrentMap is not null) { @@ -80,6 +81,39 @@ public partial class World : Node2D } } + public void LoadScene(PackedScene scene) + { + Map map; + if (_maps.ContainsKey(scene.ResourcePath)) + { + map = _maps[scene.ResourcePath]; + } + else + { + map = scene.Instantiate(); + _maps.Add(scene.ResourcePath, map); + } + + LoadMap(map); + } + + public void LoadScene(string path) + { + Map map; + if (_maps.ContainsKey(path)) + { + map = _maps[path]; + } + else + { + var scene = ResourceLoader.Load(path); + map = scene.Instantiate(); + _maps.Add(scene.ResourcePath, map); + } + + LoadMap(map); + } + public void CreatePlayer() { CurrentPlayer = _playerScene.Instantiate(); @@ -111,7 +145,7 @@ public partial class World : Node2D } return false; }) as BoundingBoxes.ConnectorBox; - + CurrentPlayer.GlobalPosition = connector.GlobalPosition; } @@ -146,4 +180,36 @@ public partial class World : Node2D { throw new System.NotImplementedException(); } + + /// + /// Sets the player's saved spawn position. + /// + /// The position to save and spawn the player in + /// + /// The map to spawn the player in. If , use the + /// World's CurrentMap + /// + public void SetSpawn(Vector2 position, string mapKey = null) + { + GD.Print("Set spawn"); + if (mapKey is null) + { + mapKey = CurrentMap.SceneFilePath; + SaveLocation = position; + SaveMapKey = mapKey; + } + } + + public void SpawnPlayer() + { + // TODO: add max health property + //CurrentPlayer.Health = 100; + //CurrentPlayer.Sprite.Visible = true; + if (CurrentMap.SceneFilePath != SaveMapKey) + { + LoadScene(SaveMapKey); + } + CurrentPlayer.GlobalPosition = SaveLocation; + CurrentPlayer.Spawn(); + } } diff --git a/project.godot b/project.godot index c2544a1..e50529c 100644 --- a/project.godot +++ b/project.godot @@ -89,7 +89,13 @@ equip_3={ 2d_physics/layer_3="Player" 2d_physics/layer_4="NPC" 2d_physics/layer_5="World Clip" +2d_physics/layer_6="Interaction Receiver" +2d_physics/layer_7="Interaction Trigger" [physics] 2d/default_gravity=0.0 + +[rendering] + +environment/defaults/default_clear_color=Color(0.301961, 0.301961, 0.301961, 1)