mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-12 02:45:54 +00:00
Changed player to new one
This commit is contained in:
parent
60ab375572
commit
1c1436a539
27 changed files with 323 additions and 87 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Threading.Tasks;
|
||||
using Cirno.Scripts.Components.FSM;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Activables;
|
||||
|
|
@ -10,16 +11,19 @@ public partial class LevelTeleporter : Teleporter
|
|||
[Export]
|
||||
public string LevelPath {get; private set;}
|
||||
|
||||
protected override async Task Teleport(PlayerMovement player)
|
||||
protected override async Task Teleport(PlayerStateMachine player)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(LevelPath)) return;
|
||||
player.RequestMovementDisable(true);
|
||||
//player.RequestMovementDisable(true);
|
||||
player.SetState((int)PlayerState.Cutscene);
|
||||
|
||||
await TweenPlayer(player);
|
||||
|
||||
_particles.Emitting = true;
|
||||
|
||||
await player.Teleport();
|
||||
//await player.Teleport();
|
||||
player.SetState((int)PlayerState.UnTeleporting);
|
||||
await Task.Delay((int)(0.6f * 1000));
|
||||
|
||||
await Task.Delay((int)(TeleportAnimationLength * 1000));
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@ public partial class PlayerMover : ChainActivable
|
|||
|
||||
private async Task MovePlayer()
|
||||
{
|
||||
_gameManager.Player.RequestMovementDisable(true);
|
||||
//_gameManager.Player.RequestMovementDisable(true);
|
||||
_gameManager.Player.SetState((int)PlayerState.Cutscene);
|
||||
|
||||
Tween tween = GetTree().CreateTween();
|
||||
tween.SetEase(EaseType);
|
||||
|
|
@ -46,7 +47,8 @@ public partial class PlayerMover : ChainActivable
|
|||
// Wait for the tween to finish
|
||||
await ToSignal(tween, "finished");
|
||||
|
||||
_gameManager.Player.RequestMovementDisable(false);
|
||||
//_gameManager.Player.RequestMovementDisable(false);
|
||||
_gameManager.Player.SetState((int)PlayerState.Cutscene);
|
||||
|
||||
ActivateTargets();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Cirno.Scripts.Components.FSM;
|
||||
using Godot;
|
||||
using GTweensGodot.Extensions;
|
||||
|
||||
|
|
@ -115,7 +116,7 @@ private AudioStreamPlayer2D _teleportEndSound;
|
|||
|
||||
private void _on_body_entered(CharacterBody2D area)
|
||||
{
|
||||
if (area is not PlayerMovement player) return;
|
||||
if (area is not PlayerStateMachine player) return;
|
||||
|
||||
if (!IsPrimed)
|
||||
{
|
||||
|
|
@ -132,10 +133,11 @@ private AudioStreamPlayer2D _teleportEndSound;
|
|||
_ = Teleport(player);
|
||||
}
|
||||
|
||||
protected virtual async Task Teleport(PlayerMovement player)
|
||||
protected virtual async Task Teleport(PlayerStateMachine player)
|
||||
{
|
||||
if (Target is null) return;
|
||||
player.RequestMovementDisable(true);
|
||||
//player.RequestMovementDisable(true);
|
||||
player.SetState((int)PlayerState.Cutscene);
|
||||
|
||||
await TweenPlayer(player);
|
||||
|
||||
|
|
@ -144,16 +146,22 @@ private AudioStreamPlayer2D _teleportEndSound;
|
|||
//_particles.Emitting = true;
|
||||
FireParticles();
|
||||
|
||||
await player.Teleport();
|
||||
//await player.Teleport();
|
||||
player.SetState((int)PlayerState.Teleporting);
|
||||
await Task.Delay((int)(0.6f * 1000));
|
||||
|
||||
await Task.Delay((int)(TeleportAnimationLength * 1000));
|
||||
|
||||
Target.PrepareForReceiving();
|
||||
player.GlobalPosition = Target.GlobalPosition + TeleportOffset;
|
||||
Target.PlayTeleportEndSound();
|
||||
await player.UnTeleport();
|
||||
//await player.UnTeleport();
|
||||
|
||||
player.RequestMovementDisable(false);
|
||||
player.SetState((int)PlayerState.UnTeleporting);
|
||||
await Task.Delay((int)(0.6f * 1000));
|
||||
|
||||
//player.RequestMovementDisable(false);
|
||||
player.SetState((int)PlayerState.Active);
|
||||
}
|
||||
|
||||
public void PlayTeleportStartSound()
|
||||
|
|
@ -166,7 +174,7 @@ private AudioStreamPlayer2D _teleportEndSound;
|
|||
_teleportEndSound?.Play();
|
||||
}
|
||||
|
||||
protected async Task TweenPlayer(PlayerMovement player)
|
||||
protected async Task TweenPlayer(PlayerStateMachine player)
|
||||
{
|
||||
await player.TweenGlobalPosition(GlobalPosition + new Vector2(0, -4f), TeleportAnimationLength).PlayAsync(CancellationToken.None);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue