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 System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -2,27 +2,30 @@ using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class CharacterCreationReference : MonoBehaviour {
|
||||
public Canvas canvas;
|
||||
//top
|
||||
public Button backButton;
|
||||
public Button settingsButton;
|
||||
namespace Nox.UI {
|
||||
public class CharacterCreationReference : MonoBehaviour {
|
||||
public Canvas canvas;
|
||||
|
||||
//left
|
||||
public TMP_Dropdown raceDropdown;
|
||||
public TMP_Dropdown classDropdown;
|
||||
public TMP_Dropdown perksDropdown;
|
||||
public AttributeReference[] attributeReference;
|
||||
public StatReference[] statReference;
|
||||
//top
|
||||
public Button backButton;
|
||||
public Button settingsButton;
|
||||
|
||||
//center
|
||||
public Button backButtonCenter;
|
||||
public Button acceptButton;
|
||||
//left
|
||||
public TMP_Dropdown raceDropdown;
|
||||
public TMP_Dropdown classDropdown;
|
||||
public TMP_Dropdown perksDropdown;
|
||||
public AttributeReference[] attributeReference;
|
||||
public StatReference[] statReference;
|
||||
|
||||
//right
|
||||
public Image portraitImage;
|
||||
public Button portraitSelectionLeftButton;
|
||||
public Button portraitSelectionRightButton;
|
||||
public TMP_InputField nameInputField;
|
||||
public Button startGameButton;
|
||||
//center
|
||||
public Button backButtonCenter;
|
||||
public Button acceptButton;
|
||||
|
||||
//right
|
||||
public Image portraitImage;
|
||||
public Button portraitSelectionLeftButton;
|
||||
public Button portraitSelectionRightButton;
|
||||
public TMP_InputField nameInputField;
|
||||
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 UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
using PlayMode = Nox.Core.PlayMode;
|
||||
|
||||
namespace Nox.UI {
|
||||
@@ -14,6 +15,10 @@ namespace Nox.UI {
|
||||
private readonly MenuGameStateData menuGameStateData;
|
||||
private readonly ISaveSystem saveSystem;
|
||||
private MainMenuReference mainMenuReference;
|
||||
private CharacterCreationReference characterCreationReference;
|
||||
private CharacterCreationView characterCreationView;
|
||||
private AsyncOperationHandle<GameObject> charCreationHandle;
|
||||
|
||||
public MainMenuView(MenuPrefabsContainer menuPrefabsContainer, MenuGameStateData menuGameStateData, ISaveSystem saveSystem) {
|
||||
this.menuPrefabsContainer = menuPrefabsContainer;
|
||||
this.menuGameStateData = menuGameStateData;
|
||||
@@ -25,7 +30,7 @@ namespace Nox.UI {
|
||||
}
|
||||
mainMenuReference.exitButton.onClick.AddListener(Application.Quit);
|
||||
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();
|
||||
mainMenuReference.continueButton.gameObject.SetActive(hasSave);
|
||||
@@ -33,8 +38,27 @@ namespace Nox.UI {
|
||||
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() {
|
||||
characterCreationView?.Dispose();
|
||||
Object.Destroy(characterCreationReference.gameObject);
|
||||
charCreationHandle.Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.ResourceManagement.ResourceLocations;
|
||||
|
||||
namespace Nox.UI {
|
||||
[CreateAssetMenu(fileName = "MenuPrefabsContainer", menuName = "Nox/Database/UI/MenuPrefabContainer")]
|
||||
public class MenuPrefabsContainer : ScriptableObject {
|
||||
public AssetReference mainMenuReference;
|
||||
public CharacterCreationReference characterCreationReference;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ GameObject:
|
||||
- component: {fileID: 3618468963710046005}
|
||||
- component: {fileID: 8834560166594506199}
|
||||
m_Layer: 5
|
||||
m_Name: CharacterCreationView
|
||||
m_Name: CharacterCreationReference
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
Reference in New Issue
Block a user