forked from Shardstone/trail-into-darkness
added the charater creation view base functionality
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
using Jovian.InspectorTools;
|
|
||||||
using Jovian.Logger;
|
using Jovian.Logger;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ using TMPro;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class CharacterCreationReference : MonoBehaviour {
|
namespace Nox.UI {
|
||||||
|
public class CharacterCreationReference : MonoBehaviour {
|
||||||
public Canvas canvas;
|
public Canvas canvas;
|
||||||
|
|
||||||
//top
|
//top
|
||||||
public Button backButton;
|
public Button backButton;
|
||||||
public Button settingsButton;
|
public Button settingsButton;
|
||||||
@@ -25,4 +27,5 @@ public class CharacterCreationReference : MonoBehaviour {
|
|||||||
public Button portraitSelectionRightButton;
|
public Button portraitSelectionRightButton;
|
||||||
public TMP_InputField nameInputField;
|
public TMP_InputField nameInputField;
|
||||||
public Button startGameButton;
|
public Button startGameButton;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
29
Assets/Code/GameState/UI/CharacterCreationView.cs
Normal file
29
Assets/Code/GameState/UI/CharacterCreationView.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using Nox.Core;
|
||||||
|
using Nox.Game.UI;
|
||||||
|
|
||||||
|
namespace Nox.UI {
|
||||||
|
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
|
||||||
|
// party creation data/system,
|
||||||
|
public CharacterCreationView(CharacterCreationReference characterCreationReference, MenuGameStateData menuGameStateData) {
|
||||||
|
characterCreationReference.startGameButton.onClick.AddListener(() => menuGameStateData.startGameRequests?.Invoke(PlayMode.Adventure));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Initialize() {
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Tick() {
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
public void Show() {
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
public void Hide() {
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
public void Dispose() {
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Code/GameState/UI/CharacterCreationView.cs.meta
Normal file
3
Assets/Code/GameState/UI/CharacterCreationView.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 555173dcbeb04c44b6f02f04fb1cb762
|
||||||
|
timeCreated: 1775381234
|
||||||
@@ -3,6 +3,7 @@ using Nox.Game;
|
|||||||
using Jovian.SaveSystem;
|
using Jovian.SaveSystem;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.AddressableAssets;
|
using UnityEngine.AddressableAssets;
|
||||||
|
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||||
using PlayMode = Nox.Core.PlayMode;
|
using PlayMode = Nox.Core.PlayMode;
|
||||||
|
|
||||||
namespace Nox.UI {
|
namespace Nox.UI {
|
||||||
@@ -14,6 +15,10 @@ namespace Nox.UI {
|
|||||||
private readonly MenuGameStateData menuGameStateData;
|
private readonly MenuGameStateData menuGameStateData;
|
||||||
private readonly ISaveSystem saveSystem;
|
private readonly ISaveSystem saveSystem;
|
||||||
private MainMenuReference mainMenuReference;
|
private MainMenuReference mainMenuReference;
|
||||||
|
private CharacterCreationReference characterCreationReference;
|
||||||
|
private CharacterCreationView characterCreationView;
|
||||||
|
private AsyncOperationHandle<GameObject> charCreationHandle;
|
||||||
|
|
||||||
public MainMenuView(MenuPrefabsContainer menuPrefabsContainer, MenuGameStateData menuGameStateData, ISaveSystem saveSystem) {
|
public MainMenuView(MenuPrefabsContainer menuPrefabsContainer, MenuGameStateData menuGameStateData, ISaveSystem saveSystem) {
|
||||||
this.menuPrefabsContainer = menuPrefabsContainer;
|
this.menuPrefabsContainer = menuPrefabsContainer;
|
||||||
this.menuGameStateData = menuGameStateData;
|
this.menuGameStateData = menuGameStateData;
|
||||||
@@ -25,7 +30,7 @@ namespace Nox.UI {
|
|||||||
}
|
}
|
||||||
mainMenuReference.exitButton.onClick.AddListener(Application.Quit);
|
mainMenuReference.exitButton.onClick.AddListener(Application.Quit);
|
||||||
mainMenuReference.optionsButton.onClick.AddListener(() => {/* options logic here */});
|
mainMenuReference.optionsButton.onClick.AddListener(() => {/* options logic here */});
|
||||||
mainMenuReference.newGameButton.onClick.AddListener(() => menuGameStateData.startGameRequests?.Invoke(PlayMode.Adventure));
|
mainMenuReference.newGameButton.onClick.AddListener(InitializeCharacterCreation);
|
||||||
|
|
||||||
bool hasSave = saveSystem.HasAnySaves();
|
bool hasSave = saveSystem.HasAnySaves();
|
||||||
mainMenuReference.continueButton.gameObject.SetActive(hasSave);
|
mainMenuReference.continueButton.gameObject.SetActive(hasSave);
|
||||||
@@ -33,8 +38,27 @@ namespace Nox.UI {
|
|||||||
mainMenuReference.continueButton.onClick.AddListener(() => menuGameStateData.continueGameRequest.Invoke());
|
mainMenuReference.continueButton.onClick.AddListener(() => menuGameStateData.continueGameRequest.Invoke());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Tick() { }
|
|
||||||
|
public 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);
|
||||||
|
characterCreationView.Show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Tick() {
|
||||||
|
characterCreationView?.Tick();
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
|
characterCreationView?.Dispose();
|
||||||
|
Object.Destroy(characterCreationReference.gameObject);
|
||||||
|
charCreationHandle.Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
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")]
|
||||||
public class MenuPrefabsContainer : ScriptableObject {
|
public class MenuPrefabsContainer : ScriptableObject {
|
||||||
public AssetReference mainMenuReference;
|
public AssetReference mainMenuReference;
|
||||||
|
public CharacterCreationReference characterCreationReference;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -342,7 +342,7 @@ GameObject:
|
|||||||
- component: {fileID: 3618468963710046005}
|
- component: {fileID: 3618468963710046005}
|
||||||
- component: {fileID: 8834560166594506199}
|
- component: {fileID: 8834560166594506199}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: CharacterCreationView
|
m_Name: CharacterCreationReference
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
Reference in New Issue
Block a user