Big refactor in place: Organize nodes in line with dependency injection expectations, use state machine flow more
This commit is contained in:
@@ -7,7 +7,7 @@ using Godot;
|
||||
|
||||
namespace GameJamDungeon
|
||||
{
|
||||
public interface IPlayer : ICharacterBody3D
|
||||
public interface IPlayer : ICharacterBody3D, IKillable
|
||||
{
|
||||
PlayerStatInfo PlayerStatInfo { get; }
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace GameJamDungeon
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
Settings = new PlayerLogic.Settings() { RotationSpeed = RotationSpeed, MoveSpeed = MoveSpeed };
|
||||
Settings = new PlayerLogic.Settings() { RotationSpeed = RotationSpeed, MoveSpeed = MoveSpeed, Acceleration = Acceleration };
|
||||
|
||||
PlayerLogic = new PlayerLogic();
|
||||
PlayerLogic.Set(this as IPlayer);
|
||||
@@ -92,14 +92,6 @@ namespace GameJamDungeon
|
||||
PlayerLogic.Set(AppRepo);
|
||||
PlayerLogic.Set(GameRepo);
|
||||
PlayerLogic.Set(PlayerData);
|
||||
|
||||
GameRepo.SetPlayerGlobalPosition(GlobalPosition);
|
||||
GameRepo.PlayerGlobalPosition.Sync += OnPlayerPositionUpdated;
|
||||
|
||||
GameRepo.SetPlayerStatInfo(PlayerStatInfo);
|
||||
|
||||
HealthTimer.Timeout += OnHealthTimerTimeout;
|
||||
CollisionDetector.AreaEntered += OnEnemyHitBoxEntered;
|
||||
}
|
||||
|
||||
public void OnResolved()
|
||||
@@ -127,6 +119,11 @@ namespace GameJamDungeon
|
||||
PlayerLogic.Start();
|
||||
|
||||
SwordSlashAnimation.Position = GetViewport().GetVisibleRect().Size / 2;
|
||||
GlobalPosition = GameRepo.PlayerGlobalPosition.Value;
|
||||
GameRepo.SetPlayerStatInfo(PlayerStatInfo);
|
||||
|
||||
HealthTimer.Timeout += OnHealthTimerTimeout;
|
||||
CollisionDetector.AreaEntered += OnEnemyHitBoxEntered;
|
||||
}
|
||||
|
||||
public void OnReady()
|
||||
@@ -227,6 +224,8 @@ namespace GameJamDungeon
|
||||
AnimationPlayer.AnimationFinished -= OnAnimationFinished;
|
||||
}
|
||||
|
||||
public void Kill() => PlayerLogic.Input(new PlayerLogic.Input.Killed());
|
||||
|
||||
private void OnHPChanged(double newHP)
|
||||
{
|
||||
HPNumber.Text = $"{Mathf.RoundToInt(newHP)}/{PlayerStatInfo.MaximumHP}";
|
||||
|
||||
Reference in New Issue
Block a user