Changed player to new one

This commit is contained in:
Marco 2025-03-02 11:58:30 +01:00
commit 1c1436a539
27 changed files with 323 additions and 87 deletions

View file

@ -77,7 +77,8 @@ public partial class EnemyPossessionMovement : ActorFreeMovement
public void AssumeControl()
{
GameManager.Instance.CameraTargetObject(_parent);
GameManager.Instance.Player.RequestMovementDisable(true);
//GameManager.Instance.Player.RequestMovementDisable(true);
GameManager.Instance.Player.SetState((int)PlayerState.Controlling);
_previousAiState = _actorAi.Ai;
_actorAi.Ai = AiState.Controlled;
@ -92,7 +93,8 @@ public partial class EnemyPossessionMovement : ActorFreeMovement
_actorAi.Ai = _previousAiState;
GameManager.Instance.CameraTargetPlayer();
GameManager.Instance.Player.RequestMovementDisable(false);
//GameManager.Instance.Player.RequestMovementDisable(false);
GameManager.Instance.Player.SetState((int)PlayerState.Active);
DamageReceiver.BulletGroup = BulletOwner.Enemy;

View file

@ -6,33 +6,33 @@ public partial class KeyboardInputProvider : InputProvider
{
[ExportCategory("Movement")]
[Export]
public string LeftAxisName { get; private set; } = "left";
public StringName LeftAxisName { get; private set; } = "left";
[Export]
public string RightAxisName { get; private set; } = "right";
public StringName RightAxisName { get; private set; } = "right";
[Export]
public string UpAxisName { get; private set; } = "up";
public StringName UpAxisName { get; private set; } = "up";
[Export]
public string DownAxisName { get; private set; } = "down";
public StringName DownAxisName { get; private set; } = "down";
[ExportCategory("Aiming")]
[Export]
public string LeftAimName { get; private set; } = "aim_left";
public StringName LeftAimName { get; private set; } = "aim_left";
[Export]
public string RightAimName { get; private set; } = "aim_right";
public StringName RightAimName { get; private set; } = "aim_right";
[Export]
public string UpAimName { get; private set; } = "aim_up";
public StringName UpAimName { get; private set; } = "aim_up";
[Export]
public string DownAimName { get; private set; } = "aim_down";
public StringName DownAimName { get; private set; } = "aim_down";
[ExportCategory("Action Names")]
[Export] private string _shootActionName = "shoot";
[Export] private string _useActionName = "Use";
[Export] private string _scanActionName = "scan";
[Export] private string _strafeActionName = "strafe";
[Export] private string _nextWeaponActionName = "next_weapon";
[Export] private string _previousWeaponActionName = "previous_weapon";
[Export] private string _inventoryActionName = "inventory";
[Export] private string _pauseActionName = "pause";
[Export] private StringName _shootActionName = "shoot";
[Export] private StringName _useActionName = "Use";
[Export] private StringName _scanActionName = "scan";
[Export] private StringName _strafeActionName = "strafe";
[Export] private StringName _nextWeaponActionName = "next_weapon";
[Export] private StringName _previousWeaponActionName = "previous_weapon";
[Export] private StringName _inventoryActionName = "inventory";
[Export] private StringName _pauseActionName = "pause";
public override Vector2 GetMovementInput()
{

View file

@ -16,21 +16,33 @@ public partial class PlayerAnimationProvider : Node2D
[ExportCategory("Animation Names")]
[Export]
public string WalkRightAnimationName {get; private set;} = "walk_right";
public StringName WalkRightAnimationName {get; private set;} = "walk_right";
[Export]
public string WalkLeftAnimationName {get; private set;} = "walk_left";
public StringName WalkLeftAnimationName {get; private set;} = "walk_left";
[Export]
public string WalkDownAnimationName {get; private set;} = "walk_down";
public StringName WalkDownAnimationName {get; private set;} = "walk_down";
[Export]
public string WalkUpAnimationName {get; private set;} = "walk_up";
public StringName WalkUpAnimationName {get; private set;} = "walk_up";
[ExportCategory("Shaders")]
[Export] public ShaderMaterial BlinkMaterial {get; private set;}
[Export] public StringName BlinkShaderPropertyName { get; private set; } = new StringName("blink_intensity");
[Export] public StringName BlinkShaderPropertyName { get; private set; } = new("blink_intensity");
[Export] public StringName TeleportProgressPropertyName { get; private set; } = new("teleport_progress");
[Export] public StringName ScanlineDensityPropertyName { get; private set; } = new("scanline_density");
private GTween _blinkTween;
public void ShowSprite()
{
_animatedSprite.Show();
}
public void HideSprite()
{
_animatedSprite.Hide();
}
public void SetAnimation(Vector2 velocity)
{
@ -78,6 +90,38 @@ public partial class PlayerAnimationProvider : Node2D
_blinkTween.Play();
}
public void PlayTeleportAnimation()
{
if (BlinkMaterial == null) return;
_animatedSprite.Material = BlinkMaterial;
var material = ((ShaderMaterial)_animatedSprite.Material);
_blinkTween?.Kill();
_blinkTween = GTweenSequenceBuilder.New()
.Append(material.TweenPropertyFloat(TeleportProgressPropertyName, 0f, 0f))
.Append(material.TweenPropertyFloat(ScanlineDensityPropertyName, 0f, 0f))
.Append(material.TweenPropertyFloat(ScanlineDensityPropertyName,50f,0.5f))
.Join(material.TweenPropertyFloat(TeleportProgressPropertyName, 1f,0.5f))
.Build();
_blinkTween.Play();
}
public void PlayUnteleportAnimation()
{
if (BlinkMaterial == null) return;
_animatedSprite.Material = BlinkMaterial;
var material = ((ShaderMaterial)_animatedSprite.Material);
_blinkTween?.Kill();
_blinkTween = GTweenSequenceBuilder.New()
.Append(material.TweenPropertyFloat(TeleportProgressPropertyName, 1f, 0f))
.Append(material.TweenPropertyFloat(ScanlineDensityPropertyName, 50f, 0f))
.Append(material.TweenPropertyFloat(ScanlineDensityPropertyName,0f,0.5f))
.Join(material.TweenPropertyFloat(TeleportProgressPropertyName, 0f,0.5f))
.Build();
_blinkTween.Play();
}
private void SetShaderTeleportProgress(float value)
{
((ShaderMaterial)_animatedSprite.Material).SetShaderParameter("teleport_progress", value);
@ -103,4 +147,6 @@ public partial class PlayerAnimationProvider : Node2D
{
_shieldParticles.Emitting = true;
}
}

View file

@ -8,9 +8,21 @@ public partial class PlayerHitboxSpriteProvider : Node2D
public AnimatedSprite2D Hitbox { get; private set; }
[Export]
public AnimatedSprite2D Circle { get; private set; }
[Export]
public AnimatedSprite2D Square { get; private set; }
[Export] public float RotationSpeed { get; private set; } = 10f;
public override void _Process(double delta)
{
if (!Visible) return;
Circle.Rotate((float)(RotationSpeed * delta));
Square.Rotate((float)(-RotationSpeed * delta));
}
public void SetVisibility(bool isVisible)
{
if (isVisible == Visible) return;
if (isVisible)
{
Show();

View file

@ -78,7 +78,7 @@ public partial class Active : PlayerFSMState
// enable sprite
// enable crosshair
_crosshairProvider.Show();
_animationProvider.ShowSprite();
_damageReceiver.Enabled = true;
_activationProvider.Enabled = true;
}

View file

@ -14,12 +14,12 @@ public partial class Cutscene : PlayerFSMState
public override void ExitState()
{
_animationProvider.SetAnimation(Vector2.Zero);
}
public override void ProcessState(double delta)
{
_animationProvider.SetAnimation(_stateMachine.Velocity);
}
public override void PhysicsProcessState(double delta)

View file

@ -9,7 +9,7 @@ public partial class Teleporting : PlayerFSMState
public override void EnterState()
{
_animationProvider.PlayTeleportAnimation();
}
public override void ExitState()

View file

@ -0,0 +1,29 @@
using Godot;
namespace Cirno.Scripts.Components.FSM.Player;
public partial class UnTeleporting : PlayerFSMState
{
[Export]
private PlayerAnimationProvider _animationProvider;
public override void EnterState()
{
_animationProvider.PlayUnteleportAnimation();
}
public override void ExitState()
{
}
public override void ProcessState(double delta)
{
}
public override void PhysicsProcessState(double delta)
{
}
}

View file

@ -0,0 +1 @@
uid://br2ev58gwuvu4