Refactor stats
This commit is contained in:
@@ -11,7 +11,6 @@ using Zennysoft.Game.Abstractions;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Zennysoft.Game.Implementation.Components;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class Game : Node3D, IGame
|
||||
@@ -95,7 +94,8 @@ public partial class Game : Node3D, IGame
|
||||
|
||||
PlayerData = new PlayerData()
|
||||
{
|
||||
Inventory = _player.Inventory
|
||||
Inventory = (Inventory)_player.Inventory,
|
||||
HealthComponent = (HealthComponent)_player.HealthComponent,
|
||||
},
|
||||
MapData = new MapData()
|
||||
{
|
||||
@@ -119,7 +119,7 @@ public partial class Game : Node3D, IGame
|
||||
|
||||
public void OnResolved()
|
||||
{
|
||||
var saveFileManager = _container.GetInstance<IMaSaveFileManager<GameData>>();
|
||||
var saveFileManager = _container.GetInstance<IMaSaveFileManager>();
|
||||
SaveFile = new SaveFile<GameData>(
|
||||
root: GameChunk,
|
||||
onSave: saveFileManager.Save,
|
||||
@@ -127,7 +127,7 @@ public partial class Game : Node3D, IGame
|
||||
{
|
||||
try
|
||||
{
|
||||
var gameData = await saveFileManager.Load();
|
||||
var gameData = await saveFileManager.Load() as GameData;
|
||||
return gameData;
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
@@ -138,7 +138,6 @@ public partial class Game : Node3D, IGame
|
||||
return null;
|
||||
}
|
||||
);
|
||||
|
||||
GameBinding = GameState.Bind();
|
||||
GameBinding
|
||||
.Handle((in GameState.Output.InitializeGame _) =>
|
||||
@@ -200,22 +199,22 @@ public partial class Game : Node3D, IGame
|
||||
.Handle((in GameState.Output.LoadNextFloor _) =>
|
||||
{
|
||||
FloorClearMenu.FadeOut();
|
||||
_map.LoadFloor();
|
||||
if (_player.EquippedWeapon.Value.ItemTag == ItemTag.BreaksOnChange)
|
||||
Task.Run(() => _map.LoadFloor());
|
||||
if (_player.EquipmentComponent.EquippedWeapon.Value.ItemTag == ItemTag.BreaksOnChange)
|
||||
{
|
||||
var itemToDestroy = _player.EquippedWeapon.Value;
|
||||
var itemToDestroy = _player.EquipmentComponent.EquippedWeapon.Value;
|
||||
_player.Unequip(itemToDestroy);
|
||||
_player.Inventory.Remove(itemToDestroy);
|
||||
}
|
||||
if (_player.EquippedArmor.Value.ItemTag == ItemTag.BreaksOnChange)
|
||||
if (_player.EquipmentComponent.EquippedArmor.Value.ItemTag == ItemTag.BreaksOnChange)
|
||||
{
|
||||
var itemToDestroy = _player.EquippedArmor.Value;
|
||||
var itemToDestroy = _player.EquipmentComponent.EquippedArmor.Value;
|
||||
_player.Unequip(itemToDestroy);
|
||||
_player.Inventory.Remove(itemToDestroy);
|
||||
}
|
||||
if (_player.EquippedAccessory.Value.ItemTag == ItemTag.BreaksOnChange)
|
||||
if (_player.EquipmentComponent.EquippedAccessory.Value.ItemTag == ItemTag.BreaksOnChange)
|
||||
{
|
||||
var itemToDestroy = _player.EquippedAccessory.Value;
|
||||
var itemToDestroy = _player.EquipmentComponent.EquippedAccessory.Value;
|
||||
_player.Unequip(itemToDestroy);
|
||||
_player.Inventory.Remove(itemToDestroy);
|
||||
}
|
||||
@@ -245,6 +244,7 @@ public partial class Game : Node3D, IGame
|
||||
_effectService = new EffectService(this, _player, _map);
|
||||
}
|
||||
|
||||
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
public void OnReady()
|
||||
{
|
||||
InitializeGame();
|
||||
@@ -254,22 +254,22 @@ public partial class Game : Node3D, IGame
|
||||
InGameUI.PlayerInfoUI.Activate();
|
||||
_player.Activate();
|
||||
}
|
||||
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
|
||||
private void FloorClearMenu_SaveAndExit()
|
||||
{
|
||||
//SaveFile.Save();
|
||||
_player.Deactivate();
|
||||
GameState.Input(new GameState.Input.ReturnToMainMenu());
|
||||
InGameUI.Hide();
|
||||
}
|
||||
|
||||
private void FloorClearMenu_GoToNextFloor() => GameState.Input(new GameState.Input.LoadNextFloor());
|
||||
|
||||
public void LoadExistingGame() => SaveFile.Load().ContinueWith((_) => CallDeferred(nameof(FinishedLoadingSaveFile)));
|
||||
|
||||
public void InitializeGame()
|
||||
{
|
||||
_map.InitializeMapData();
|
||||
_player.InitializePlayerState();
|
||||
}
|
||||
|
||||
public void FloorExitReached()
|
||||
|
||||
Reference in New Issue
Block a user