forked from Shardstone/trail-into-darkness
added logger to character creation, default character setup, gameplay flow and textmeshpro stuff
This commit is contained in:
@@ -21,7 +21,7 @@ namespace Nox.Core {
|
||||
private readonly PlayModeSettings bootstrapSettings;
|
||||
private readonly ISaveSystem saveSystem;
|
||||
private readonly ISceneTransition sceneTransition;
|
||||
private readonly AdventureData adventuredata;
|
||||
private readonly AdventureData adventureData;
|
||||
private readonly IGameLogStore gameLogStore;
|
||||
|
||||
private readonly Dictionary<PlayMode, IPlayMode?> playModeCache = new();
|
||||
@@ -45,13 +45,13 @@ namespace Nox.Core {
|
||||
PlatformSettings platformSettings,
|
||||
ISaveSystem saveSystem,
|
||||
ISceneTransition sceneTransition,
|
||||
AdventureData adventuredata,
|
||||
AdventureData adventureData,
|
||||
IGameLogStore gameLogStore) {
|
||||
this.gameDataState = gameDataState;
|
||||
this.platformSettings = platformSettings;
|
||||
this.saveSystem = saveSystem;
|
||||
this.sceneTransition = sceneTransition;
|
||||
this.adventuredata = adventuredata;
|
||||
this.adventureData = adventureData;
|
||||
this.gameLogStore = gameLogStore;
|
||||
|
||||
bootstrapSettings = Addressables.LoadAssetAsync<PlayModeSettings>(bootstrapReferences.playModeSettings).WaitForCompletion();
|
||||
@@ -108,7 +108,7 @@ namespace Nox.Core {
|
||||
}
|
||||
|
||||
playMode = gameDataState.ActivePlayMode switch {
|
||||
PlayMode.Adventure => new AdventurePlayMode(platformSettings, activeParty, bootstrapSettings, gameDataState, saveSystem, adventureSettings, adventuredata),
|
||||
PlayMode.Adventure => new AdventurePlayMode(platformSettings, activeParty, bootstrapSettings, gameDataState, saveSystem, adventureSettings, adventureData),
|
||||
PlayMode.PauseMenu => new PauseMenuPlayMode(platformSettings, gameDataState, pauseMenuView!),
|
||||
PlayMode.Town => new TownPlayMode(platformSettings, activeParty),
|
||||
PlayMode.Rest => new RestPlayMode(platformSettings, activeParty),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ZLinq;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -34,6 +35,15 @@ namespace Nox.Game {
|
||||
Perception
|
||||
}
|
||||
|
||||
public enum CombatScoreType {
|
||||
None,
|
||||
ATK,
|
||||
DEF,
|
||||
INIT,
|
||||
SPD,
|
||||
RES
|
||||
}
|
||||
|
||||
public enum CharacterRole {
|
||||
None,
|
||||
Protagonist,
|
||||
@@ -93,6 +103,10 @@ namespace Nox.Game {
|
||||
public int GetValue(AttributeType attributeType) {
|
||||
return attributes.AsValueEnumerable().First(attr => attr.attribute == attributeType).value;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return $"Attributes: {string.Join(", ", attributes.Select(attr => $"{attr.attribute}: {attr.value}"))}";
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
@@ -106,6 +120,10 @@ namespace Nox.Game {
|
||||
var match = stats.AsValueEnumerable().FirstOrDefault(stat => stat.stat == statType);
|
||||
return match?.value ?? 0;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return $"Stats: {string.Join(", ", stats.Select(stat => $"{stat.stat}: {stat.value}"))}";
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Jovian.Logger;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ZLinq;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -32,16 +33,21 @@ namespace Nox.Game {
|
||||
[Serializable]
|
||||
public sealed class ModifierDefinition : IModifier {
|
||||
[field: SerializeField] public string Name { get; set; }
|
||||
public Guid Id { get; set; }
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
[field: SerializeField] public StatType StatType { get; set; }
|
||||
[field: SerializeField] public AttributeType AttributeType { get; set; }
|
||||
[field: SerializeField] public ModifierOperation Operation { get; set; }
|
||||
[field: SerializeField] public CombatScoreType CombatScoreType { get; set; }
|
||||
[field: SerializeField] public float Value { get; set; }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class ModifiersData {
|
||||
public List<ModifierDefinition> modifiers = new ();
|
||||
|
||||
public override string ToString() {
|
||||
return $"Modifiers: {string.Join(", ", modifiers.Select(modifier => $"{modifier.Name}"))}";
|
||||
}
|
||||
}
|
||||
|
||||
public class ModifiersFactory : IModifiersFactory {
|
||||
|
||||
@@ -15,9 +15,6 @@ namespace Nox.Game {
|
||||
[Header("Party Definition Sets")]
|
||||
public List<PartyDefinitionSet> testPartyDefinitionSets;
|
||||
|
||||
[Header("Testing Party Definition Sets")]
|
||||
public StarterCharacterSettings[] testStarterCharacterSettings;
|
||||
|
||||
private void OnValidate() {
|
||||
if(String.IsNullOrEmpty(testStartingSetId)) {
|
||||
Debug.LogError("DefaultPartySettings: startingSetId cannot be null or empty");
|
||||
@@ -35,13 +32,6 @@ namespace Nox.Game {
|
||||
}
|
||||
}
|
||||
|
||||
if(testPartyDefinitionSets.AsValueEnumerable().FirstOrDefault(pds => pds.id == partyDefinitionSet.id && pds.isTestingSet) != null) {
|
||||
var testingSet = testPartyDefinitionSets.AsValueEnumerable().FirstOrDefault(pds => pds.id == partyDefinitionSet.id && pds.isTestingSet);
|
||||
foreach(var characterSetting in testStarterCharacterSettings) {
|
||||
ApplyClassAndRacialBonuses(testingSet, characterSetting);
|
||||
}
|
||||
}
|
||||
|
||||
if(partyDefinition.members.Count <= partyDefinition.maxPartySize) {
|
||||
continue;
|
||||
}
|
||||
@@ -49,17 +39,6 @@ namespace Nox.Game {
|
||||
partyDefinition.members.RemoveRange(partyDefinition.maxPartySize, partyDefinition.members.Count - partyDefinition.maxPartySize);
|
||||
}
|
||||
}
|
||||
private void ApplyClassAndRacialBonuses(PartyDefinitionSet testingSet, StarterCharacterSettings starterCharacterSettings) {
|
||||
var partyDefinition = testingSet.partyDefinition;
|
||||
foreach(var member in partyDefinition.members) {
|
||||
var baseSettings = starterCharacterSettings.defaultEntityAttributes;
|
||||
var classAttributes = starterCharacterSettings.classBonuses.AsValueEnumerable().FirstOrDefault(c => c.@class == member.Class)?.bonusAttributes;
|
||||
var racialAttributes = starterCharacterSettings.racialBonuses.AsValueEnumerable().FirstOrDefault(rb => rb.race == member.Race)?.bonusAttributes;
|
||||
if (classAttributes != null && racialAttributes != null) {
|
||||
member.Attributes += baseSettings + classAttributes + racialAttributes;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Jovian.Logger;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ZLinq;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -23,12 +24,16 @@ namespace Nox.Game {
|
||||
public sealed class PerkDefinition : IPerk {
|
||||
[field: SerializeField] public string Name { get; set; }
|
||||
[field: SerializeField] public ModifiersData Modifiers { get; set; }
|
||||
public Guid Id { get; set; }
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class PerksData {
|
||||
public List<PerkDefinition> perks = new ();
|
||||
|
||||
public override string ToString() {
|
||||
return $"Perks: {string.Join(", ", perks.Select(perk => $"{perk.Name}"))}";
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class PerkFactory : IPerkFactory {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using Jovian.InGameLogging;
|
||||
using Jovian.InGameLogging.UI;
|
||||
using Jovian.Logger;
|
||||
using Jovian.SaveSystem;
|
||||
using Nox.Core;
|
||||
@@ -5,6 +7,8 @@ using Nox.Game;
|
||||
using Nox.Game.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using PlayMode = Nox.Core.PlayMode;
|
||||
|
||||
namespace Nox.UI {
|
||||
public class CharacterCreationView : IGameLifecycle, IMenuView {
|
||||
@@ -16,6 +20,9 @@ namespace Nox.UI {
|
||||
private readonly ICharacterSystems characterSystems;
|
||||
|
||||
private List<CharacterCreationRequest> characterCreationRequests;
|
||||
private Action canStartCheck;
|
||||
private GameLogView gameLogView;
|
||||
private InGameLogger inGameLogger;
|
||||
|
||||
public CharacterCreationView(
|
||||
CharacterCreationReference characterCreationReference,
|
||||
@@ -33,35 +40,63 @@ namespace Nox.UI {
|
||||
}
|
||||
|
||||
public void Initialize() {
|
||||
var store = new GameLogStore(500);
|
||||
gameLogView = characterCreationReference.gameLogView;
|
||||
gameLogView.Initialize(store);
|
||||
inGameLogger = new InGameLogger(store, LogChannel.CharacterCreation);
|
||||
inGameLogger.Enable();
|
||||
|
||||
canStartCheck = () => {
|
||||
var canStart = characterCreationRequests is { Count: > 0 };
|
||||
characterCreationReference.startGameButton.interactable = canStart;
|
||||
};
|
||||
|
||||
characterCreationReference.startGameButton.interactable = false;
|
||||
characterCreationReference.startGameButton.onClick.AddListener(() => {
|
||||
if(characterCreationRequests == null || characterCreationRequests.Count == 0) {
|
||||
GlobalLogger.LogException("No character creation requests available, cannot start game, starting with a semi-random default", LogCategory.GameLogic);
|
||||
var randomIndex = UnityEngine.Random.Range(0, partySettings.testStarterCharacterSettings.Length-1);
|
||||
characterCreationRequests = new List<CharacterCreationRequest> { new () {
|
||||
Id = Guid.NewGuid(),
|
||||
Name = partySettings.testStarterCharacterSettings[randomIndex].name,
|
||||
Race = partySettings.testStarterCharacterSettings[randomIndex].race,
|
||||
Class = partySettings.testStarterCharacterSettings[randomIndex].@class,
|
||||
Role = CharacterRole.Protagonist,
|
||||
Attributes = partySettings.testStarterCharacterSettings[randomIndex].defaultEntityAttributes,
|
||||
Stats = partySettings.testStarterCharacterSettings[randomIndex].defaultEntityStats,
|
||||
Perks = partySettings.testStarterCharacterSettings[randomIndex].defaultPerksData,
|
||||
Modifiers = partySettings.testStarterCharacterSettings[randomIndex].defaultModifiersData
|
||||
} };
|
||||
return;
|
||||
}
|
||||
Hide();
|
||||
menuGameStateData.startGameRequests?.Invoke(PlayMode.Adventure);
|
||||
});
|
||||
characterCreationReference.backButton.onClick.AddListener(Hide);
|
||||
characterCreationReference.backButtonCenter.onClick.AddListener(Hide);
|
||||
characterCreationReference.acceptButton.onClick.AddListener(CreateParty);
|
||||
characterCreationReference.acceptButton.onClick.AddListener(() => {
|
||||
if(characterCreationRequests == null || characterCreationRequests.Count == 0) {
|
||||
GlobalLogger.LogWarning("No characters selected. Creating party from the test party definition sets", LogCategory.GameLogic);
|
||||
var randomIndex = UnityEngine.Random.Range(0, partySettings.testPartyDefinitionSets.Count - 1);
|
||||
var protagonist = partySettings.testPartyDefinitionSets[randomIndex].partyDefinition.Protagonist;
|
||||
characterCreationRequests = new List<CharacterCreationRequest> {
|
||||
new() {
|
||||
Id = Guid.NewGuid(),
|
||||
Name = protagonist.Name,
|
||||
Race = protagonist.Race,
|
||||
Class = protagonist.Class,
|
||||
Role = CharacterRole.Protagonist,
|
||||
Attributes = protagonist.Attributes,
|
||||
Stats = protagonist.Stats,
|
||||
Perks = protagonist.Perks,
|
||||
Modifiers = protagonist.Modifiers
|
||||
}
|
||||
};
|
||||
}
|
||||
CreateParty();
|
||||
canStartCheck.Invoke();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void CreateParty() {
|
||||
private void CreateParty() {
|
||||
var partyCreatorModel = new PartyCreatorModel(characterSystems.CharacterFactory, characterSystems.PartyFactory, characterCreationRequests, partySettings);
|
||||
var party = partyCreatorModel.CreatePartyForNewRun();
|
||||
gameDataState.ActiveParty = party;
|
||||
|
||||
inGameLogger.Log("Character Creation Results:");
|
||||
inGameLogger.Log($"Protagonist: {party.Protagonist.Name}", "FFBF00");
|
||||
inGameLogger.Log($"Protagonist Race: {party.Protagonist.Race}");
|
||||
inGameLogger.Log($"Protagonist Class: {party.Protagonist.Class}");
|
||||
inGameLogger.Log($"Companions: {party.Companions.Count}");
|
||||
inGameLogger.Log($"{party.Protagonist.Attributes}");
|
||||
inGameLogger.Log($"{party.Protagonist.Stats}");
|
||||
inGameLogger.Log($"{party.Protagonist.Perks}");
|
||||
inGameLogger.Log($"{party.Protagonist.Modifiers}");
|
||||
}
|
||||
|
||||
public void Tick() {
|
||||
@@ -73,6 +108,8 @@ namespace Nox.UI {
|
||||
public void Hide() {
|
||||
characterCreationReference.gameObject.SetActive(false);
|
||||
}
|
||||
public void Dispose() { }
|
||||
public void Dispose() {
|
||||
inGameLogger.Disable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,8 +75,10 @@ namespace Nox.UI {
|
||||
|
||||
public void Dispose() {
|
||||
characterCreationView?.Dispose();
|
||||
Object.Destroy(characterCreationReference.gameObject);
|
||||
charCreationHandle.Release();
|
||||
Object.Destroy(characterCreationReference?.gameObject);
|
||||
if (charCreationHandle.IsValid()) {
|
||||
charCreationHandle.Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user