mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-30 05:41:17 +00:00
Screen fader on level transition
This commit is contained in:
parent
687d3f7803
commit
959701be08
6 changed files with 80 additions and 8 deletions
|
|
@ -32,6 +32,7 @@ script = ExtResource("1_na4uq")
|
||||||
BossName = "Rumia"
|
BossName = "Rumia"
|
||||||
Phases = Array[Resource]([ExtResource("2_1rhf6"), ExtResource("3_j7lbl"), ExtResource("2_eyxw4"), ExtResource("2_p8j4e")])
|
Phases = Array[Resource]([ExtResource("2_1rhf6"), ExtResource("3_j7lbl"), ExtResource("2_eyxw4"), ExtResource("2_p8j4e")])
|
||||||
BossHudPrefab = ExtResource("4_ehp8q")
|
BossHudPrefab = ExtResource("4_ehp8q")
|
||||||
|
CameraOffset = Vector2(0, 32)
|
||||||
_bossPortraitTexture = ExtResource("4_at5iq")
|
_bossPortraitTexture = ExtResource("4_at5iq")
|
||||||
Health = 200.0
|
Health = 200.0
|
||||||
metadata/_edit_group_ = true
|
metadata/_edit_group_ = true
|
||||||
|
|
|
||||||
12
Scenes/HUD/SceenFader.tscn
Normal file
12
Scenes/HUD/SceenFader.tscn
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
[gd_scene format=3 uid="uid://cec8gr3m3q3d0"]
|
||||||
|
|
||||||
|
[node name="SceenFader" type="CanvasLayer"]
|
||||||
|
|
||||||
|
[node name="ColorRect" type="ColorRect" parent="."]
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
mouse_filter = 2
|
||||||
|
color = Color(0, 0, 0, 1)
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,11 +1,16 @@
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Cirno.Scripts.Resources;
|
using Cirno.Scripts.Resources;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
using GTweens.Builders;
|
||||||
|
using GTweensGodot.Extensions;
|
||||||
|
|
||||||
public partial class GlobalState : Node
|
public partial class GlobalState : Node
|
||||||
{
|
{
|
||||||
public static GlobalState Instance { get; private set; }
|
public static GlobalState Instance { get; private set; }
|
||||||
|
|
||||||
public Node CurrentScene { get; set; }
|
public Node CurrentScene { get; set; }
|
||||||
|
|
||||||
|
private ColorRect _fader { get; set; }
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
|
|
@ -16,6 +21,8 @@ public partial class GlobalState : Node
|
||||||
Viewport root = GetTree().Root;
|
Viewport root = GetTree().Root;
|
||||||
// Using a negative index counts from the end, so this gets the last child node of `root`.
|
// Using a negative index counts from the end, so this gets the last child node of `root`.
|
||||||
CurrentScene = root.GetChild(-1);
|
CurrentScene = root.GetChild(-1);
|
||||||
|
|
||||||
|
_fader = CreateFader();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GotoScene(string path)
|
public void GotoScene(string path)
|
||||||
|
|
@ -28,16 +35,26 @@ public partial class GlobalState : Node
|
||||||
|
|
||||||
// The solution is to defer the load to a later time, when
|
// The solution is to defer the load to a later time, when
|
||||||
// we can be sure that no code from the current scene is running:
|
// we can be sure that no code from the current scene is running:
|
||||||
|
|
||||||
CallDeferred(MethodName.DeferredGotoScene, path, new MapStartDataResource());
|
//CallDeferred(MethodName.DeferredGotoScene, path, new MapStartDataResource());
|
||||||
|
|
||||||
|
GoToScene(path, new MapStartDataResource());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GoToScene(string path, MapStartDataResource startData)
|
public void GoToScene(string path, MapStartDataResource startData)
|
||||||
{
|
{
|
||||||
// TODO: Implement startdata usage
|
GTweenSequenceBuilder.New()
|
||||||
CallDeferred(MethodName.DeferredGotoScene, path, startData);
|
//.Append(_fader.TweenModulateAlpha(0, 0f))
|
||||||
|
.Append(_fader.TweenModulateAlpha(1, 0.5f))
|
||||||
|
.AppendCallback(() =>
|
||||||
|
{
|
||||||
|
CallDeferred(MethodName.DeferredGotoScene, path, startData);
|
||||||
|
})
|
||||||
|
.Build()
|
||||||
|
.PlayUnpausable();
|
||||||
|
//CallDeferred(MethodName.DeferredGotoScene, path, startData);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeferredGotoScene(string path, MapStartDataResource startData = null)
|
private void DeferredGotoScene(string path, MapStartDataResource startData = null)
|
||||||
{
|
{
|
||||||
// It is now safe to remove the current scene.
|
// It is now safe to remove the current scene.
|
||||||
|
|
@ -63,10 +80,43 @@ public partial class GlobalState : Node
|
||||||
// Call deferred if it gives issues
|
// Call deferred if it gives issues
|
||||||
DeferredAddStartDataToGameManager(startData);
|
DeferredAddStartDataToGameManager(startData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FadeIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeferredAddStartDataToGameManager(MapStartDataResource resource)
|
private void DeferredAddStartDataToGameManager(MapStartDataResource resource)
|
||||||
{
|
{
|
||||||
GameManager.Instance.ApplyMapStartData(resource);
|
GameManager.Instance.ApplyMapStartData(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ColorRect CreateFader()
|
||||||
|
{
|
||||||
|
var canvas = new CanvasLayer();
|
||||||
|
canvas.ProcessMode = ProcessModeEnum.Always;
|
||||||
|
|
||||||
|
var rect = new ColorRect();
|
||||||
|
rect.SetAnchorsPreset(Control.LayoutPreset.FullRect);
|
||||||
|
rect.Color = new Color(Colors.Black, 1f);
|
||||||
|
rect.ProcessMode = ProcessModeEnum.Always;
|
||||||
|
|
||||||
|
rect.Modulate = new Color(0,0,0,0);
|
||||||
|
|
||||||
|
rect.MouseFilter = Control.MouseFilterEnum.Ignore;
|
||||||
|
|
||||||
|
canvas.CallDeferred("add_child", rect);
|
||||||
|
|
||||||
|
this.CallDeferred("add_child", canvas);
|
||||||
|
|
||||||
|
return rect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void FadeOut()
|
||||||
|
{
|
||||||
|
_fader.TweenModulateAlpha(1, 0.5f).PlayUnpausable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void FadeIn()
|
||||||
|
{
|
||||||
|
_fader.TweenModulateAlpha(0, 1f).PlayUnpausable();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
8
Scripts/UI/ScreenFader.cs
Normal file
8
Scripts/UI/ScreenFader.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Cirno.Scripts.UI;
|
||||||
|
|
||||||
|
public partial class ScreenFader : Control
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
1
Scripts/UI/ScreenFader.cs.uid
Normal file
1
Scripts/UI/ScreenFader.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://cq6jj3lsr7m0d
|
||||||
Loading…
Add table
Add a link
Reference in a new issue