scene transitions
parent
39c2d7c29d
commit
29b146558e
|
@ -24,4 +24,18 @@ public partial class EventBus : Node
|
|||
|
||||
[Signal]
|
||||
public delegate void DeregisteredBossEventHandler(Characters.Boss boss);
|
||||
|
||||
[Signal]
|
||||
public delegate void EnterTransitionEventHandler();
|
||||
|
||||
[Signal]
|
||||
public delegate void TransitionFinishedEventHandler();
|
||||
|
||||
[Signal]
|
||||
public delegate void ExitTransitionEventHandler();
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
ProcessMode = ProcessModeEnum.Always;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1833,6 +1833,7 @@ glow_enabled = true
|
|||
glow_hdr_threshold = 1.4
|
||||
|
||||
[node name="TileMap" type="TileMap" node_paths=PackedStringArray("Entities", "Areas", "Spawners", "Markers")]
|
||||
process_mode = 1
|
||||
y_sort_enabled = true
|
||||
texture_filter = 3
|
||||
tile_set = SubResource("TileSet_18c7j")
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
[ext_resource type="PackedScene" uid="uid://c271rdjhd1gfo" path="res://UI/Base.tscn" id="2_mm0qt"]
|
||||
|
||||
[node name="World" type="Node2D" node_paths=PackedStringArray("MusicPlayer", "DialogueBalloon")]
|
||||
process_mode = 3
|
||||
script = ExtResource("1_1k6ew")
|
||||
MusicPlayer = NodePath("MusicPlayer")
|
||||
DialogueBalloon = NodePath("CanvasLayer/SubViewportContainer/UIViewport/DialogBalloon")
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
shader_type canvas_item;
|
||||
|
||||
uniform float a: hint_range(0.0, 1.0, 0.1) = 0;
|
||||
uniform float b: hint_range(0.0, 1.0, 0.1) = 0;
|
||||
|
||||
void fragment() {
|
||||
if (UV.x < a) {
|
||||
if (UV.x > b) {
|
||||
COLOR.a = 1.0;
|
||||
} else {
|
||||
COLOR.a = 0.0;
|
||||
}
|
||||
} else {
|
||||
COLOR.a = 0.0;
|
||||
}
|
||||
}
|
|
@ -17,7 +17,10 @@ public partial class GlobalState : Node
|
|||
[Signal]
|
||||
public delegate void SummonBossEventHandler(string bossName);
|
||||
|
||||
public void Print(string str) => GD.Print(str);
|
||||
public override void _Ready()
|
||||
{
|
||||
ProcessMode = ProcessModeEnum.Always;
|
||||
}
|
||||
|
||||
public void ImportFromSave(Save save)
|
||||
{
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://c271rdjhd1gfo"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://c271rdjhd1gfo"]
|
||||
|
||||
[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="PackedScene" uid="uid://bxo553hblp6nf" path="res://UI/HealthBar.tscn" id="3_j1j6h"]
|
||||
[ext_resource type="PackedScene" uid="uid://01d24ij5av1y" path="res://UI/BossBar.tscn" id="4_igi28"]
|
||||
[ext_resource type="PackedScene" uid="uid://c77754nvmckn" path="res://UI/LocationDisplay.tscn" id="5_cr6vo"]
|
||||
[ext_resource type="PackedScene" uid="uid://d3q1yu3n7cqfj" path="res://UI/SceneTransition.tscn" id="6_j0nhv"]
|
||||
|
||||
[node name="BaseUI" type="CanvasLayer"]
|
||||
process_mode = 3
|
||||
|
||||
[node name="SubViewportContainer" type="SubViewportContainer" parent="."]
|
||||
anchors_preset = 15
|
||||
|
@ -73,3 +75,6 @@ visible = false
|
|||
layout_mode = 2
|
||||
|
||||
[node name="LocationDisplay" parent="SubViewportContainer/UIViewport/MainUILayer" instance=ExtResource("5_cr6vo")]
|
||||
|
||||
[node name="SceneTransition" parent="SubViewportContainer/UIViewport/MainUILayer" instance=ExtResource("6_j0nhv")]
|
||||
z_index = 1
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
using Godot;
|
||||
using SupaLidlGame.Extensions;
|
||||
|
||||
namespace SupaLidlGame.UI;
|
||||
|
||||
public partial class SceneTransition : Control
|
||||
{
|
||||
private AnimationPlayer _animPlayer;
|
||||
private Events.EventBus _bus;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_animPlayer = GetNode<AnimationPlayer>("AnimationPlayer");
|
||||
_bus = this.GetEventBus();
|
||||
_bus.EnterTransition += Enter;
|
||||
_bus.ExitTransition += Exit;
|
||||
}
|
||||
|
||||
public async void Enter()
|
||||
{
|
||||
_animPlayer.Play("enter");
|
||||
await ToSignal(_animPlayer, "animation_finished");
|
||||
_bus.EmitSignal(Events.EventBus.SignalName.TransitionFinished);
|
||||
}
|
||||
|
||||
public void Exit()
|
||||
{
|
||||
_animPlayer.Play("exit");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
[gd_scene load_steps=8 format=3 uid="uid://d3q1yu3n7cqfj"]
|
||||
|
||||
[ext_resource type="Shader" path="res://Shaders/WipeTransition.gdshader" id="1_1rft7"]
|
||||
[ext_resource type="Script" path="res://UI/SceneTransition.cs" id="1_mx0ay"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_vfeh4"]
|
||||
shader = ExtResource("1_1rft7")
|
||||
shader_parameter/a = 0.0
|
||||
shader_parameter/b = 0.0
|
||||
|
||||
[sub_resource type="Animation" id="Animation_4e8tt"]
|
||||
resource_name = "enter"
|
||||
length = 0.5
|
||||
step = 0.05
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("ColorRect:material:shader_parameter/a")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.25),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [0.0, 1.0]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("ColorRect:material:shader_parameter/b")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [0.0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_c026w"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("ColorRect:material:shader_parameter/a")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [0.0]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("ColorRect:material:shader_parameter/b")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [0.0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_uvf4a"]
|
||||
resource_name = "exit"
|
||||
length = 0.25
|
||||
step = 0.05
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("ColorRect:material:shader_parameter/a")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [1.0]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("ColorRect:material:shader_parameter/b")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.25),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [0.0, 1.0]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_51tf5"]
|
||||
_data = {
|
||||
"RESET": SubResource("Animation_c026w"),
|
||||
"enter": SubResource("Animation_4e8tt"),
|
||||
"exit": SubResource("Animation_uvf4a")
|
||||
}
|
||||
|
||||
[node name="SceneTransition" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_mx0ay")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
material = SubResource("ShaderMaterial_vfeh4")
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0, 0, 0, 1)
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_51tf5")
|
||||
}
|
|
@ -3,6 +3,7 @@ using SupaLidlGame.Characters;
|
|||
using SupaLidlGame.Extensions;
|
||||
using SupaLidlGame.Scenes;
|
||||
using SupaLidlGame.State.Global;
|
||||
using SupaLidlGame.Events;
|
||||
|
||||
namespace SupaLidlGame.Utils;
|
||||
|
||||
|
@ -58,7 +59,7 @@ public partial class World : Node
|
|||
|
||||
public State.Global.GlobalState GlobalState { get; set; }
|
||||
|
||||
public Events.EventBus EventBus { get; set; }
|
||||
public EventBus EventBus { get; set; }
|
||||
|
||||
private CacheStore<string, Map> _maps = new();
|
||||
|
||||
|
@ -95,9 +96,10 @@ public partial class World : Node
|
|||
UIController = this.GetMainUI();
|
||||
|
||||
EventBus = this.GetEventBus();
|
||||
EventBus.RequestMoveToArea += (Events.RequestAreaArgs args) =>
|
||||
EventBus.RequestMoveToArea += (RequestAreaArgs args) =>
|
||||
{
|
||||
CallDeferred(nameof(MoveToArea), args.Area, args.Connector);
|
||||
//CallDeferred(nameof(MoveToArea), args.Area, args.Connector);
|
||||
MoveToArea(args.Area, args.Connector);
|
||||
};
|
||||
EventBus.RegisteredBoss += RegisterBoss;
|
||||
EventBus.DeregisteredBoss += DeregisterBoss;
|
||||
|
@ -155,7 +157,7 @@ public partial class World : Node
|
|||
CurrentMap.Active = true;
|
||||
CurrentMap.Load();
|
||||
|
||||
EventBus.EmitSignal(Events.EventBus.SignalName.AreaChanged, map);
|
||||
EventBus.EmitSignal(EventBus.SignalName.AreaChanged, map);
|
||||
|
||||
if (CurrentPlayer is not null)
|
||||
{
|
||||
|
@ -220,7 +222,7 @@ public partial class World : Node
|
|||
{
|
||||
CurrentPlayer = _playerScene.Instantiate<Player>();
|
||||
|
||||
CurrentPlayer.Death += (Events.HurtArgs args) =>
|
||||
CurrentPlayer.Death += (HurtArgs args) =>
|
||||
{
|
||||
// TODO: respawn the player at the last campfire.
|
||||
GetTree().CreateTimer(3).Timeout += () =>
|
||||
|
@ -230,15 +232,6 @@ public partial class World : Node
|
|||
GlobalState.Stats.DeathCount++;
|
||||
};
|
||||
|
||||
/*
|
||||
CurrentPlayer.Hurt += (Events.HurtArgs args) =>
|
||||
{
|
||||
// TODO: move this to UI controller and add a setup method
|
||||
var bar = UIController.GetNode<UI.HealthBar>("Top/Margin/HealthBar");
|
||||
bar.ProgressBar.Value = args.NewHealth;
|
||||
};
|
||||
*/
|
||||
|
||||
return CurrentPlayer;
|
||||
}
|
||||
|
||||
|
@ -253,16 +246,23 @@ public partial class World : Node
|
|||
CurrentPlayer.GlobalPosition = marker?.GlobalPosition ?? Vector2.Zero;
|
||||
}
|
||||
|
||||
public void MoveToArea(string path, string connector)
|
||||
public async void MoveToArea(string path, string connector)
|
||||
{
|
||||
_currentConnector = connector;
|
||||
GD.Print($"Moving to area {path} - {connector}");
|
||||
|
||||
EventBus.EmitSignal(EventBus.SignalName.EnterTransition);
|
||||
GetTree().Paused = true;
|
||||
await ToSignal(EventBus, EventBus.SignalName.TransitionFinished);
|
||||
|
||||
if (path != CurrentMap.SceneFilePath)
|
||||
{
|
||||
LoadScene(path);
|
||||
//_currentMapResourcePath = path;
|
||||
}
|
||||
|
||||
EventBus.EmitSignal(EventBus.SignalName.ExitTransition);
|
||||
GetTree().Paused = false;
|
||||
|
||||
// after finished loading, move our player to the connector
|
||||
MovePlayerToConnector(connector);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue