supa wip
parent
19b8bf362d
commit
2833e76175
|
@ -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)
|
|
@ -1,4 +1,5 @@
|
|||
using Godot;
|
||||
using GodotUtilities;
|
||||
using SupaLidlGame.Extensions;
|
||||
using SupaLidlGame.Items;
|
||||
using SupaLidlGame.Utils;
|
||||
|
@ -95,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)
|
||||
|
@ -188,6 +181,11 @@ public partial class Character : CharacterBody2D, IFaction
|
|||
Vector2 knockbackOrigin = default,
|
||||
Vector2 knockbackVector = default)
|
||||
{
|
||||
if (Health <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float oldHealth = Health;
|
||||
Health -= damage;
|
||||
|
||||
|
@ -232,7 +230,7 @@ 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
|
||||
|
@ -242,11 +240,15 @@ public partial class Character : CharacterBody2D, IFaction
|
|||
NewHealth = Health,
|
||||
Damage = damage,
|
||||
};
|
||||
|
||||
EmitSignal(SignalName.Hurt, args);
|
||||
|
||||
if (Health <= 0)
|
||||
{
|
||||
EmitSignal(SignalName.Death, args);
|
||||
GetNode<GpuParticles2D>("DeathParticles")
|
||||
.CloneOnWorld<GpuParticles2D>()
|
||||
.EmitOneShot();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -47,6 +47,24 @@ public sealed partial class Player : Character
|
|||
_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()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=33 format=3 uid="uid://b2254pup8k161"]
|
||||
[gd_scene load_steps=37 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"]
|
||||
|
@ -172,6 +172,30 @@ _data = {
|
|||
"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
|
||||
|
@ -289,4 +313,12 @@ 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
|
||||
|
||||
[editable path="Hurtbox"]
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
[gd_scene load_steps=13 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="Script" path="res://BoundingBoxes/InteractionTrigger.cs" id="4_h1bqe"]
|
||||
[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")
|
||||
|
@ -56,9 +56,41 @@ animations = [{
|
|||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ubam4"]
|
||||
size = Vector2(16, 4)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_dfj3a"]
|
||||
[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)
|
||||
|
@ -66,12 +98,14 @@ 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
|
||||
|
||||
|
@ -79,11 +113,14 @@ texture_scale = 0.25
|
|||
position = Vector2(0, 6)
|
||||
shape = SubResource("RectangleShape2D_ubam4")
|
||||
|
||||
[node name="InteractionTrigger" type="Area2D" parent="."]
|
||||
collision_layer = 64
|
||||
collision_mask = 0
|
||||
script = ExtResource("4_h1bqe")
|
||||
[node name="InteractionTrigger" parent="." instance=ExtResource("4_yoo3p")]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="InteractionTrigger"]
|
||||
[node name="CollisionShape2D" parent="InteractionTrigger" index="0"]
|
||||
position = Vector2(0, 5)
|
||||
shape = SubResource("RectangleShape2D_dfj3a")
|
||||
shape = SubResource("RectangleShape2D_p0hsm")
|
||||
|
||||
[node name="GPUParticles2D" type="GPUParticles2D" parent="."]
|
||||
amount = 40
|
||||
process_material = SubResource("ParticleProcessMaterial_xtx2m")
|
||||
|
||||
[editable path="InteractionTrigger"]
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Godot;
|
||||
using GodotUtilities;
|
||||
using System;
|
||||
|
||||
namespace SupaLidlGame.Extensions;
|
||||
|
@ -43,7 +44,7 @@ public static class AudioStreamPlayer2DExtensions
|
|||
this AudioStreamPlayer2D audio,
|
||||
Vector2 globalPosition)
|
||||
{
|
||||
var world = audio.GetTree().Root.GetNode("World/TileMap");
|
||||
var world = audio.GetAncestor<Scenes.Map>();
|
||||
if (world is null)
|
||||
{
|
||||
throw new NullReferenceException("World does not exist");
|
||||
|
@ -61,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)
|
||||
|
|
|
@ -8,7 +8,8 @@ public static class NodeExtensions
|
|||
/// Iterates through each ancestor until it finds an ancestor of type
|
||||
/// <c>T</c>
|
||||
/// </summary>
|
||||
public static T GetAncestor<T>(this Node node) where T : Node
|
||||
[System.Obsolete]
|
||||
public static T GetAncestorDeprecated<T>(this Node node) where T : Node
|
||||
{
|
||||
Node parent;
|
||||
|
||||
|
|
|
@ -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<Node2D>(node);
|
||||
}
|
||||
|
||||
public static T CloneOnWorld<T>(this Node2D node) where T : Node2D
|
||||
{
|
||||
var world = node.GetAncestor<Scenes.Map>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
using Godot;
|
||||
using SupaLidlGame.Extensions;
|
||||
using GodotUtilities;
|
||||
|
||||
namespace SupaLidlGame.Items.Weapons;
|
||||
|
||||
|
|
|
@ -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<AudioStreamPlayer2D>("ParrySound").OnWorld().Play();
|
||||
GetNode<AudioStreamPlayer2D>("ParrySound").OnWorld().PlayOneShot();
|
||||
}
|
||||
|
||||
public override void _on_hitbox_hit(BoundingBox box)
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -46,6 +46,13 @@ public abstract partial class CharacterState : Node, IState<CharacterState>
|
|||
|
||||
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))
|
||||
|
|
|
@ -46,7 +46,7 @@ public partial class PlayerRollState : PlayerState
|
|||
public override CharacterState Process(double delta)
|
||||
{
|
||||
Character.Direction = _rollDirection;
|
||||
if ((_timeLeftToRoll -= delta) <= 0)
|
||||
if ((_timeLeftToRoll -= delta) <= 0 || _player.Health <= 0)
|
||||
{
|
||||
return IdleState;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Godot.NET.Sdk/4.1.0-dev">
|
||||
<Project Sdk="Godot.NET.Sdk/4.1.0-beta.1">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using Godot;
|
||||
using Godot.Collections;
|
||||
using GodotUtilities;
|
||||
using SupaLidlGame.Extensions;
|
||||
|
||||
namespace SupaLidlGame.Utils;
|
||||
|
|
|
@ -49,7 +49,10 @@ public partial class World : Node2D
|
|||
CurrentPlayer.Death += (Events.HealthChangedArgs args) =>
|
||||
{
|
||||
// TODO: respawn the player at the last campfire.
|
||||
SpawnPlayer();
|
||||
GetTree().CreateTimer(1).Timeout += () =>
|
||||
{
|
||||
SpawnPlayer();
|
||||
};
|
||||
};
|
||||
|
||||
base._Ready();
|
||||
|
@ -200,11 +203,13 @@ public partial class World : Node2D
|
|||
public void SpawnPlayer()
|
||||
{
|
||||
// TODO: add max health property
|
||||
CurrentPlayer.Health = 100;
|
||||
CurrentPlayer.GlobalPosition = SaveLocation;
|
||||
//CurrentPlayer.Health = 100;
|
||||
//CurrentPlayer.Sprite.Visible = true;
|
||||
if (CurrentMap.SceneFilePath != SaveMapKey)
|
||||
{
|
||||
LoadScene(SaveMapKey);
|
||||
}
|
||||
CurrentPlayer.GlobalPosition = SaveLocation;
|
||||
CurrentPlayer.Spawn();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,13 +47,13 @@ ui_down={
|
|||
}
|
||||
roll={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":3,"pressed":false,"double_click":false,"script":null)
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":3,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
attack1={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"pressed":false,"double_click":false,"script":null)
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
equip={
|
||||
|
|
Loading…
Reference in New Issue