Compare commits

..

2 Commits

9 changed files with 123 additions and 16 deletions

View File

@ -137,7 +137,8 @@ public sealed partial class Player : Character
{ {
base.Stun(time); base.Stun(time);
Camera.Shake(2, 0.8f); Camera.Shake(2, 0.8f);
// TODO: implement visual effects for stun Events.EventBus.Instance.EmitSignal(
Events.EventBus.SignalName.PlayerStun);
} }
protected override void OnReceivedDamage( protected override void OnReceivedDamage(

View File

@ -33,6 +33,9 @@ public partial class EventBus : Node
[Signal] [Signal]
public delegate void PlayerHealthChangedEventHandler(HealthChangedArgs args); public delegate void PlayerHealthChangedEventHandler(HealthChangedArgs args);
[Signal]
public delegate void PlayerStunEventHandler();
[Signal] [Signal]
public delegate void RegisteredBossEventHandler(Characters.Boss boss); public delegate void RegisteredBossEventHandler(Characters.Boss boss);

View File

@ -0,0 +1,11 @@
shader_type canvas_item;
uniform float grayscale_intensity : hint_range(0.0, 1.0) = 0.0;
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
void fragment() {
vec4 color = texture(SCREEN_TEXTURE, SCREEN_UV);
float average = (color.r + color.g + color.b) / 3.0;
COLOR = vec4(vec3(average), grayscale_intensity);
}

View File

@ -6,18 +6,18 @@ uniform vec4 vignette_rgb : source_color = vec4(0.0, 0.0, 0.0, 1.0);
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap; uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
float vignette(vec2 uv){ float vignette(vec2 uv) {
uv *= 1.0 - uv.xy; uv *= 1.0 - uv.xy;
float vignette = uv.x * uv.y * 15.0; float vignette = uv.x * uv.y * 15.0;
return pow(vignette, vignette_intensity * vignette_opacity); return pow(vignette, vignette_intensity * vignette_opacity);
} }
void fragment(){ void fragment() {
vec4 color = texture(SCREEN_TEXTURE, SCREEN_UV); vec4 color = texture(SCREEN_TEXTURE, SCREEN_UV);
vec4 text = texture(TEXTURE, UV); vec4 text = texture(TEXTURE, UV);
text.rgba *= (vignette_rgb.rgba); text.rgba *= (vignette_rgb.rgba);
text.rgba *= (1.0 - vignette(UV)); text.rgba *= (1.0 - vignette(UV));
COLOR = vec4((text.rgb)*color.rgb,text.a); COLOR = vec4((text.rgb) * color.rgb, text.a);
} }

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=10 format=3 uid="uid://c271rdjhd1gfo"] [gd_scene load_steps=14 format=3 uid="uid://c271rdjhd1gfo"]
[ext_resource type="PackedScene" uid="uid://73jm5qjy52vq" path="res://Dialogue/balloon.tscn" id="1_atjb1"] [ext_resource type="PackedScene" uid="uid://73jm5qjy52vq" path="res://Dialogue/balloon.tscn" id="1_atjb1"]
[ext_resource type="Script" path="res://UI/UIController.cs" id="2_b4b6l"] [ext_resource type="Script" path="res://UI/UIController.cs" id="2_b4b6l"]
@ -9,6 +9,13 @@
[ext_resource type="PackedScene" uid="uid://sfs8dpfitpdu" path="res://UI/Hotbar.tscn" id="5_mmp18"] [ext_resource type="PackedScene" uid="uid://sfs8dpfitpdu" path="res://UI/Hotbar.tscn" id="5_mmp18"]
[ext_resource type="PackedScene" uid="uid://d3q1yu3n7cqfj" path="res://UI/SceneTransition.tscn" id="6_j0nhv"] [ext_resource type="PackedScene" uid="uid://d3q1yu3n7cqfj" path="res://UI/SceneTransition.tscn" id="6_j0nhv"]
[ext_resource type="PackedScene" uid="uid://2afbrf8asy2a" path="res://UI/PostProcessing/Vignette.tscn" id="9_p1ubd"] [ext_resource type="PackedScene" uid="uid://2afbrf8asy2a" path="res://UI/PostProcessing/Vignette.tscn" id="9_p1ubd"]
[ext_resource type="PackedScene" uid="uid://b1wsryv4bn0cn" path="res://UI/PostProcessing/StunEffect.tscn" id="10_646ma"]
[ext_resource type="Shader" path="res://Shaders/Grayscale.gdshader" id="11_w4gn1"]
[ext_resource type="Texture2D" uid="uid://bw052v8ikfget" path="res://icon.svg" id="12_tyv35"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_kbd61"]
shader = ExtResource("11_w4gn1")
shader_parameter/grayscale_intensity = 0.0
[node name="BaseUI" type="CanvasLayer"] [node name="BaseUI" type="CanvasLayer"]
process_mode = 3 process_mode = 3
@ -105,7 +112,22 @@ layout_mode = 2
[node name="SceneTransition" parent="SubViewportContainer/UIViewport/MainUILayer" instance=ExtResource("6_j0nhv")] [node name="SceneTransition" parent="SubViewportContainer/UIViewport/MainUILayer" instance=ExtResource("6_j0nhv")]
z_index = 1 z_index = 1
[node name="PostProcessing" type="CanvasLayer" parent="SubViewportContainer/UIViewport"] [node name="PostProcessing" type="CanvasLayer" parent="."]
layer = 2
[node name="TextureRect" parent="SubViewportContainer/UIViewport/PostProcessing" instance=ExtResource("9_p1ubd")] [node name="Vignette" parent="PostProcessing" instance=ExtResource("9_p1ubd")]
[node name="StunEffect" parent="PostProcessing" instance=ExtResource("10_646ma")]
[node name="Sprite2D" type="TextureRect" parent="PostProcessing"]
visible = false
material = SubResource("ShaderMaterial_kbd61")
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -128.0
offset_top = -128.0
grow_horizontal = 0
grow_vertical = 0
texture = ExtResource("12_tyv35")

View File

@ -0,0 +1,15 @@
using Godot;
namespace SupaLidlGame.UI.PostProcessing;
public partial class StunEffect : ColorRect
{
public override void _Ready()
{
Events.EventBus.Instance.PlayerStun += () =>
{
GD.Print("PLAYER STUNNED!!!");
GetNode<AnimationPlayer>("AnimationPlayer").Play("tighten");
};
}
}

View File

@ -0,0 +1,58 @@
[gd_scene load_steps=7 format=3 uid="uid://b1wsryv4bn0cn"]
[ext_resource type="Shader" path="res://Shaders/Grayscale.gdshader" id="2_dlm7y"]
[ext_resource type="Script" path="res://UI/PostProcessing/StunEffect.cs" id="3_h8rlj"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_uawkd"]
shader = ExtResource("2_dlm7y")
shader_parameter/grayscale_intensity = 0.0
[sub_resource type="Animation" id="Animation_5d4h1"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:material:shader_parameter/grayscale_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="Animation" id="Animation_txpv1"]
resource_name = "tighten"
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:material:shader_parameter/grayscale_intensity")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 1),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [1.0, 0.0]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_kyxik"]
_data = {
"RESET": SubResource("Animation_5d4h1"),
"tighten": SubResource("Animation_txpv1")
}
[node name="StunEffect" type="ColorRect"]
material = SubResource("ShaderMaterial_uawkd")
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("3_h8rlj")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_kyxik")
}

View File

@ -7,7 +7,7 @@
[sub_resource type="ShaderMaterial" id="ShaderMaterial_fmdjb"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_fmdjb"]
shader = ExtResource("1_nrekm") shader = ExtResource("1_nrekm")
shader_parameter/vignette_intensity = 0.1 shader_parameter/vignette_intensity = 0.1
shader_parameter/vignette_opacity = 0.1 shader_parameter/vignette_opacity = 0.2
shader_parameter/vignette_rgb = Color(0, 0, 0, 1) shader_parameter/vignette_rgb = Color(0, 0, 0, 1)
[sub_resource type="Animation" id="Animation_ph4f2"] [sub_resource type="Animation" id="Animation_ph4f2"]
@ -34,7 +34,7 @@ tracks/1/keys = {
"times": PackedFloat32Array(0), "times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1), "transitions": PackedFloat32Array(1),
"update": 0, "update": 0,
"values": [0.1] "values": [0.2]
} }
[sub_resource type="Animation" id="Animation_sqaf2"] [sub_resource type="Animation" id="Animation_sqaf2"]
@ -50,7 +50,7 @@ tracks/0/keys = {
"times": PackedFloat32Array(0, 0.2, 0.5), "times": PackedFloat32Array(0, 0.2, 0.5),
"transitions": PackedFloat32Array(1, 1, 1), "transitions": PackedFloat32Array(1, 1, 1),
"update": 0, "update": 0,
"values": [0.1, 0.1, 0.1] "values": [0.4, 0.1, 0.1]
} }
tracks/1/type = "value" tracks/1/type = "value"
tracks/1/imported = false tracks/1/imported = false
@ -62,7 +62,7 @@ tracks/1/keys = {
"times": PackedFloat32Array(0.2, 0.5), "times": PackedFloat32Array(0.2, 0.5),
"transitions": PackedFloat32Array(1, 0.25), "transitions": PackedFloat32Array(1, 0.25),
"update": 0, "update": 0,
"values": [1.0, 0.1] "values": [1.0, 0.2]
} }
[sub_resource type="AnimationLibrary" id="AnimationLibrary_s4mrn"] [sub_resource type="AnimationLibrary" id="AnimationLibrary_s4mrn"]
@ -71,7 +71,7 @@ _data = {
"tighten": SubResource("Animation_sqaf2") "tighten": SubResource("Animation_sqaf2")
} }
[node name="TextureRect" type="TextureRect"] [node name="Vignette" type="TextureRect"]
material = SubResource("ShaderMaterial_fmdjb") material = SubResource("ShaderMaterial_fmdjb")
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0

View File

@ -43,15 +43,12 @@ public partial class CharacterStats : Node
public void AddStaggerDamage(float damage) public void AddStaggerDamage(float damage)
{ {
StaggerDamage.Value += damage * StaggerCoefficient; StaggerDamage.Value += damage * StaggerCoefficient;
GD.Print(StaggerDamage.Value);
if (StaggerDamage.Value >= MaxStagger) if (StaggerDamage.Value >= MaxStagger)
{ {
GD.Print(StaggerDamage.Value + " >= " + MaxStagger);
EmitSignal(SignalName.Stagger, 1); EmitSignal(SignalName.Stagger, 1);
} }
else else
{ {
GD.Print(StaggerDamage.Value + " < " + MaxStagger);
_shouldDecayStagger = false; _shouldDecayStagger = false;
_staggerDecayTimer.Stop(); _staggerDecayTimer.Stop();
_staggerDecayTimer.Start(1); _staggerDecayTimer.Start(1);