Merge branch 'master' into main

This commit is contained in:
2023-07-08 17:12:43 +02:00
committed by GitHub
88 changed files with 14813 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 45139bbcbac1e2c4c86ff7094d67808e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "CharacterData", menuName = "Characters/Generate Character Data", order = 1)]
public class CharacterData : ScriptableObject
{
public string m_name;
public int m_charisma;
public int m_strength;
public int m_dexterity;
public int m_intelligence;
[Header("The index of the dialogue relates to what question it should link too.")]
public List<Dialogue> m_dialogueOptions;
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ddda90cbbcf3ea54e9105c3a5f0ac9a5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
[System.Serializable]
public class Dialogue
{
public string text;
}
public class QuestionData
{
public static string[] Questions = new string[]
{
"Who are you?",
"Tell me something about yourself.",
"What is your greatest accomplishment?",
"Where do you see yourself in five years?",
"What are your salary requirements?"
};
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d9ec0a6e2647c134ca75553cf8197bfe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,19 @@
using System.Collections.Generic;
using UnityEngine;
public class DialogueController : MonoBehaviour
{
[SerializeField] private DialoguePanel m_dialoguePanel;
[SerializeField] private List<CharacterData> m_characterDatas;
// DEBUG - Will need replacing with the character you selected.
private void Start()
{
DisplayCharacterText(m_characterDatas[0]);
}
public void DisplayCharacterText(CharacterData character)
{
m_dialoguePanel.Setup(character);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f2e7a099c6d0e484ba52b864ad6253c2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0bd66c3ec3a21b440be0d261ae3eaf95
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,109 @@
using System.Collections;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class DialoguePanel : MonoBehaviour
{
[SerializeField] private Transform m_questionHolder;
[SerializeField] private Button m_questionButton;
[SerializeField] private TMP_Text m_characterNameText;
[SerializeField] private TMP_Text m_characterText;
private const float TypingSpeed = 0.03f;
private CharacterData m_currentCharacter;
private bool m_skipped = false;
private void Awake()
{
PopulateQuestionButtons();
gameObject.SetActive(false);
}
// Sets the reference to the characterData to use.
public void Setup(CharacterData characterData)
{
Cleanup();
m_currentCharacter = characterData;
m_characterNameText.text = characterData.name;
// TODO: will this be changed with an introductory text?
m_characterText.text = "Select an option...";
gameObject.SetActive(true);
}
// Handles cleaing up for the next text.
private void Cleanup()
{
m_skipped = false;
m_characterText.text = "";
StopAllCoroutines();
}
// Populates the questions the player can ask the NPC.
private void PopulateQuestionButtons()
{
for (int i = 0; i < QuestionData.Questions.Length; i++)
{
var buttonObj = Instantiate(m_questionButton, m_questionHolder);
// Sets the button text to the question text.
var buttonText = buttonObj.GetComponentInChildren<TMP_Text>();
buttonText.text = QuestionData.Questions[i];
var button = buttonObj.GetComponent<Button>();
var index = i;
button.onClick.AddListener(() => OnQuestionButtonClicked(index));
button.gameObject.SetActive(true);
}
}
private IEnumerator DisplayText(string text)
{
// Hide the questions whilst the character is talking.
m_questionHolder.gameObject.SetActive(false);
foreach (char letter in text.ToCharArray())
{
if (m_skipped)
{
break;
}
m_characterText.text += letter;
yield return new WaitForSeconds(TypingSpeed);
}
m_skipped = true;
m_characterText.text = text;
// Re-enable the questions.
m_questionHolder.gameObject.SetActive(true);
}
// Handles displaying the correct dialogue for the question.
private void OnQuestionButtonClicked(int index)
{
//Debug.Log("Player picked option " + index);
Cleanup();
var dialogueOption = m_currentCharacter.m_dialogueOptions[index];
StartCoroutine(DisplayText(dialogueOption.text));
// TODO: we should update the sheet with this information.
}
// Callback from Unity on the skip button.
public void Action_SkipButtonClicked()
{
m_skipped = true;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 91eb3fe780abca14d9a12fb493b16fd6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: