Josh
2 years ago
12 changed files with 1232 additions and 87 deletions
File diff suppressed because it is too large
@ -0,0 +1,7 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 91a4af9a6af9fc840b522128085513da |
||||
|
DefaultImporter: |
||||
|
externalObjects: {} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
@ -0,0 +1,51 @@ |
|||||
|
using System.Collections; |
||||
|
using System.Collections.Generic; |
||||
|
using UnityEngine; |
||||
|
using YamlDotNet.Serialization; |
||||
|
using YamlDotNet.Serialization.NamingConventions; |
||||
|
using System.IO; |
||||
|
|
||||
|
public class GameDataManager { |
||||
|
private static GameDataManager _instance = null; |
||||
|
|
||||
|
GameData _gameData = new GameData(); |
||||
|
TopicData _currentTopic = null; |
||||
|
|
||||
|
public GameDataManager() { |
||||
|
Deserializer deserializer = new Deserializer(); |
||||
|
string yamlText = File.ReadAllText(Application.dataPath + "/Resources/categories.yaml"); |
||||
|
_gameData = deserializer.Deserialize<GameData>(yamlText); |
||||
|
} |
||||
|
|
||||
|
public TopicData GetRandomTopicData() |
||||
|
{ |
||||
|
int topicIndex = Random.Range(0, _gameData.Topics.Count); |
||||
|
TopicData topicData = _gameData.Topics[topicIndex]; |
||||
|
_gameData.Topics.RemoveAt(topicIndex); |
||||
|
|
||||
|
return topicData; |
||||
|
} |
||||
|
|
||||
|
public CategoryData GetRandomCategoryData(TopicData topicData) |
||||
|
{ |
||||
|
int categoryIndex = Random.Range(0, topicData.Categories.Count); |
||||
|
CategoryData categoryData = topicData.Categories[categoryIndex]; |
||||
|
topicData.Categories.RemoveAt(categoryIndex); |
||||
|
|
||||
|
return categoryData; |
||||
|
} |
||||
|
|
||||
|
public static GameDataManager Instance |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
if (_instance == null) |
||||
|
{ |
||||
|
_instance =new GameDataManager(); |
||||
|
} |
||||
|
return _instance; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public TopicData CurrentTopic { get => _currentTopic; set => _currentTopic = value; } |
||||
|
} |
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 24a77fac7c75b804da62577166dfd0a4 |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
@ -0,0 +1,21 @@ |
|||||
|
using System.Collections; |
||||
|
using System.Collections.Generic; |
||||
|
using UnityEngine; |
||||
|
using UnityEngine.UI; |
||||
|
|
||||
|
public class TopicBox : MonoBehaviour |
||||
|
{ |
||||
|
public string Name; |
||||
|
public TopicData TopicData; |
||||
|
// Start is called before the first frame update
|
||||
|
void Start() |
||||
|
{ |
||||
|
transform.Find("Text").GetComponent<Text>().text = Name; |
||||
|
} |
||||
|
|
||||
|
// Update is called once per frame
|
||||
|
void Update() |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: ae3cf3ee1d381b544985a421e4ecbc64 |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
@ -0,0 +1,37 @@ |
|||||
|
using System.Collections; |
||||
|
using System.Collections.Generic; |
||||
|
using UnityEngine; |
||||
|
using UnityEngine.UI; |
||||
|
using UnityEngine.SceneManagement; |
||||
|
public class TopicSelect : MonoBehaviour |
||||
|
{ |
||||
|
[SerializeField] TopicBox _topic1Box; |
||||
|
[SerializeField] TopicBox _topic2Box; |
||||
|
[SerializeField] Text _title; |
||||
|
|
||||
|
int round = 1; |
||||
|
// Start is called before the first frame update
|
||||
|
void Awake() |
||||
|
{ |
||||
|
InitRound(); |
||||
|
} |
||||
|
|
||||
|
void InitRound() |
||||
|
{ |
||||
|
_title.text = "Round " + round + "\nPick a Topic!"; |
||||
|
_topic1Box.TopicData = GameDataManager.Instance.GetRandomTopicData(); |
||||
|
_topic2Box.TopicData = GameDataManager.Instance.GetRandomTopicData(); |
||||
|
_topic1Box.Name = _topic1Box.TopicData.Topic; |
||||
|
_topic2Box.Name = _topic2Box.TopicData.Topic; |
||||
|
} |
||||
|
|
||||
|
// Update is called once per frame
|
||||
|
void Update() |
||||
|
{ |
||||
|
if (Input.GetKeyDown(KeyCode.R)) |
||||
|
{ |
||||
|
SceneManager.LoadScene(SceneManager.GetActiveScene().name); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 0a576bc4a288add46aa64939a69432e5 |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
Loading…
Reference in new issue