literally half of the game
This commit is contained in:
parent
1590b5faa6
commit
b842289076
77 changed files with 11904 additions and 72 deletions
|
|
@ -1,7 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class DialogueManager : MonoBehaviour
|
||||
{
|
||||
|
|
@ -21,31 +23,41 @@ public class DialogueManager : MonoBehaviour
|
|||
|
||||
#endregion
|
||||
|
||||
private class Choice
|
||||
{
|
||||
public string choiceName;
|
||||
public DialogueScript choiceScript;
|
||||
}
|
||||
[Header("Player")]
|
||||
public Player player;
|
||||
[Header("Dialogue Script")]
|
||||
[SerializeField] private DialogueScript currentDialogueScript;
|
||||
public DialogueScript currentDialogueScript;
|
||||
public DialogueScript[] allDialogue;
|
||||
public bool clickingDisabled = false;
|
||||
private int textProgress;
|
||||
public string[] scriptLines;
|
||||
[Header("UI")]
|
||||
public GameObject uiCanvas;
|
||||
public TextMeshProUGUI nameText;
|
||||
public TextMeshProUGUI dialogueText;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
StartDialogue(currentDialogueScript);
|
||||
}
|
||||
public Button choiceButton;
|
||||
public Transform choicePanel;
|
||||
|
||||
public void StartDialogue(DialogueScript scriptToShow)
|
||||
{
|
||||
uiCanvas.SetActive(true);
|
||||
textProgress = 0;
|
||||
currentDialogueScript = scriptToShow;
|
||||
scriptLines = currentDialogueScript.script.text.Split("\n");
|
||||
player.abilitiesDisabled = true;
|
||||
player.stalled = true;
|
||||
UpdateDialogue();
|
||||
}
|
||||
|
||||
private void ContinueDialogue()
|
||||
{
|
||||
textProgress++;
|
||||
clickingDisabled = false;
|
||||
UpdateDialogue();
|
||||
}
|
||||
|
||||
|
|
@ -70,7 +82,73 @@ public class DialogueManager : MonoBehaviour
|
|||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case "TASK": //must use 3 words on these.
|
||||
string taskModifier = words[1].ToUpper();
|
||||
if (taskModifier == "ADD")
|
||||
{
|
||||
foreach (Task task in TaskManager.instance.taskList)
|
||||
{
|
||||
if (string.Equals(task.taskID, words[2], StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
TaskManager.instance.AddTask(task);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ContinueDialogue();
|
||||
break;
|
||||
case "ITEM":
|
||||
string itemModifier = words[1].ToUpper();
|
||||
if (itemModifier == "ADD")
|
||||
{
|
||||
foreach (Item item in InventoryManager.instance.itemList)
|
||||
{
|
||||
if (string.Equals(item.itemName, words[2], StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
InventoryManager.instance.AddItem(item, Int32.Parse(words[3]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ContinueDialogue();
|
||||
break;
|
||||
case "#":
|
||||
ContinueDialogue();
|
||||
break;
|
||||
case "CHOICE":
|
||||
clickingDisabled = true;
|
||||
List<Choice> choices = new();
|
||||
for (int i = 1; i < words.Length; i++)
|
||||
{
|
||||
Choice newChoice = new Choice();
|
||||
string[] c = words[i].Split(":");
|
||||
newChoice.choiceName = c[0];
|
||||
foreach (DialogueScript dialogueScript in allDialogue)
|
||||
{
|
||||
if (string.Equals(c[1], dialogueScript.dialogueID, StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
newChoice.choiceScript = dialogueScript; //this is the worst way ever to find a matching id but WHATEVER
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!newChoice.choiceScript)
|
||||
{
|
||||
Debug.LogWarning("BRO WTF THERE IS NO MATCHING ID!!!");
|
||||
}
|
||||
else
|
||||
{
|
||||
choices.Add(newChoice);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Choice possibleChoice in choices)
|
||||
{
|
||||
Button newChoiceButton = Instantiate(choiceButton, choicePanel);
|
||||
newChoiceButton.onClick.AddListener(() => StartDialogue(possibleChoice.choiceScript));
|
||||
newChoiceButton.GetComponentInChildren<TextMeshProUGUI>().text = possibleChoice.choiceName;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -80,6 +158,8 @@ public class DialogueManager : MonoBehaviour
|
|||
uiCanvas.SetActive(false);
|
||||
currentDialogueScript = null;
|
||||
scriptLines = null;
|
||||
player.abilitiesDisabled = false;
|
||||
player.stalled = false;
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue