forked from Shardstone/trail-into-darkness
added logger to character creation, default character setup, gameplay flow and textmeshpro stuff
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user