Setup test character and triggered dialogue

This will need adjusting to work with the click/input
This commit is contained in:
Amaan Shawkath
2023-07-08 14:26:00 +01:00
parent 0c2d335bb5
commit 293dbbec2c
5 changed files with 75 additions and 9 deletions

8
Assets/Data.meta Normal file
View File

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

29
Assets/Data/Derk.asset Normal file
View File

@@ -0,0 +1,29 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ddda90cbbcf3ea54e9105c3a5f0ac9a5, type: 3}
m_Name: Derk
m_EditorClassIdentifier:
m_name: Derk
m_charisma: 5
m_strength: 5
m_dexterity: 3
m_intelligence: 5
m_money: 5
m_dialogueOptions:
- text: "Name\u2019s Derk"
- text: "Man, I just want to work, y\u2019know? Give me a task and I\u2019ll do
it, no problem for old Derk."
- text: "This mornin\u2019 I helped an old lady get into one of those high speed
trains. They always say Derk the jerk, but no one ever says \u201CWow, what
a nice guy\u201D. "
- text: "\u2026 (drools)"
- text: I just want money, whatevs

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fe5c0edf44ede8146ac344d9538dafc6
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -5,10 +5,16 @@ using UnityEngine;
public class DialogueController : MonoBehaviour public class DialogueController : MonoBehaviour
{ {
[SerializeField] private DialoguePanel m_dialoguePanel; [SerializeField] private DialoguePanel m_dialoguePanel;
[SerializeField] private List<CharacterData> m_characterDatas;
// TODO: // DEBUG - Will need replacing with the character you selected.
// - Load the correct character based on the character who has been interacted with private void Start()
// - Display the 5 question options and hook up their responses {
// - Fill out a character sheet as you go along DisplayCharacterText(m_characterDatas[0]);
// - Update the visual with the text }
public void DisplayCharacterText(CharacterData character)
{
m_dialoguePanel.Setup(character);
}
} }

View File

@@ -12,16 +12,18 @@ public class DialoguePanel : MonoBehaviour
[SerializeField] private TMP_Text m_characterNameText; [SerializeField] private TMP_Text m_characterNameText;
[SerializeField] private TMP_Text m_characterText; [SerializeField] private TMP_Text m_characterText;
private const float TypingSpeed = 0.02f; private const float TypingSpeed = 0.03f;
private CharacterData m_currentCharacter; private CharacterData m_currentCharacter;
private bool m_skipped = false; private bool m_skipped = false;
private void Start() private void Awake()
{ {
PopulateQuestionButtons(); PopulateQuestionButtons();
gameObject.SetActive(false);
} }
// Sets the reference to the characterData to use.
public void Setup(CharacterData characterData) public void Setup(CharacterData characterData)
{ {
Cleanup(); Cleanup();
@@ -31,8 +33,11 @@ public class DialoguePanel : MonoBehaviour
// TODO: will this be changed with an introductory text? // TODO: will this be changed with an introductory text?
m_characterText.text = "Select an option..."; m_characterText.text = "Select an option...";
gameObject.SetActive(true);
} }
// Handles cleaing up for the next text.
private void Cleanup() private void Cleanup()
{ {
m_skipped = false; m_skipped = false;
@@ -53,7 +58,11 @@ public class DialoguePanel : MonoBehaviour
buttonText.text = QuestionData.Questions[i]; buttonText.text = QuestionData.Questions[i];
var button = buttonObj.GetComponent<Button>(); var button = buttonObj.GetComponent<Button>();
button.onClick.AddListener(() => OnQuestionButtonClicked(i));
var index = i;
button.onClick.AddListener(() => OnQuestionButtonClicked(index));
button.gameObject.SetActive(true);
} }
} }
@@ -83,7 +92,7 @@ public class DialoguePanel : MonoBehaviour
// Handles displaying the correct dialogue for the question. // Handles displaying the correct dialogue for the question.
private void OnQuestionButtonClicked(int index) private void OnQuestionButtonClicked(int index)
{ {
Debug.Log("Player picked option " + index); //Debug.Log("Player picked option " + index);
Cleanup(); Cleanup();
@@ -92,4 +101,10 @@ public class DialoguePanel : MonoBehaviour
// TODO: we should update the sheet with this information. // TODO: we should update the sheet with this information.
} }
// Callback from Unity on the skip button.
public void Action_SkipButtonClicked()
{
m_skipped = true;
}
} }