In progress gameplay loop changes
This commit is contained in:
@@ -98,9 +98,8 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<ISaveChunk<Play
|
||||
private DamageCalculator _damageCalculator;
|
||||
|
||||
#region Initialization
|
||||
public void Initialize()
|
||||
public void InitializePlayerState()
|
||||
{
|
||||
AnimationPlayer.AnimationFinished += OnAnimationFinished;
|
||||
_expToNextLevel = new Dictionary<int, int>
|
||||
{
|
||||
{ 2, 12 },
|
||||
@@ -112,15 +111,7 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<ISaveChunk<Play
|
||||
{ 8, 609 }
|
||||
};
|
||||
_damageCalculator = new DamageCalculator();
|
||||
}
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
var container = new SimpleInjector.Container();
|
||||
container.Register<IPlayerLogic, PlayerLogic>(Lifestyle.Singleton);
|
||||
//container.Verify();
|
||||
|
||||
Settings = new PlayerLogic.Settings() { RotationSpeed = PlayerStatResource.RotationSpeed, MoveSpeed = PlayerStatResource.MoveSpeed, Acceleration = PlayerStatResource.Acceleration };
|
||||
Stats = new PlayerStatController();
|
||||
Stats.Init(
|
||||
new PlayerStats
|
||||
@@ -143,12 +134,6 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<ISaveChunk<Play
|
||||
|
||||
Inventory = new Inventory();
|
||||
|
||||
PlayerLogic = container.GetInstance<IPlayerLogic>();
|
||||
PlayerLogic.Set(this as IPlayer);
|
||||
PlayerLogic.Set(Settings);
|
||||
PlayerLogic.Set(Stats);
|
||||
PlayerLogic.Set(_gameRepo);
|
||||
|
||||
var defaultWeapon = new Weapon
|
||||
{
|
||||
Stats = _defaultWeapon
|
||||
@@ -160,19 +145,35 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<ISaveChunk<Play
|
||||
Inventory.TryAdd(defaultWeapon);
|
||||
Inventory.TryAdd(defaultArmor);
|
||||
|
||||
Equip(defaultWeapon);
|
||||
Equip(defaultArmor);
|
||||
|
||||
EquippedWeapon.Sync += EquippedWeapon_Sync;
|
||||
EquippedArmor.Sync += EquippedArmor_Sync;
|
||||
EquippedAccessory.Sync += EquippedAccessory_Sync;
|
||||
Stats.CurrentHP.Sync += CurrentHP_Sync;
|
||||
Stats.CurrentExp.Sync += CurrentEXP_Sync;
|
||||
|
||||
Equip(defaultWeapon);
|
||||
Equip(defaultArmor);
|
||||
|
||||
HealthTimer.WaitTime = _healthTimerWaitTime;
|
||||
HealthTimer.Timeout += OnHealthTimerTimeout;
|
||||
Hitbox.AreaEntered += Hitbox_AreaEntered;
|
||||
CollisionDetector.AreaEntered += CollisionDetector_AreaEntered;
|
||||
AnimationPlayer.AnimationFinished += OnAnimationFinished;
|
||||
}
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
var container = new SimpleInjector.Container();
|
||||
container.Register<IPlayerLogic, PlayerLogic>(Lifestyle.Singleton);
|
||||
//container.Verify();
|
||||
|
||||
Settings = new PlayerLogic.Settings() { RotationSpeed = PlayerStatResource.RotationSpeed, MoveSpeed = PlayerStatResource.MoveSpeed, Acceleration = PlayerStatResource.Acceleration };
|
||||
|
||||
PlayerLogic = container.GetInstance<IPlayerLogic>();
|
||||
PlayerLogic.Set(this as IPlayer);
|
||||
PlayerLogic.Set(Settings);
|
||||
PlayerLogic.Set(Stats);
|
||||
PlayerLogic.Set(_gameRepo);
|
||||
}
|
||||
|
||||
public void OnResolved()
|
||||
@@ -363,7 +364,21 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<ISaveChunk<Play
|
||||
Stats.SetCurrentExp(newCurrentExp);
|
||||
}
|
||||
|
||||
public void Die() => PlayerLogic.Input(new PlayerLogic.Input.Die());
|
||||
public void Die()
|
||||
{
|
||||
EquippedWeapon.Sync -= EquippedWeapon_Sync;
|
||||
EquippedArmor.Sync -= EquippedArmor_Sync;
|
||||
EquippedAccessory.Sync -= EquippedAccessory_Sync;
|
||||
Stats.CurrentHP.Sync -= CurrentHP_Sync;
|
||||
Stats.CurrentExp.Sync -= CurrentEXP_Sync;
|
||||
|
||||
HealthTimer.WaitTime = _healthTimerWaitTime;
|
||||
HealthTimer.Timeout -= OnHealthTimerTimeout;
|
||||
Hitbox.AreaEntered -= Hitbox_AreaEntered;
|
||||
CollisionDetector.AreaEntered -= CollisionDetector_AreaEntered;
|
||||
AnimationPlayer.AnimationFinished -= OnAnimationFinished;
|
||||
PlayerLogic.Input(new PlayerLogic.Input.Die());
|
||||
}
|
||||
|
||||
public override void _UnhandledInput(InputEvent @event)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user