mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 22:15:55 +00:00
Teleport animation
This commit is contained in:
parent
2ce91362b7
commit
4a8ac7a495
8 changed files with 269 additions and 5 deletions
|
|
@ -7,6 +7,7 @@ using Cirno.Scripts.Components;
|
|||
using Cirno.Scripts.Components.Actors;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Godot.Collections;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public partial class PlayerMovement : CharacterBody2D, IDestructible
|
||||
{
|
||||
|
|
@ -49,6 +50,8 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
[Export] public float MaxHealth = 32f;
|
||||
[Export] public float MaxShield = 32f;
|
||||
|
||||
[Export] public Shader BlinkShader {get;set;}
|
||||
|
||||
[ExportGroup("Action Names")]
|
||||
[Export] private string _shootActionName = "shoot";
|
||||
[ExportGroup("Action Names")]
|
||||
|
|
@ -182,6 +185,8 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
}
|
||||
|
||||
_lastCheckPointPosition = GlobalPosition;
|
||||
|
||||
_ = UnTeleport();
|
||||
}
|
||||
|
||||
private void GameManagerOnGameStateChange(GameState state)
|
||||
|
|
@ -483,12 +488,62 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
}
|
||||
}
|
||||
|
||||
// Blink
|
||||
//_animatedSprite
|
||||
if (BlinkShader != null)
|
||||
{
|
||||
_ = Blink();
|
||||
}
|
||||
|
||||
if (!(CurrentHealth <= 0)) return;
|
||||
_isDestroyed = true;
|
||||
Explode();
|
||||
}
|
||||
|
||||
|
||||
private async Task Blink()
|
||||
{
|
||||
((ShaderMaterial)_animatedSprite.Material).Shader = BlinkShader;
|
||||
|
||||
Tween tween = GetTree().CreateTween();
|
||||
tween.TweenMethod(Callable.From((float value) => SetShaderBlinkIntensity(value)), 1f, 0, 0.5);
|
||||
await ToSignal(tween, "finished");
|
||||
}
|
||||
|
||||
public async Task Teleport()
|
||||
{
|
||||
((ShaderMaterial)_animatedSprite.Material).Shader = BlinkShader;
|
||||
|
||||
Tween tween = GetTree().CreateTween();
|
||||
tween.TweenMethod(Callable.From((float value) => SetShaderScanlineDensity(value)), 0f, 50f, 0.5);
|
||||
tween.Parallel().TweenMethod(Callable.From((float value) => SetShaderTeleportProgress(value)), 0f, 1f, 0.5);
|
||||
await ToSignal(tween, "finished");
|
||||
}
|
||||
|
||||
public async Task UnTeleport()
|
||||
{
|
||||
((ShaderMaterial)_animatedSprite.Material).Shader = BlinkShader;
|
||||
|
||||
Tween tween = GetTree().CreateTween();
|
||||
tween.TweenMethod(Callable.From((float value) => SetShaderTeleportProgress(value)), 1f, 0f, 0.5);
|
||||
tween.Parallel().TweenMethod(Callable.From((float value) => SetShaderScanlineDensity(value)), 50f, 0f, 0.5);
|
||||
await ToSignal(tween, "finished");
|
||||
}
|
||||
|
||||
private void SetShaderTeleportProgress(float value)
|
||||
{
|
||||
((ShaderMaterial)_animatedSprite.Material).SetShaderParameter("teleport_progress", value);
|
||||
}
|
||||
|
||||
private void SetShaderScanlineDensity(float value)
|
||||
{
|
||||
((ShaderMaterial)_animatedSprite.Material).SetShaderParameter("scanline_density", value);
|
||||
}
|
||||
|
||||
private void SetShaderBlinkIntensity(float newValue)
|
||||
{
|
||||
((ShaderMaterial)_animatedSprite.Material).SetShaderParameter("blink_intensity", newValue);
|
||||
}
|
||||
|
||||
|
||||
public bool IsDestroyed()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue