forked from Shardstone/trail-into-darkness
Work on hooking the character system into the character creation
This commit is contained in:
@@ -104,18 +104,9 @@ namespace Nox.Core {
|
|||||||
|
|
||||||
var adventureData = new AdventureData();
|
var adventureData = new AdventureData();
|
||||||
|
|
||||||
var characterBaseSettings = Addressables.LoadAssetAsync<StarterCharacterSettings>("CharacterBaseSettings").WaitForCompletion();
|
|
||||||
var perKRegistry = Addressables.LoadAssetAsync<PerksRegistry>("PerksRegistry").WaitForCompletion();
|
|
||||||
var characterRegistry = Addressables.LoadAssetAsync<CharacterRegistry>("CharacterRegistry").WaitForCompletion();
|
|
||||||
var defaultPartySettings = Addressables.LoadAssetAsync<DefaultPartySettings>("DefaultPartySettings").WaitForCompletion();
|
|
||||||
var modifiersRegistry = Addressables.LoadAssetAsync<ModifiersRegistry>("ModifiersRegistry").WaitForCompletion();
|
|
||||||
|
|
||||||
var characterSystems = DefaultCharacterSystemsFactory.Create(characterBaseSettings, perKRegistry, characterRegistry, modifiersRegistry);
|
|
||||||
var partyCreatorModel = new PartyCreatorModel(characterSystems.CharacterFactory, characterSystems.PartyFactory, defaultPartySettings);
|
|
||||||
|
|
||||||
applicationStates = new Dictionary<GameState, IGameState> {
|
applicationStates = new Dictionary<GameState, IGameState> {
|
||||||
[GameState.BootState] = new SplashGameState(bootstrapReferences, gameDataState),
|
[GameState.BootState] = new SplashGameState(bootstrapReferences, gameDataState),
|
||||||
[GameState.MainMenu] = new MainMenuGameState(gameDataState, menuGameStateData, bootstrapReferences, saveSystem, partyCreatorModel, adventureData, gameLogStore),
|
[GameState.MainMenu] = new MainMenuGameState(gameDataState, menuGameStateData, bootstrapReferences, saveSystem, adventureData, gameLogStore),
|
||||||
[GameState.GameMode] = new GameModeGameState(gameDataState, bootstrapReferences, platform.PlatformSettings, saveSystem, sceneTransition, adventureData, gameLogStore),
|
[GameState.GameMode] = new GameModeGameState(gameDataState, bootstrapReferences, platform.PlatformSettings, saveSystem, sceneTransition, adventureData, gameLogStore),
|
||||||
};
|
};
|
||||||
createApplicationStateMarker.End();
|
createApplicationStateMarker.End();
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ namespace Nox.Core {
|
|||||||
private readonly MenuGameStateData menuGameStateData;
|
private readonly MenuGameStateData menuGameStateData;
|
||||||
private readonly BootstrapReferences bootstrapReferences;
|
private readonly BootstrapReferences bootstrapReferences;
|
||||||
private readonly ISaveSystem saveSystem;
|
private readonly ISaveSystem saveSystem;
|
||||||
private readonly PartyCreatorModel partyCreatorModel;
|
|
||||||
private readonly IGameLogStore gameLogStore;
|
private readonly IGameLogStore gameLogStore;
|
||||||
private AdventureData adventureData;
|
private AdventureData adventureData;
|
||||||
private Action<PlayMode> onStartGameRequested;
|
private Action<PlayMode> onStartGameRequested;
|
||||||
@@ -34,14 +33,12 @@ namespace Nox.Core {
|
|||||||
MenuGameStateData menuGameStateData,
|
MenuGameStateData menuGameStateData,
|
||||||
BootstrapReferences bootstrapReferences,
|
BootstrapReferences bootstrapReferences,
|
||||||
ISaveSystem saveSystem,
|
ISaveSystem saveSystem,
|
||||||
PartyCreatorModel partyCreatorModel,
|
|
||||||
AdventureData adventureData,
|
AdventureData adventureData,
|
||||||
IGameLogStore gameLogStore) {
|
IGameLogStore gameLogStore) {
|
||||||
this.gameDataState = gameDataState;
|
this.gameDataState = gameDataState;
|
||||||
this.menuGameStateData = menuGameStateData;
|
this.menuGameStateData = menuGameStateData;
|
||||||
this.bootstrapReferences = bootstrapReferences;
|
this.bootstrapReferences = bootstrapReferences;
|
||||||
this.saveSystem = saveSystem;
|
this.saveSystem = saveSystem;
|
||||||
this.partyCreatorModel = partyCreatorModel;
|
|
||||||
this.adventureData = adventureData;
|
this.adventureData = adventureData;
|
||||||
this.gameLogStore = gameLogStore;
|
this.gameLogStore = gameLogStore;
|
||||||
}
|
}
|
||||||
@@ -49,8 +46,6 @@ namespace Nox.Core {
|
|||||||
public void EnterGameState() {
|
public void EnterGameState() {
|
||||||
IsGameStateInitialized = false;
|
IsGameStateInitialized = false;
|
||||||
onStartGameRequested = mode => {
|
onStartGameRequested = mode => {
|
||||||
var party = partyCreatorModel.CreatePartyForNewRun(companionCount: 4);
|
|
||||||
gameDataState.ActiveParty = party;
|
|
||||||
var sessions = saveSystem.GetAllSessions();
|
var sessions = saveSystem.GetAllSessions();
|
||||||
gameDataState.activeSessionId = sessions.Count > 0
|
gameDataState.activeSessionId = sessions.Count > 0
|
||||||
? sessions[0].sessionId
|
? sessions[0].sessionId
|
||||||
@@ -67,6 +62,7 @@ namespace Nox.Core {
|
|||||||
|
|
||||||
gameDataState.ChangeGameState(GameState.GameMode);
|
gameDataState.ChangeGameState(GameState.GameMode);
|
||||||
gameDataState.ChangePlayMode(saveData.activePlayMode);
|
gameDataState.ChangePlayMode(saveData.activePlayMode);
|
||||||
|
gameDataState.ActiveParty = saveData.activeParty;
|
||||||
|
|
||||||
};
|
};
|
||||||
menuGameStateData.startGameRequests += onStartGameRequested;
|
menuGameStateData.startGameRequests += onStartGameRequested;
|
||||||
@@ -80,7 +76,15 @@ namespace Nox.Core {
|
|||||||
await sceneHandle.Result.ActivateAsync();
|
await sceneHandle.Result.ActivateAsync();
|
||||||
var assetHandle = Addressables.LoadAssetAsync<MenuPrefabsContainer>(bootstrapReferences.menuPrefabsContainer);
|
var assetHandle = Addressables.LoadAssetAsync<MenuPrefabsContainer>(bootstrapReferences.menuPrefabsContainer);
|
||||||
await assetHandle.Task;
|
await assetHandle.Task;
|
||||||
mainMenuView = new MainMenuView(assetHandle.Result, menuGameStateData, saveSystem);
|
var characterBaseSettings = Addressables.LoadAssetAsync<StarterCharacterSettings>("CharacterBaseSettings").WaitForCompletion();
|
||||||
|
var perKRegistry = Addressables.LoadAssetAsync<PerksRegistry>("PerksRegistry").WaitForCompletion();
|
||||||
|
var characterRegistry = Addressables.LoadAssetAsync<CharacterRegistry>("CharacterRegistry").WaitForCompletion();
|
||||||
|
var modifiersRegistry = Addressables.LoadAssetAsync<ModifiersRegistry>("ModifiersRegistry").WaitForCompletion();
|
||||||
|
|
||||||
|
var partySettings = Addressables.LoadAssetAsync<PartySettings>("DefaultPartySettings").WaitForCompletion();
|
||||||
|
var characterSystems = CharacterSystemsFactory.Create(partySettings, characterBaseSettings, perKRegistry, characterRegistry, modifiersRegistry);
|
||||||
|
|
||||||
|
mainMenuView = new MainMenuView(assetHandle.Result, menuGameStateData, saveSystem, gameDataState, partySettings, characterSystems);
|
||||||
mainMenuView.Initialize();
|
mainMenuView.Initialize();
|
||||||
IsGameStateInitialized = true;
|
IsGameStateInitialized = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using ZLinq;
|
|||||||
|
|
||||||
namespace Nox.Game {
|
namespace Nox.Game {
|
||||||
public interface ICharacterFactory {
|
public interface ICharacterFactory {
|
||||||
CharacterDefinition CreateCustomProtagonist(CustomCharacterCreationRequest request);
|
CharacterDefinition CreateProtagonist(CharacterCreationRequest request);
|
||||||
CharacterDefinition CreateFromTemplate(CharacterTemplate template, CharacterRole role = CharacterRole.Companion);
|
CharacterDefinition CreateFromTemplate(CharacterTemplate template, CharacterRole role = CharacterRole.Companion);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ namespace Nox.Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class CustomCharacterCreationRequest : IEntityDefinition {
|
public sealed class CharacterCreationRequest : IEntityDefinition {
|
||||||
public Guid Id { get; set; } = Guid.Empty;
|
public Guid Id { get; set; } = Guid.Empty;
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public CharacterRace Race { get; set; }
|
public CharacterRace Race { get; set; }
|
||||||
@@ -64,7 +64,7 @@ namespace Nox.Game {
|
|||||||
this.modifiersFactory = modifiersFactory ?? throw new ArgumentNullException(nameof(modifiersFactory));
|
this.modifiersFactory = modifiersFactory ?? throw new ArgumentNullException(nameof(modifiersFactory));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CharacterDefinition CreateCustomProtagonist(CustomCharacterCreationRequest request) {
|
public CharacterDefinition CreateProtagonist(CharacterCreationRequest request) {
|
||||||
if(request == null) {
|
if(request == null) {
|
||||||
throw new ArgumentNullException(nameof(request));
|
throw new ArgumentNullException(nameof(request));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Nox.Game {
|
namespace Nox.Game {
|
||||||
public static class DefaultCharacterSystemsFactory {
|
public static class CharacterSystemsFactory {
|
||||||
public static ICharacterSystems Create(
|
public static ICharacterSystems Create(
|
||||||
|
PartySettings partySettings,
|
||||||
StarterCharacterSettings starterCharacterSettings,
|
StarterCharacterSettings starterCharacterSettings,
|
||||||
PerksRegistry perksRegistry,
|
PerksRegistry perksRegistry,
|
||||||
CharacterRegistry characterRegistry,
|
CharacterRegistry characterRegistry,
|
||||||
@@ -13,7 +14,7 @@ namespace Nox.Game {
|
|||||||
ICharacterAttributesFactory attributesFactory = new CharacterAttributesFactory(modifierResolver);
|
ICharacterAttributesFactory attributesFactory = new CharacterAttributesFactory(modifierResolver);
|
||||||
ICharacterStatsFactory statsFactory = new CharacterStatsFactory(starterCharacterSettings, modifierResolver);
|
ICharacterStatsFactory statsFactory = new CharacterStatsFactory(starterCharacterSettings, modifierResolver);
|
||||||
ICharacterFactory characterFactory = new CharacterFactory(attributesFactory, statsFactory, perkFactory, modifiersFactory);
|
ICharacterFactory characterFactory = new CharacterFactory(attributesFactory, statsFactory, perkFactory, modifiersFactory);
|
||||||
IPartyFactory partyFactory = new PartyFactory(starterCharacterSettings);
|
IPartyFactory partyFactory = new PartyFactory(partySettings, starterCharacterSettings);
|
||||||
|
|
||||||
return new CharacterSystems(perkFactory, modifiersFactory, modifierResolver, characterFactory, partyFactory);
|
return new CharacterSystems(perkFactory, modifiersFactory, modifierResolver, characterFactory, partyFactory);
|
||||||
}
|
}
|
||||||
@@ -1,52 +1,28 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Nox.Game {
|
namespace Nox.Game {
|
||||||
public class PartyCreatorModel {
|
public class PartyCreatorModel {
|
||||||
private readonly ICharacterFactory characterFactory;
|
private readonly ICharacterFactory characterFactory;
|
||||||
private readonly IPartyFactory partyFactory;
|
private readonly IPartyFactory partyFactory;
|
||||||
private readonly DefaultPartySettings defaultPartySettings;
|
private readonly List<CharacterCreationRequest> characterCreationRequests;
|
||||||
public PartyCreatorModel(ICharacterFactory characterFactory, IPartyFactory partyFactory, DefaultPartySettings defaultPartySettings) {
|
private readonly PartySettings partySettings;
|
||||||
|
|
||||||
|
public PartyCreatorModel(ICharacterFactory characterFactory,
|
||||||
|
IPartyFactory partyFactory,
|
||||||
|
List<CharacterCreationRequest> characterCreationRequests,
|
||||||
|
PartySettings partySettings) {
|
||||||
this.characterFactory = characterFactory;
|
this.characterFactory = characterFactory;
|
||||||
this.partyFactory = partyFactory;
|
this.partyFactory = partyFactory;
|
||||||
this.defaultPartySettings = defaultPartySettings;
|
this.characterCreationRequests = characterCreationRequests;
|
||||||
|
this.partySettings = partySettings;
|
||||||
}
|
}
|
||||||
public PartyDefinition CreatePartyForNewRun(int companionCount) {
|
public PartyDefinition CreatePartyForNewRun() {
|
||||||
var protagonist = characterFactory.CreateCustomProtagonist(new CustomCharacterCreationRequest {
|
if(characterCreationRequests.Count > partySettings.maxPartySize) {
|
||||||
Name = "John Doe",
|
throw new System.ArgumentException("Too many characters requested.");
|
||||||
Attributes = new EntityAttributes {
|
|
||||||
attributes = new[] {
|
|
||||||
new Attribute(AttributeType.Might, 3),
|
|
||||||
new Attribute(AttributeType.Reflex, 3),
|
|
||||||
new Attribute(AttributeType.Knowledge, 3),
|
|
||||||
new Attribute(AttributeType.Perception, 3)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var rookAttributes = new EntityAttributes {
|
|
||||||
attributes = new[] {
|
|
||||||
new Attribute(AttributeType.Might, 6),
|
|
||||||
new Attribute(AttributeType.Knowledge, 2),
|
|
||||||
new Attribute(AttributeType.Perception, 2),
|
|
||||||
new Attribute(AttributeType.Reflex, 4)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
CharacterTemplate[] companionTemplates = {
|
|
||||||
new() {
|
|
||||||
Name = "Rook",
|
|
||||||
Attributes = rookAttributes,
|
|
||||||
Perks = new PerksData(){
|
|
||||||
perks = new List<PerkDefinition>()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var companions = new List<CharacterDefinition>();
|
|
||||||
for(var i = 0; i < companionCount && i < companionTemplates.Length; i++) {
|
|
||||||
companions.Add(characterFactory.CreateFromTemplate(companionTemplates[i], CharacterRole.Companion));
|
|
||||||
}
|
}
|
||||||
|
var protagonist = characterFactory.CreateProtagonist(characterCreationRequests.Find(r => r.Role == CharacterRole.Protagonist));
|
||||||
|
var companions = characterCreationRequests.FindAll(r => r.Role != CharacterRole.Protagonist).Select(r => characterFactory.CreateProtagonist(r));
|
||||||
return partyFactory.Create(protagonist, companions);
|
return partyFactory.Create(protagonist, companions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ namespace Nox.Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public sealed class PartyFactory : IPartyFactory {
|
public sealed class PartyFactory : IPartyFactory {
|
||||||
|
private readonly PartySettings partySettings;
|
||||||
private readonly StarterCharacterSettings starterCharacterSettings;
|
private readonly StarterCharacterSettings starterCharacterSettings;
|
||||||
|
|
||||||
public PartyFactory(StarterCharacterSettings starterCharacterSettings) {
|
public PartyFactory(PartySettings partySettings, StarterCharacterSettings starterCharacterSettings) {
|
||||||
|
this.partySettings = partySettings;
|
||||||
this.starterCharacterSettings = starterCharacterSettings;
|
this.starterCharacterSettings = starterCharacterSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,7 +22,7 @@ namespace Nox.Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var party = new PartyDefinition {
|
var party = new PartyDefinition {
|
||||||
maxPartySize = starterCharacterSettings.maxPartySize <= 0 ? int.MaxValue : starterCharacterSettings.maxPartySize
|
maxPartySize = partySettings.maxPartySize <= 0 ? int.MaxValue : partySettings.maxPartySize
|
||||||
};
|
};
|
||||||
|
|
||||||
var protagonistClone = protagonist.Clone();
|
var protagonistClone = protagonist.Clone();
|
||||||
|
|||||||
@@ -5,22 +5,25 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace Nox.Game {
|
namespace Nox.Game {
|
||||||
[CreateAssetMenu(fileName = "DefaultPartySettings", menuName = "Nox/Database/Entities/Default Party Settings")]
|
[CreateAssetMenu(fileName = "DefaultPartySettings", menuName = "Nox/Database/Entities/Default Party Settings")]
|
||||||
public class DefaultPartySettings : ScriptableObject {
|
public class PartySettings : ScriptableObject {
|
||||||
|
[Header("Party System Defaults")]
|
||||||
|
public int maxPartySize = 4;
|
||||||
|
|
||||||
[Header("This will be default starting set")]
|
[Header("This will be default starting set")]
|
||||||
public string startingSetId;
|
public string testStartingSetId;
|
||||||
|
|
||||||
[Header("Party Definition Sets")]
|
[Header("Party Definition Sets")]
|
||||||
public List<PartyDefinitionSet> partyDefinitionSets;
|
public List<PartyDefinitionSet> testPartyDefinitionSets;
|
||||||
|
|
||||||
[Header("Testing Party Definition Sets")]
|
[Header("Testing Party Definition Sets")]
|
||||||
public StarterCharacterSettings starterCharacterSettings;
|
public StarterCharacterSettings testStarterCharacterSettings;
|
||||||
|
|
||||||
private void OnValidate() {
|
private void OnValidate() {
|
||||||
if(String.IsNullOrEmpty(startingSetId)) {
|
if(String.IsNullOrEmpty(testStartingSetId)) {
|
||||||
Debug.LogError("DefaultPartySettings: startingSetId cannot be null or empty");
|
Debug.LogError("DefaultPartySettings: startingSetId cannot be null or empty");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
foreach(var partyDefinitionSet in partyDefinitionSets) {
|
foreach(var partyDefinitionSet in testPartyDefinitionSets) {
|
||||||
var partyDefinition = partyDefinitionSet.partyDefinition;
|
var partyDefinition = partyDefinitionSet.partyDefinition;
|
||||||
if(partyDefinition == null) {
|
if(partyDefinition == null) {
|
||||||
return;
|
return;
|
||||||
@@ -32,8 +35,8 @@ namespace Nox.Game {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(partyDefinitionSets.AsValueEnumerable().FirstOrDefault(pds => pds.id == partyDefinitionSet.id && pds.isTestingSet) != null) {
|
if(testPartyDefinitionSets.AsValueEnumerable().FirstOrDefault(pds => pds.id == partyDefinitionSet.id && pds.isTestingSet) != null) {
|
||||||
var testingSet = partyDefinitionSets.AsValueEnumerable().FirstOrDefault(pds => pds.id == partyDefinitionSet.id && pds.isTestingSet);
|
var testingSet = testPartyDefinitionSets.AsValueEnumerable().FirstOrDefault(pds => pds.id == partyDefinitionSet.id && pds.isTestingSet);
|
||||||
ApplyClassAndRacialBonuses(testingSet);
|
ApplyClassAndRacialBonuses(testingSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,9 +50,9 @@ namespace Nox.Game {
|
|||||||
private void ApplyClassAndRacialBonuses(PartyDefinitionSet testingSet) {
|
private void ApplyClassAndRacialBonuses(PartyDefinitionSet testingSet) {
|
||||||
var partyDefinition = testingSet.partyDefinition;
|
var partyDefinition = testingSet.partyDefinition;
|
||||||
foreach(var member in partyDefinition.members) {
|
foreach(var member in partyDefinition.members) {
|
||||||
var baseSettings = starterCharacterSettings.defaultEntityAttributes;
|
var baseSettings = testStarterCharacterSettings.defaultEntityAttributes;
|
||||||
var classAttributes = starterCharacterSettings.classBonuses.AsValueEnumerable().FirstOrDefault(c => c.@class == member.Class)?.bonusAttributes;
|
var classAttributes = testStarterCharacterSettings.classBonuses.AsValueEnumerable().FirstOrDefault(c => c.@class == member.Class)?.bonusAttributes;
|
||||||
var racialAttributes = starterCharacterSettings.racialBonuses.AsValueEnumerable().FirstOrDefault(rb => rb.race == member.Race)?.bonusAttributes;
|
var racialAttributes = testStarterCharacterSettings.racialBonuses.AsValueEnumerable().FirstOrDefault(rb => rb.race == member.Race)?.bonusAttributes;
|
||||||
if (classAttributes != null && racialAttributes != null) {
|
if (classAttributes != null && racialAttributes != null) {
|
||||||
member.Attributes += baseSettings + classAttributes + racialAttributes;
|
member.Attributes += baseSettings + classAttributes + racialAttributes;
|
||||||
}
|
}
|
||||||
@@ -14,9 +14,6 @@ namespace Nox.Game {
|
|||||||
[Header("General Racial Bonuses and Perks per Class")]
|
[Header("General Racial Bonuses and Perks per Class")]
|
||||||
public RacialBonuses [] racialBonuses;
|
public RacialBonuses [] racialBonuses;
|
||||||
public ClassBonuses [] classBonuses;
|
public ClassBonuses [] classBonuses;
|
||||||
|
|
||||||
[Header("Party System Defaults")]
|
|
||||||
public int maxPartySize = 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace Nox.Game {
|
|||||||
|
|
||||||
gameDataState.activeSessionId = latestSession.sessionId;
|
gameDataState.activeSessionId = latestSession.sessionId;
|
||||||
gameDataState.savedPartyPosition = saveData.partyPosition.ToVector3();
|
gameDataState.savedPartyPosition = saveData.partyPosition.ToVector3();
|
||||||
gameDataState.ActiveParty = saveData.partyDefinition;
|
gameDataState.ActiveParty = saveData.activeParty;
|
||||||
adventureData = saveData.adventureData;
|
adventureData = saveData.adventureData;
|
||||||
|
|
||||||
if(gameLogStore != null && saveData.gameLogData != null) {
|
if(gameLogStore != null && saveData.gameLogData != null) {
|
||||||
@@ -59,7 +59,7 @@ namespace Nox.Game {
|
|||||||
public AdventureData adventureData;
|
public AdventureData adventureData;
|
||||||
|
|
||||||
// Party
|
// Party
|
||||||
public PartyDefinition partyDefinition;
|
public PartyDefinition activeParty;
|
||||||
public SerializableVector3 partyPosition;
|
public SerializableVector3 partyPosition;
|
||||||
|
|
||||||
// In-game log
|
// In-game log
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ namespace Nox.Game {
|
|||||||
public NoxSavedDataSet CaptureNoxSaveData() {
|
public NoxSavedDataSet CaptureNoxSaveData() {
|
||||||
return new NoxSavedDataSet {
|
return new NoxSavedDataSet {
|
||||||
activePlayMode = PlayMode.Adventure,
|
activePlayMode = PlayMode.Adventure,
|
||||||
partyDefinition = partyDefinition,
|
activeParty = partyDefinition,
|
||||||
partyPosition = partyRef ? SerializableVector3.FromVector3(partyRef.transform.position) : SerializableVector3.Zero
|
partyPosition = partyRef ? SerializableVector3.FromVector3(partyRef.transform.position) : SerializableVector3.Zero
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,44 @@
|
|||||||
|
using Jovian.SaveSystem;
|
||||||
using Nox.Core;
|
using Nox.Core;
|
||||||
|
using Nox.Game;
|
||||||
using Nox.Game.UI;
|
using Nox.Game.UI;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Nox.UI {
|
namespace Nox.UI {
|
||||||
public class CharacterCreationView : IMenuView {
|
public class CharacterCreationView : IMenuView {
|
||||||
// we need prefab reference from the menu view, character creation data, save system, modifier calculation, gamemode state to start the game
|
public ISaveSystem SaveSystem { get; }
|
||||||
// party creation data/system,
|
private readonly CharacterCreationReference characterCreationReference;
|
||||||
public CharacterCreationView(CharacterCreationReference characterCreationReference, MenuGameStateData menuGameStateData) {
|
private readonly MenuGameStateData menuGameStateData;
|
||||||
characterCreationReference.startGameButton.onClick.AddListener(() => menuGameStateData.startGameRequests?.Invoke(PlayMode.Adventure));
|
private readonly GameDataState gameDataState;
|
||||||
|
private readonly PartySettings partySettings;
|
||||||
|
private readonly ICharacterSystems characterSystems;
|
||||||
|
|
||||||
|
private List<CharacterCreationRequest> characterCreationRequests;
|
||||||
|
|
||||||
|
public CharacterCreationView(
|
||||||
|
CharacterCreationReference characterCreationReference,
|
||||||
|
MenuGameStateData menuGameStateData,
|
||||||
|
ISaveSystem saveSystem,
|
||||||
|
GameDataState gameDataState,
|
||||||
|
PartySettings partySettings,
|
||||||
|
ICharacterSystems characterSystems) {
|
||||||
|
SaveSystem = saveSystem;
|
||||||
|
this.characterCreationReference = characterCreationReference;
|
||||||
|
this.menuGameStateData = menuGameStateData;
|
||||||
|
this.gameDataState = gameDataState;
|
||||||
|
this.partySettings = partySettings;
|
||||||
|
this.characterSystems = characterSystems;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize() {
|
public void Initialize() {
|
||||||
throw new System.NotImplementedException();
|
characterCreationReference.startGameButton.onClick.AddListener(() => menuGameStateData.startGameRequests?.Invoke(PlayMode.Adventure));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateParty() {
|
||||||
|
var partyCreatorModel = new PartyCreatorModel(characterSystems.CharacterFactory, characterSystems.PartyFactory, characterCreationRequests, partySettings);
|
||||||
|
var party = partyCreatorModel.CreatePartyForNewRun();
|
||||||
|
gameDataState.ActiveParty = party;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick() {
|
public void Tick() {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ using Jovian.SaveSystem;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.AddressableAssets;
|
using UnityEngine.AddressableAssets;
|
||||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||||
using PlayMode = Nox.Core.PlayMode;
|
|
||||||
|
|
||||||
namespace Nox.UI {
|
namespace Nox.UI {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -14,15 +13,28 @@ namespace Nox.UI {
|
|||||||
private readonly MenuPrefabsContainer menuPrefabsContainer;
|
private readonly MenuPrefabsContainer menuPrefabsContainer;
|
||||||
private readonly MenuGameStateData menuGameStateData;
|
private readonly MenuGameStateData menuGameStateData;
|
||||||
private readonly ISaveSystem saveSystem;
|
private readonly ISaveSystem saveSystem;
|
||||||
|
private readonly GameDataState gameDataState;
|
||||||
|
private readonly PartySettings partySettings;
|
||||||
|
private readonly ICharacterSystems characterSystems;
|
||||||
private MainMenuReference mainMenuReference;
|
private MainMenuReference mainMenuReference;
|
||||||
private CharacterCreationReference characterCreationReference;
|
private CharacterCreationReference characterCreationReference;
|
||||||
private CharacterCreationView characterCreationView;
|
private CharacterCreationView characterCreationView;
|
||||||
private AsyncOperationHandle<GameObject> charCreationHandle;
|
private AsyncOperationHandle<GameObject> charCreationHandle;
|
||||||
|
|
||||||
public MainMenuView(MenuPrefabsContainer menuPrefabsContainer, MenuGameStateData menuGameStateData, ISaveSystem saveSystem) {
|
public MainMenuView(
|
||||||
|
MenuPrefabsContainer menuPrefabsContainer,
|
||||||
|
MenuGameStateData menuGameStateData,
|
||||||
|
ISaveSystem saveSystem,
|
||||||
|
GameDataState gameDataState,
|
||||||
|
PartySettings partySettings,
|
||||||
|
ICharacterSystems characterSystems
|
||||||
|
) {
|
||||||
this.menuPrefabsContainer = menuPrefabsContainer;
|
this.menuPrefabsContainer = menuPrefabsContainer;
|
||||||
this.menuGameStateData = menuGameStateData;
|
this.menuGameStateData = menuGameStateData;
|
||||||
this.saveSystem = saveSystem;
|
this.saveSystem = saveSystem;
|
||||||
|
this.gameDataState = gameDataState;
|
||||||
|
this.partySettings = partySettings;
|
||||||
|
this.characterSystems = characterSystems;
|
||||||
}
|
}
|
||||||
public void Initialize() {
|
public void Initialize() {
|
||||||
if(mainMenuReference == null) {
|
if(mainMenuReference == null) {
|
||||||
@@ -39,14 +51,14 @@ namespace Nox.UI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitializeCharacterCreation() {
|
private void InitializeCharacterCreation() {
|
||||||
charCreationHandle = Addressables.InstantiateAsync(menuPrefabsContainer.characterCreationReference);
|
charCreationHandle = Addressables.InstantiateAsync(menuPrefabsContainer.characterCreationReference);
|
||||||
charCreationHandle.Task.ContinueWith(t => {
|
charCreationHandle.Task.ContinueWith(t => {
|
||||||
if(t.IsFaulted) {
|
if(t.IsFaulted) {
|
||||||
Debug.LogError(t.Exception);
|
Debug.LogError(t.Exception);
|
||||||
}
|
}
|
||||||
characterCreationReference =t.Result.GetComponent<CharacterCreationReference>();
|
characterCreationReference =t.Result.GetComponent<CharacterCreationReference>();
|
||||||
characterCreationView = new CharacterCreationView(characterCreationReference, menuGameStateData);
|
characterCreationView = new CharacterCreationView(characterCreationReference, menuGameStateData, saveSystem, gameDataState, partySettings, characterSystems);
|
||||||
characterCreationView.Show();
|
characterCreationView.Show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.AddressableAssets;
|
using UnityEngine.AddressableAssets;
|
||||||
using UnityEngine.ResourceManagement.ResourceLocations;
|
|
||||||
|
|
||||||
namespace Nox.UI {
|
namespace Nox.UI {
|
||||||
[CreateAssetMenu(fileName = "MenuPrefabsContainer", menuName = "Nox/Database/UI/MenuPrefabContainer")]
|
[CreateAssetMenu(fileName = "MenuPrefabsContainer", menuName = "Nox/Database/UI/MenuPrefabContainer")]
|
||||||
|
|||||||
@@ -12,92 +12,6 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: ff702898b3cd4100b9b8230f04711fa9, type: 3}
|
m_Script: {fileID: 11500000, guid: ff702898b3cd4100b9b8230f04711fa9, type: 3}
|
||||||
m_Name: DefaultPartySettings
|
m_Name: DefaultPartySettings
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::Nox.Game.DefaultPartySettings
|
m_EditorClassIdentifier: Assembly-CSharp::Nox.Game.DefaultPartySettings
|
||||||
partyDefinitionSets:
|
startingSetId:
|
||||||
- id: startingParty1
|
partyDefinitionSets: []
|
||||||
partyDefinition:
|
starterCharacterSettings: {fileID: 0}
|
||||||
maxPartySize: 4
|
|
||||||
members:
|
|
||||||
- id:
|
|
||||||
displayName:
|
|
||||||
race: 0
|
|
||||||
class: 0
|
|
||||||
role: 0
|
|
||||||
attributes:
|
|
||||||
might: 0
|
|
||||||
reflex: 0
|
|
||||||
knowledge: 0
|
|
||||||
perception: 0
|
|
||||||
stats:
|
|
||||||
health: 0
|
|
||||||
stamina: 0
|
|
||||||
level: 0
|
|
||||||
experience: 0
|
|
||||||
perksData:
|
|
||||||
perks: []
|
|
||||||
activeModifiers:
|
|
||||||
modifiers: []
|
|
||||||
- id:
|
|
||||||
displayName:
|
|
||||||
race: 0
|
|
||||||
class: 0
|
|
||||||
role: 0
|
|
||||||
attributes:
|
|
||||||
might: 0
|
|
||||||
reflex: 0
|
|
||||||
knowledge: 0
|
|
||||||
perception: 0
|
|
||||||
stats:
|
|
||||||
health: 0
|
|
||||||
stamina: 0
|
|
||||||
level: 0
|
|
||||||
experience: 0
|
|
||||||
perksData:
|
|
||||||
perks: []
|
|
||||||
activeModifiers:
|
|
||||||
modifiers: []
|
|
||||||
- id:
|
|
||||||
displayName:
|
|
||||||
race: 0
|
|
||||||
class: 0
|
|
||||||
role: 0
|
|
||||||
attributes:
|
|
||||||
might: 0
|
|
||||||
reflex: 0
|
|
||||||
knowledge: 0
|
|
||||||
perception: 0
|
|
||||||
stats:
|
|
||||||
health: 0
|
|
||||||
stamina: 0
|
|
||||||
level: 0
|
|
||||||
experience: 0
|
|
||||||
perksData:
|
|
||||||
perks: []
|
|
||||||
activeModifiers:
|
|
||||||
modifiers: []
|
|
||||||
- id:
|
|
||||||
displayName:
|
|
||||||
race: 0
|
|
||||||
class: 0
|
|
||||||
role: 0
|
|
||||||
attributes:
|
|
||||||
might: 0
|
|
||||||
reflex: 0
|
|
||||||
knowledge: 0
|
|
||||||
perception: 0
|
|
||||||
stats:
|
|
||||||
health: 0
|
|
||||||
stamina: 0
|
|
||||||
level: 0
|
|
||||||
experience: 0
|
|
||||||
perksData:
|
|
||||||
perks: []
|
|
||||||
activeModifiers:
|
|
||||||
modifiers: []
|
|
||||||
attributesPointDistribution:
|
|
||||||
might: 0
|
|
||||||
reflex: 0
|
|
||||||
knowledge: 0
|
|
||||||
perception: 0
|
|
||||||
distributionPointsPerClass:
|
|
||||||
class: 0
|
|
||||||
points: 0
|
|
||||||
|
|||||||
@@ -772,7 +772,7 @@ MonoBehaviour:
|
|||||||
m_OnCullStateChanged:
|
m_OnCullStateChanged:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
m_Calls: []
|
m_Calls: []
|
||||||
m_text: 5
|
m_text: -1
|
||||||
m_isRightToLeft: 0
|
m_isRightToLeft: 0
|
||||||
m_fontAsset: {fileID: 11400000, guid: a0ee74bf6f853704a8a568d5ef638ee9, type: 2}
|
m_fontAsset: {fileID: 11400000, guid: a0ee74bf6f853704a8a568d5ef638ee9, type: 2}
|
||||||
m_sharedMaterial: {fileID: 9074173216178389243, guid: a0ee74bf6f853704a8a568d5ef638ee9, type: 2}
|
m_sharedMaterial: {fileID: 9074173216178389243, guid: a0ee74bf6f853704a8a568d5ef638ee9, type: 2}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ MonoBehaviour:
|
|||||||
m_OnCullStateChanged:
|
m_OnCullStateChanged:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
m_Calls: []
|
m_Calls: []
|
||||||
m_text: 100
|
m_text: -1
|
||||||
m_isRightToLeft: 0
|
m_isRightToLeft: 0
|
||||||
m_fontAsset: {fileID: 11400000, guid: a0ee74bf6f853704a8a568d5ef638ee9, type: 2}
|
m_fontAsset: {fileID: 11400000, guid: a0ee74bf6f853704a8a568d5ef638ee9, type: 2}
|
||||||
m_sharedMaterial: {fileID: 9074173216178389243, guid: a0ee74bf6f853704a8a568d5ef638ee9, type: 2}
|
m_sharedMaterial: {fileID: 9074173216178389243, guid: a0ee74bf6f853704a8a568d5ef638ee9, type: 2}
|
||||||
|
|||||||
Reference in New Issue
Block a user