Refactor Player class to use components, also use components in Enemy class types and fiddle with boss structure
This commit is contained in:
@@ -7,12 +7,6 @@ namespace Zennysoft.Game.Ma;
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class EnemyModelView2D : EnemyModelView, IEnemyModelView
|
||||
{
|
||||
private readonly string _idleName = "Idle";
|
||||
private readonly string _walkingName = "Walking";
|
||||
private readonly string _primaryAttackName = "Primary Attack";
|
||||
private readonly string _secondaryAttackName = "Secondary Attack";
|
||||
private readonly string _activateName = "Activate";
|
||||
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Export] public EnemyLoreInfo EnemyLoreInfo { get; set; } = default!;
|
||||
@@ -23,8 +17,6 @@ public partial class EnemyModelView2D : EnemyModelView, IEnemyModelView
|
||||
|
||||
[Node] public AnimationPlayer AnimationPlayer { get; set; } = default!;
|
||||
|
||||
[Node] public AnimationTree AnimationTree { get; set; } = default!;
|
||||
|
||||
[ExportGroup("Enemy Model Properties")]
|
||||
[Export(PropertyHint.Range, "0.0, 1.0")]
|
||||
private float _upperThreshold { get; set; } = 0.5f;
|
||||
@@ -33,40 +25,24 @@ public partial class EnemyModelView2D : EnemyModelView, IEnemyModelView
|
||||
|
||||
EnemyDirection _enemyDirection { get; set; } = EnemyDirection.Forward;
|
||||
|
||||
private AnimationNodeStateMachinePlayback _stateMachine;
|
||||
|
||||
public void OnReady()
|
||||
public new void OnReady()
|
||||
{
|
||||
_stateMachine = (AnimationNodeStateMachinePlayback)AnimationTree.Get("parameters/playback");
|
||||
Hitbox.BodyEntered += Hitbox_BodyEntered;
|
||||
Hitbox.AreaEntered += Hitbox_AreaEntered;
|
||||
base.OnReady();
|
||||
}
|
||||
|
||||
private void Hitbox_BodyEntered(Node3D body) => EmitSignal(SignalName.HitPlayer);
|
||||
private void Hitbox_AreaEntered(Area3D area) => OnPlayerHit();
|
||||
|
||||
public void SetCurrentDirection(Basis enemyBasis, Vector3 cameraDirection) => _enemyDirection = GetEnemyDirection(enemyBasis, cameraDirection, _upperThreshold, _lowerThreshold);
|
||||
|
||||
public void PlayPrimaryAttackAnimation() => _stateMachine.Travel(_primaryAttackName);
|
||||
|
||||
public void PlaySecondaryAttackAnimation() => _stateMachine.Travel(_secondaryAttackName);
|
||||
|
||||
public void PlayPrimarySkillAnimation() => _stateMachine.Travel("Primary Skill");
|
||||
|
||||
public void PlayIdleAnimation() => _stateMachine.Travel(_idleName);
|
||||
|
||||
public void PlayWalkAnimation() => _stateMachine.Travel(_walkingName);
|
||||
|
||||
public void PlayActivateAnimation()
|
||||
{
|
||||
}
|
||||
|
||||
public void PlayHitAnimation()
|
||||
public override void PlayHitAnimation()
|
||||
{
|
||||
LoadShader("res://src/vfx/shaders/DamageHit.gdshader");
|
||||
var tweener = GetTree().CreateTween();
|
||||
tweener.TweenMethod(Callable.From((float x) => SetShaderValue(x)), 0.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
public void PlayDeathAnimation()
|
||||
public override void PlayDeathAnimation()
|
||||
{
|
||||
LoadShader("res://src/vfx/shaders/PixelMelt.gdshader");
|
||||
var tweener = GetTree().CreateTween();
|
||||
@@ -159,12 +135,4 @@ public partial class EnemyModelView2D : EnemyModelView, IEnemyModelView
|
||||
{
|
||||
_enemyDirection = EnemyDirection.Backward;
|
||||
}
|
||||
|
||||
private enum EnemyDirection
|
||||
{
|
||||
Left,
|
||||
Right,
|
||||
Forward,
|
||||
Backward
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user