void ParseAction(string statement)
 {
     char[] delims = { ' ', ':' };
     string[] arguments = statement.Split(delims);
     if (arguments.Length != 2) {
         Debug.Log("DialogueController Warning - Parse error at statement \"" + statement + "\" - %do must have only one argument");
         return;
     }
     // First token is 'do'. Evaluate the action
     switch (arguments[1]) {
         case "highlightleft":
             if (leftCharacter == null) {
                 Debug.Log("DialogueController Warning - Parse error at statement \"" + statement + "\" - Trying to highlight an unset character");
                 return;
             }
             speakerName.text = leftCharacter.name;
             speakerName.alignment = TextAnchor.MiddleLeft;
             leftSpeaker.color = normalColor;
             speakerNameBox.transform.position = leftNameTransform.position;
             if (useColoredHighlight) {
                 rightSpeaker.color = shadowedColor;
             }
             break;
         case "highlightright":
             if (rightCharacter == null) {
                 Debug.Log("DialogueController Warning - Parse error at statement \"" + statement + "\" - Trying to highlight an unset character");
                 return;
             }
             speakerName.text = rightCharacter.name;
             speakerName.alignment = TextAnchor.MiddleRight;
             speakerNameBox.transform.position = rightNameTransform.position;
             rightSpeaker.color = normalColor;
             if (useColoredHighlight) {
                 leftSpeaker.color = shadowedColor;
             }
             break;
         case "hideleft":
             leftCharacter = null;
             leftSpeaker.sprite = null;
             leftSpeaker.GetComponent<RectTransform>().sizeDelta = new Vector2(0, 0);
             break;
         case "hideright":
             rightCharacter = null;
             rightSpeaker.sprite = null;
             rightSpeaker.GetComponent<RectTransform>().sizeDelta = new Vector2(0, 0);
             break;
         case "noleftsprite":
             noSprite = true;
             leftSpeaker.gameObject.SetActive(false);
             break;
         case "norightsprite":
             noSprite = true;
             rightSpeaker.gameObject.SetActive(false);
             break;
         case "autoskipnext":
             autoSkip = true;
             break;
         default:
             Debug.Log("DialogueController Warning - Parse error at statement \"" + statement + "\" - Unknown action");
             break;
     }
 }
 void ParseAssignment(string statement)
 {
     char[] delims = { ' ', '=' };
     string[] arguments = statement.Split(delims);
     if (arguments.Length != 2) {
         Debug.Log("DialogueController Warning - Parse error at statement \"" + statement + "\" - Invalid number of arguments");
         return;
     }
     // Evaluate the assignee
     switch (arguments[0]) {
         case "leftspeaker":
             leftCharacter = GameData.instance.GetCharacterData(arguments[1]);
             if (leftCharacter == null) {
                 Debug.Log("DialogueController Warning - Parse error at statement \"" + statement + "\" - Invalid speaker");
                 return;
             }
             leftSpeaker.sprite = leftCharacter.defaultSprite;
             speakerName.text = leftCharacter.name;
             speakerName.alignment = TextAnchor.MiddleLeft;
             leftSpeaker.SetNativeSize();
             leftSpeaker.GetComponent<RectTransform>().sizeDelta *= spriteScale;
             leftSpeaker.color = normalColor;
             speakerNameBox.transform.position = leftNameTransform.position;
             if (useColoredHighlight) {
                 rightSpeaker.color = shadowedColor;
             }
             break;
         case "rightspeaker":
             rightCharacter = GameData.instance.GetCharacterData(arguments[1]);
             if (rightCharacter == null) {
                 Debug.Log("DialogueController Warning - Parse error at statement \"" + statement + "\" - Invalid speaker");
                 return;
             }
             rightSpeaker.sprite = rightCharacter.defaultSprite;
             speakerName.text = rightCharacter.name;
             speakerName.alignment = TextAnchor.MiddleRight;
             rightSpeaker.SetNativeSize();
             rightSpeaker.GetComponent<RectTransform>().sizeDelta *= spriteScale;
             rightSpeaker.color = normalColor;
             speakerNameBox.transform.position = rightNameTransform.position;
             if (useColoredHighlight) {
                 leftSpeaker.color = shadowedColor;
             }
             break;
         case "frameinterval":
             try {
                 int newFrameInterval = int.Parse(arguments[1]);
                 if (newFrameInterval < 0) {
                     Debug.Log("DialogueController Warning - Parse error at statement \"" + statement + "\" - Frame interval cannot be negative");
                     return;
                 }
                 frameInterval = newFrameInterval;
             }
             catch (System.Exception e) {
                 Debug.Log("DialogueController Warning - Parse error at statement \"" + statement + "\" - Invalid frame interval");
             }
             break;
         case "intervaltime":
             try {
                 int newIntervalTime = int.Parse(arguments[1]);
                 if (newIntervalTime < 0) {
                     Debug.Log("DialogueController Warning - Parse error at statement \"" + statement + "\" - Interval time cannot be negative");
                     return;
                 }
                 intervalTime = newIntervalTime;
             }
             catch (System.Exception e) {
                 Debug.Log("DialogueController Warning - Parse error at statement \"" + statement + "\" - Invalid interval time");
             }
             break;
         case "halfintervaltime":
             try {
                 int newHalfIntervalTime = int.Parse(arguments[1]);
                 if (newHalfIntervalTime < 0) {
                     Debug.Log("DialogueController Warning - Parse error at statement \"" + statement + "\" - Half interval time cannot be negative");
                     return;
                 }
                 halfIntervalTime = newHalfIntervalTime;
             }
             catch (System.Exception e) {
                 Debug.Log("DialogueController Warning - Parse error at statement \"" + statement + "\" - Invalid half interval time");
             }
             break;
         case "delay":
             try {
                 int newDelay = int.Parse(arguments[1]);
                 if (newDelay < 0) {
                     Debug.Log("DialogueController Warning - Parse error at statement \"" + statement + "\" - Delay cannot be negative");
                     return;
                 }
                 frameCounter = newDelay;
             }
             catch (System.Exception e) {
                 Debug.Log("DialogueController Warning - Parse error at statement \"" + statement + "\" - Invalid delay");
             }
             break;
         case "mute":
             try {
                 bool newMuted = bool.Parse(arguments[1]);
                 muted = newMuted;
             }
             catch (System.Exception e) {
                 Debug.Log("DialogueController Warning - Parse error at statement \"" + statement + "\" - Invalid mute boolean value");
             }
             break;
         case "usecoloredhighlight":
             try {
                 bool newUseColoredHighlight = bool.Parse(arguments[1]);
                 useColoredHighlight = newUseColoredHighlight;
                 if (!useColoredHighlight) {
                     leftSpeaker.color = normalColor;
                     rightSpeaker.color = normalColor;
                 }
             }
             catch (System.Exception e) {
                 Debug.Log("DialogueController Warning - Parse error at statement \"" + statement + "\" - Invalid useColoredHighlight boolean value");
             }
             break;
         case "alwaysautoskip":
             try {
                 bool newAlwaysAutoSkip = bool.Parse(arguments[1]);
                 alwaysAutoSkip = newAlwaysAutoSkip;
                 autoSkip = alwaysAutoSkip;
             }
             catch (System.Exception e) {
                 Debug.Log("DialogueController Warning - Parse error at statement \"" + statement + "\" - Invalid alwaysAutoSkip boolean value");
             }
             break;
         case "autoskipdelay":
             try {
                 int newAutoSkipDelay = int.Parse(arguments[1]);
                 if (newAutoSkipDelay < 0) {
                     Debug.Log("DialogueController Warning - Parse error at statement \"" + statement + "\" - autoSkipDelay cannot be negative");
                     return;
                 }
                 autoSkipDelay = newAutoSkipDelay;
             }
             catch (System.Exception e) {
                 Debug.Log("DialogueController Warning - Parse error at statement \"" + statement + "\" - Invalid autoSkipDelay");
             }
             break;
         default:
             Debug.Log("DialogueController Warning - Parse error at statement \"" + statement + "\" - Invalid assignee");
             break;
     }
 }
    void Hide()
    {
        isRunning = false;
        isReady = false;
        animator.SetBool("running", false);
        GetComponent<CanvasGroup>().blocksRaycasts = false;

        leftCharacter = null;
        leftSpeaker.sprite = null;
        leftSpeaker.GetComponent<RectTransform>().sizeDelta = new Vector2(0, 0);
        rightCharacter = null;
        rightSpeaker.sprite = null;
        rightSpeaker.GetComponent<RectTransform>().sizeDelta = new Vector2(0, 0);

        speakerName.text = "";
        dialogue.text = "";
    }