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

View File

@@ -5,10 +5,16 @@ using UnityEngine;
public class DialogueController : MonoBehaviour
{
[SerializeField] private DialoguePanel m_dialoguePanel;
[SerializeField] private List<CharacterData> m_characterDatas;
// TODO:
// - Load the correct character based on the character who has been interacted with
// - Display the 5 question options and hook up their responses
// - Fill out a character sheet as you go along
// - Update the visual with the text
// 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

@@ -12,16 +12,18 @@ public class DialoguePanel : MonoBehaviour
[SerializeField] private TMP_Text m_characterNameText;
[SerializeField] private TMP_Text m_characterText;
private const float TypingSpeed = 0.02f;
private const float TypingSpeed = 0.03f;
private CharacterData m_currentCharacter;
private bool m_skipped = false;
private void Start()
private void Awake()
{
PopulateQuestionButtons();
gameObject.SetActive(false);
}
// Sets the reference to the characterData to use.
public void Setup(CharacterData characterData)
{
Cleanup();
@@ -31,8 +33,11 @@ public class DialoguePanel : MonoBehaviour
// 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;
@@ -53,7 +58,11 @@ public class DialoguePanel : MonoBehaviour
buttonText.text = QuestionData.Questions[i];
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.
private void OnQuestionButtonClicked(int index)
{
Debug.Log("Player picked option " + index);
//Debug.Log("Player picked option " + index);
Cleanup();
@@ -92,4 +101,10 @@ public class DialoguePanel : MonoBehaviour
// TODO: we should update the sheet with this information.
}
// Callback from Unity on the skip button.
public void Action_SkipButtonClicked()
{
m_skipped = true;
}
}