forked from Shardstone/trail-into-darkness
connected the default test settings
This commit is contained in:
@@ -86,6 +86,7 @@ namespace Nox.Core {
|
||||
|
||||
mainMenuView = new MainMenuView(assetHandle.Result, menuGameStateData, saveSystem, gameDataState, partySettings, characterSystems);
|
||||
mainMenuView.Initialize();
|
||||
mainMenuView.Show();
|
||||
IsGameStateInitialized = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Nox.Game {
|
||||
public List<PartyDefinitionSet> testPartyDefinitionSets;
|
||||
|
||||
[Header("Testing Party Definition Sets")]
|
||||
public StarterCharacterSettings testStarterCharacterSettings;
|
||||
public StarterCharacterSettings[] testStarterCharacterSettings;
|
||||
|
||||
private void OnValidate() {
|
||||
if(String.IsNullOrEmpty(testStartingSetId)) {
|
||||
@@ -37,7 +37,9 @@ 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);
|
||||
ApplyClassAndRacialBonuses(testingSet);
|
||||
foreach(var characterSetting in testStarterCharacterSettings) {
|
||||
ApplyClassAndRacialBonuses(testingSet, characterSetting);
|
||||
}
|
||||
}
|
||||
|
||||
if(partyDefinition.members.Count <= partyDefinition.maxPartySize) {
|
||||
@@ -47,12 +49,12 @@ namespace Nox.Game {
|
||||
partyDefinition.members.RemoveRange(partyDefinition.maxPartySize, partyDefinition.members.Count - partyDefinition.maxPartySize);
|
||||
}
|
||||
}
|
||||
private void ApplyClassAndRacialBonuses(PartyDefinitionSet testingSet) {
|
||||
private void ApplyClassAndRacialBonuses(PartyDefinitionSet testingSet, StarterCharacterSettings starterCharacterSettings) {
|
||||
var partyDefinition = testingSet.partyDefinition;
|
||||
foreach(var member in partyDefinition.members) {
|
||||
var baseSettings = testStarterCharacterSettings.defaultEntityAttributes;
|
||||
var classAttributes = testStarterCharacterSettings.classBonuses.AsValueEnumerable().FirstOrDefault(c => c.@class == member.Class)?.bonusAttributes;
|
||||
var racialAttributes = testStarterCharacterSettings.racialBonuses.AsValueEnumerable().FirstOrDefault(rb => rb.race == member.Race)?.bonusAttributes;
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace Nox.Game {
|
||||
[CreateAssetMenu(fileName = "CharacterBaseSettings", menuName = "Nox/Database/Entities/CharacterBaseSettings")]
|
||||
@@ -12,8 +13,17 @@ namespace Nox.Game {
|
||||
public ModifiersData defaultModifiersData;
|
||||
|
||||
[Header("General Racial Bonuses and Perks per Class")]
|
||||
public CharacterRace race;
|
||||
|
||||
public CharacterClass @class;
|
||||
public RacialBonuses [] racialBonuses;
|
||||
public ClassBonuses [] classBonuses;
|
||||
|
||||
|
||||
private void OnEnable() {
|
||||
race = (CharacterRace)Random.Range(0, Enum.GetNames(typeof(CharacterRace)).Length-1);
|
||||
@class = (CharacterClass)Random.Range(0, Enum.GetNames(typeof(CharacterClass)).Length-1);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
||||
@@ -166,8 +166,8 @@ namespace Nox.Game {
|
||||
inputActions.UI.PauseMenu.Disable();
|
||||
}
|
||||
public void Dispose() {
|
||||
cameraController.Dispose();
|
||||
partyMovementHandler.Dispose();
|
||||
cameraController?.Dispose();
|
||||
partyMovementHandler?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
using Jovian.Logger;
|
||||
using Jovian.SaveSystem;
|
||||
using Nox.Core;
|
||||
using Nox.Game;
|
||||
using Nox.Game.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Nox.UI {
|
||||
public class CharacterCreationView : IMenuView {
|
||||
public class CharacterCreationView : IGameLifecycle, IMenuView {
|
||||
public ISaveSystem SaveSystem { get; }
|
||||
private readonly CharacterCreationReference characterCreationReference;
|
||||
private readonly MenuGameStateData menuGameStateData;
|
||||
@@ -28,11 +30,32 @@ namespace Nox.UI {
|
||||
this.gameDataState = gameDataState;
|
||||
this.partySettings = partySettings;
|
||||
this.characterSystems = characterSystems;
|
||||
|
||||
}
|
||||
|
||||
public void Initialize() {
|
||||
characterCreationReference.startGameButton.onClick.AddListener(() => menuGameStateData.startGameRequests?.Invoke(PlayMode.Adventure));
|
||||
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);
|
||||
}
|
||||
|
||||
public void CreateParty() {
|
||||
@@ -42,16 +65,14 @@ namespace Nox.UI {
|
||||
}
|
||||
|
||||
public void Tick() {
|
||||
throw new System.NotImplementedException();
|
||||
return;
|
||||
}
|
||||
public void Show() {
|
||||
throw new System.NotImplementedException();
|
||||
characterCreationReference.gameObject.SetActive(true);
|
||||
}
|
||||
public void Hide() {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
public void Dispose() {
|
||||
throw new System.NotImplementedException();
|
||||
characterCreationReference.gameObject.SetActive(false);
|
||||
}
|
||||
public void Dispose() { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Nox.Core;
|
||||
using Nox.Game;
|
||||
using Jovian.SaveSystem;
|
||||
using Nox.Game.UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
@@ -9,7 +10,7 @@ namespace Nox.UI {
|
||||
/// <summary>
|
||||
/// Main menu interface class which is responsible for creating the main menu view and handling the main menu events
|
||||
/// </summary>
|
||||
public class MainMenuView : IGameLifecycle {
|
||||
public class MainMenuView : IGameLifecycle, IMenuView {
|
||||
private readonly MenuPrefabsContainer menuPrefabsContainer;
|
||||
private readonly MenuGameStateData menuGameStateData;
|
||||
private readonly ISaveSystem saveSystem;
|
||||
@@ -37,7 +38,7 @@ namespace Nox.UI {
|
||||
this.characterSystems = characterSystems;
|
||||
}
|
||||
public void Initialize() {
|
||||
if(mainMenuReference == null) {
|
||||
if(!mainMenuReference) {
|
||||
mainMenuReference = Addressables.InstantiateAsync(menuPrefabsContainer.mainMenuReference).WaitForCompletion().GetComponent<MainMenuReference>();
|
||||
}
|
||||
mainMenuReference.exitButton.onClick.AddListener(Application.Quit);
|
||||
@@ -49,18 +50,23 @@ namespace Nox.UI {
|
||||
if(hasSave) {
|
||||
mainMenuReference.continueButton.onClick.AddListener(() => menuGameStateData.continueGameRequest.Invoke());
|
||||
}
|
||||
Show();
|
||||
}
|
||||
|
||||
public void Show() {
|
||||
mainMenuReference.gameObject.SetActive(true);
|
||||
}
|
||||
public void Hide() {
|
||||
mainMenuReference.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void InitializeCharacterCreation() {
|
||||
charCreationHandle = Addressables.InstantiateAsync(menuPrefabsContainer.characterCreationReference);
|
||||
charCreationHandle.Task.ContinueWith(t => {
|
||||
if(t.IsFaulted) {
|
||||
Debug.LogError(t.Exception);
|
||||
}
|
||||
characterCreationReference =t.Result.GetComponent<CharacterCreationReference>();
|
||||
characterCreationView = new CharacterCreationView(characterCreationReference, menuGameStateData, saveSystem, gameDataState, partySettings, characterSystems);
|
||||
characterCreationView.Show();
|
||||
});
|
||||
var result = charCreationHandle.WaitForCompletion();
|
||||
characterCreationReference =result.GetComponent<CharacterCreationReference>();
|
||||
characterCreationView = new CharacterCreationView(characterCreationReference, menuGameStateData, saveSystem, gameDataState, partySettings, characterSystems);
|
||||
characterCreationView.Initialize();
|
||||
characterCreationView.Show();
|
||||
}
|
||||
|
||||
public void Tick() {
|
||||
|
||||
Reference in New Issue
Block a user