//Executing commands found in txt files: //=================================================== private void executeMetaCommand(string metaCommand) { bool isValue = false; string command = ""; string value = ""; for (int i = 0; i < metaCommand.Length; i++) { if (metaCommand [i] == ':') { isValue = true; } else { if (isValue == false) { command += metaCommand [i]; } if (isValue == true) { value += metaCommand [i]; } } } Debug.Log("Command: " + command); Debug.Log("Value: " + value); //if - if else routing: Executing according to command! (If recognizable) //=================================================== if (command == "timeout") { float time = 0; if (float.TryParse(value, out time)) { //dialogAusgabe.text = currentLine; Debug.Log("Timout initiated by dialog script!"); StartCoroutine(timeoutFor(time)); } else { Debug.Log("Dialog command 'timeout' failed!"); } dialogAusgabe.text = currentLine; } //=================================================== else if (command == "playsound") { Debug.Log("Playsound command executing! ->filename: " + value); loadAndPlaySoundFile(value, unterverzeichnis); } //=================================================== else if (command == "unlockExit") { if (currentExitDoor != null) { currentExitDoor.setIsLocked(); Debug.Log("Exit unlocked through dialog script!"); } } //=================================================== else if (command == "choice") { Debug.Log("...executing choice command now..."); string content = "Choose: \n"; //dialogAusgabe.text = content; string currentChoice = ""; bool isChoice = false; int choiceCounter = 0; for (int i = 0; i < value.Length; i++) { if (isChoice == true) { if (value [i] == '"') { isChoice = false; globalChoiceCount++; // How many choices are there? choiceCounter++; Debug.Log("Choice: " + currentChoice); content += choiceCounter + ": " + currentChoice + "\n"; currentChoice = ""; } else { currentChoice += value [i]; } } else { if (value [i] == '"') { isChoice = true; } } } currentLine += content; } //=================================================== else if (command == "waitForAnswer") { dialogAusgabe.text = currentLine; currentLine = ""; waitingForAnswer = true; } //=================================================== else if (command == "jumpTo") { Debug.Log("JumpTo command active!"); for (int i = 0; i < value.Length; i++) { if (value [i] == '#') { jumpToString += AnswerID; } else { jumpToString += value [i]; } } Debug.Log("JumptToString has been set to: " + jumpToString); } //=================================================== else if (command == "freezeFor") { int time = 0; if (int.TryParse(value, out time)) { player.setFreezeFor(time); Debug.Log("Player frozen through dialog script!"); } else { Debug.Log("Dialog command 'freezeFor' failed!"); } } //=================================================== else if (command == "freeze") { player.freeze(); } //=================================================== else if (command == "unfreeze") { player.unfreeze(); } //=================================================== else if (command == "waitForEnter") { dialogAusgabe.text = currentLine; currentLine = ""; waitingForEnter = true; } //=================================================== else if (command == "movePlayerTo") { bool check = false; float x = 0; float y = 0; string currentValuePart = ""; for (int i = 0; i < value.Length; i++) { if (check == false) { if (value [i] != ',') { currentValuePart += value [i]; } else { Debug.Log("Current valuePart x: " + currentValuePart); if (float.TryParse(currentValuePart, out x)) { //dialogAusgabe.text = currentLine; Debug.Log("x initiated by dialog script!"); } else { Debug.Log("Dialog command 'movePlayerTo' failed!"); } currentValuePart = ""; check = true; } } else { if (value [i] <= '9') { currentValuePart += value [i]; } } } Debug.Log("Current valuePart y: " + currentValuePart); if (float.TryParse(currentValuePart, out y)) { //dialogAusgabe.text = currentLine; Debug.Log("y initiated by dialog script!"); } else { Debug.Log("Dialog command 'movePlayerTo' failed!"); } player.moveTo(x, y); currentValuePart = ""; check = true; } //=================================================== else if (command == "movePlayerRelative") { bool check = false; float x = 0; float y = 0; string currentValuePart = ""; for (int i = 0; i < value.Length; i++) { if (check == false) { if (value [i] != ',') { currentValuePart += value [i]; } else { Debug.Log("Current valuePart x: " + currentValuePart); if (float.TryParse(currentValuePart, out x)) { //dialogAusgabe.text = currentLine; Debug.Log("x initiated by dialog script!"); } else { Debug.Log("Dialog command 'movePlayerTo' failed!"); } currentValuePart = ""; check = true; } } else { if (value [i] <= '9') { currentValuePart += value [i]; } } } Debug.Log("Current valuePart y: " + currentValuePart); if (float.TryParse(currentValuePart, out y)) { //dialogAusgabe.text = currentLine; Debug.Log("y initiated by dialog script!"); } else { Debug.Log("Dialog command 'movePlayerRelative' failed!"); } Debug.Log("Player is being moved by vector: " + x + ", " + y + ";"); player.moveRelative(x, y); } //=================================================== else if (command == "returnMessage") { dialogOutput = value; } //=================================================== else if (command == "enableDisplay") { display.enabled = true; } //=================================================== else if (command == "disableDisplay") { display.enabled = false; } else if (command == "exitDialog") { Debug.Log("Dialog has been ended by meta command! dialog index: " + dialogIndex); rawDialog = ""; //Interpretation is done! rawDialog empty now! display.enabled = false; dialogAusgabe.text = ""; currentLine = ""; dialogIndex = 0; dialogtxt = ""; } else if (command == jumpToString) { jumpToString = ""; } }