usable with only 'e'
This commit is contained in:
parent
69cfb630d2
commit
7c953a442a
|
@ -14,26 +14,32 @@ public class NPCDialogue : MonoBehaviour
|
||||||
|
|
||||||
public float wordSpeed;
|
public float wordSpeed;
|
||||||
public bool playerIsClose;
|
public bool playerIsClose;
|
||||||
|
|
||||||
|
bool isTyping = false;
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
if(Input.GetKeyDown(KeyCode.E) && playerIsClose) {
|
if(Input.GetKeyDown(KeyCode.E) && playerIsClose && isTyping == false) {
|
||||||
if (dialoguePanel.activeInHierarchy) {
|
if (dialoguePanel.activeInHierarchy) {
|
||||||
zeroText();
|
// zeroText();
|
||||||
|
NextLine();
|
||||||
} else {
|
} else {
|
||||||
dialoguePanel.SetActive(true);
|
dialoguePanel.SetActive(true);
|
||||||
|
contButton.SetActive(false);
|
||||||
StartCoroutine(Typing());
|
StartCoroutine(Typing());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dialogueText.text == dialogue[index]) {
|
if(dialogueText.text == dialogue[index]) {
|
||||||
contButton.SetActive(true);
|
contButton.SetActive(true);
|
||||||
|
isTyping = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void zeroText() {
|
public void zeroText() {
|
||||||
dialogueText.text = "";
|
dialogueText.text = "";
|
||||||
index = 0;
|
index = 0;
|
||||||
|
isTyping = false;
|
||||||
dialoguePanel.SetActive(false);
|
dialoguePanel.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,11 +51,11 @@ public class NPCDialogue : MonoBehaviour
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NextLine () {
|
public void NextLine () {
|
||||||
|
|
||||||
contButton.SetActive(false);
|
contButton.SetActive(false);
|
||||||
if (index < dialogue.Length - 1) {
|
if (index < dialogue.Length - 1) {
|
||||||
index++;
|
index++;
|
||||||
dialogueText.text = "";
|
dialogueText.text = "";
|
||||||
|
isTyping = true;
|
||||||
StartCoroutine(Typing());
|
StartCoroutine(Typing());
|
||||||
} else {
|
} else {
|
||||||
zeroText();
|
zeroText();
|
||||||
|
|
Loading…
Reference in New Issue