// Update is called once per frame void Update() { if (isActive) { dialogManager.setRoom("room_2"); player.setRoom("room_2"); switch (eventCounter) { case 0: dialogManager.setDialog("conversationWithFire.txt"); eventCounter++; break; case 1: //Debug.Log ("Dialog still running: "+dialogManager.isActive()); if (!dialogManager.isActive()) { eventCounter++; } break; case 2: Debug.Log("I'm here :>"); /*dialogManager.setDialog ("areYouAngry.txt"); * if(dialogManager.getDialogOutput()=="selfIsCalm"){ * eventCounter++; * player.unfreeze (); * }*/ eventCounter++; break; case 3: exitDoor.setIsLocked(); roomSolved = true; eventCounter++; break; case 4: break; } if (roomSolved) { if (exitDoor.isLocked()) { //File.Delete("dialog/room_2/ItemHolder.txt"); r2Dark = GameObject.Find("raum2D").GetComponent <SpriteRenderer>(); r2Dark.enabled = true; r1Dark = GameObject.Find("raum3D").GetComponent <SpriteRenderer>(); r1Dark.enabled = false; endAndProceed(); } } } }
// Update is called once per frame void Update() { if (mudSwitch.isSwitchedOn()) { mud.fill(); colliderE.enabled = false; } if (!mudSwitch.isSwitchedOn()) { mud.drain(); colliderE.enabled = true; //audio.GetComponent<AudioSource> ().Stop (); } if (mud.isFilling()) { player.setSpeed(drainedPlayerSpeed(player.getX(), player.getY(), defaultPlayerSpeed)); audio.GetComponent <AudioSource> ().Play(); } if (isActive) { dialogManager.setRoom("room_4"); player.setRoom("room_4"); switch (eventCounter) { case 0: if (mudSwitch.isSwitchedOn()) { eventCounter++; } break; case 1: exitDoor.setIsLocked(); //exitDoor locked=false!! (unlock) roomSolved = true; eventCounter++; break; case 2: if (distanceToEscape > 10 && distanceToEscape < 15) { dialogManager.setDialog("dialog1.txt"); eventCounter++; } break; case 3: if (distanceToEscape > 7 && distanceToEscape < 10) { dialogManager.setDialog("dialog2.txt"); eventCounter++; } break; case 4: if (distanceToEscape > 5 && distanceToEscape < 7) { dialogManager.setDialog("dialog3.txt"); eventCounter++; } break; case 5: if (distanceToEscape > 4 && distanceToEscape < 5) { dialogManager.setDialog("dialog4.txt"); eventCounter++; } break; case 6: if (distanceToEscape > 3 && distanceToEscape < 4) { dialogManager.setDialog("dialog5.txt"); eventCounter++; } break; case 7: break; } if (roomSolved) { if (exitDoor.isLocked()) { //GetComponent<AudioSource> ().enabled = false; player.setSpeed(defaultPlayerSpeed); File.Delete("dialog/room_4/ItemHolder.txt"); r4Dark = GameObject.Find("raum4D").GetComponent <SpriteRenderer>(); r4Dark.enabled = true; r5Dark = GameObject.Find("raum5D").GetComponent <SpriteRenderer>(); r5Dark.enabled = false; endAndProceed(); } } } }
// Update is called once per frame void Update() { if (isActive) { dialogManager.setRoom("room_1"); player.setRoom("room_1"); switch (eventCounter) { case 0: //dialogManager.setDialog ("Lala lulu!"); //player.freeze(); dialogManager.setDialog("contrastEncounter.txt"); eventCounter++; break; case 1: if (scaryPainting.interactionOccurred()) { dialogManager.setDialog("scaryPainting_firstLook.txt"); eventCounter++; } break; case 2: if (beautifulPainting.interactionOccurred()) { //Debug.Log ("Dialog running: "+dialogManager.isActive()); dialogManager.setDialog("beautifulPainting_firstLook.txt"); //Debug.Log ("...and running: "+dialogManager.isActive()); eventCounter++; } break; case 3: //Debug.Log ("Dialog still running: "+dialogManager.isActive()); if (!dialogManager.isActive()) { eventCounter++; } break; case 4: if (beautifulPainting.interactionOccurred()) { //Debug.Log ("Dialog running: "+dialogManager.isActive()); dialogManager.setDialog("beautifulPainting_secondLook.txt"); //Debug.Log ("...and running: "+dialogManager.isActive()); eventCounter++; } break; case 5: //Debug.Log ("Dialog still running: "+dialogManager.isActive()); if (!dialogManager.isActive()) { eventCounter++; } break; case 6: if (beautifulPainting.interactionOccurred()) { //Debug.Log ("Dialog running: "+dialogManager.isActive()); dialogManager.setDialog("beautifulPainting_thirdLook.txt"); //Debug.Log ("...and running: "+dialogManager.isActive()); eventCounter++; } break; case 7: //Debug.Log ("Dialog still running: "+dialogManager.isActive()); if (!dialogManager.isActive()) { eventCounter++; } break; case 8: if (beautifulPainting.interactionOccurred()) { //Debug.Log ("Dialog running: "+dialogManager.isActive()); dialogManager.setDialog("beautifulPainting_fourthLook.txt"); //Debug.Log ("...and running: "+dialogManager.isActive()); eventCounter++; } break; case 9: //Debug.Log ("Dialog still running: "+dialogManager.isActive()); if (!dialogManager.isActive()) { eventCounter++; } break; case 10: if (beautifulPainting.interactionOccurred()) { //Debug.Log ("Dialog running: "+dialogManager.isActive()); dialogManager.setDialog("inDenial.txt"); //Debug.Log ("...and running: "+dialogManager.isActive()); eventCounter++; } break; case 11: //Debug.Log ("Dialog still running: "+dialogManager.isActive()); if (!dialogManager.isActive()) { eventCounter++; } break; case 12: if (beautifulPainting.interactionOccurred()) { //Debug.Log ("Dialog running: "+dialogManager.isActive()); dialogManager.setDialog("finalChoice.txt"); //Debug.Log ("...and running: "+dialogManager.isActive()); } if (dialogManager.getDialogOutput() == "paintingBeingRipped") { eventCounter++; } break; case 13: eventCounter++; break; case 14: //dialogManager.setDialog ("talkingToSomeone.txt"); //if(!dialogManager.isActive()){eventCounter++;} eventCounter++; break; case 15: beautifulPainting.ripPainting(); exitDoor.setIsLocked(); //exitDoor locked=false!! (unlock) roomSolved = true; eventCounter++; break; } if (roomSolved) { if (exitDoor.isLocked()) { File.Delete("dialog/room_1/ItemHolder.txt"); r2Dark = GameObject.Find("raum2D").GetComponent <SpriteRenderer>(); r2Dark.enabled = false; r1Dark = GameObject.Find("raum1D").GetComponent <SpriteRenderer>(); r1Dark.enabled = true; endAndProceed(); } } } }
//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 = ""; } }
// Update is called once per frame void Update() { if (isActive) { dialogManager.setRoom("room_3"); player.setRoom("room_3"); switch (eventCounter) { case 0: if (event1.getColliderStateEnter()) { player.freeze(); if (player.getFirstItem() != null) { //Debug.Log ("FirstIsntHere"); dialogManager.setDialog("someitems.txt"); firstTime = false; } else if (firstTime) { dialogManager.setDialog("noitems.txt"); } else { dialogManager.setDialog("lostitems.txt"); eventCounter++; } } if (dialogManager.getDialogOutput() == "falling") { collider.enabled = false; if (timeCounter < 2f) { tempPlanken = planken.transform.position.y + Time.deltaTime * 2f; planken.transform.position = new Vector3(planken.transform.position.x, tempPlanken, planken.transform.position.z); } if (timeCounter > .5f && (spieler.transform.position.y > 14)) { tempPlanken = spieler.transform.position.y - Time.deltaTime * 1f; spieler.transform.position = new Vector3(spieler.transform.position.x, tempPlanken, spieler.transform.position.z); tempPlanken = spieler.transform.localScale.y - 0.05f * Time.deltaTime; spieler.transform.localScale = new Vector3(tempPlanken, tempPlanken, 1f); } if (timeCounter > 1.5f && timeCounter < 3.5f) { tempPlanken = planken.transform.position.y - Time.deltaTime * 2f; planken.transform.position = new Vector3(planken.transform.position.x, tempPlanken, planken.transform.position.z); } else if (timeCounter > 3.5f) { spieler.transform.localScale = new Vector3(0.025f, 0.025f, 1f); timeCounter = 0f; player.setSpeed(1f); collider.enabled = true; //player.unfreeze (); dialogManager.setDialogOutputTo(""); } timeCounter += Time.deltaTime; } if (dialogManager.getDialogOutput() == "delete") { player.deleteIventory(); } if (dialogManager.getDialogOutput() == "endDialog") { //Debug.Log ("endDialog = true"); endDialog = true; } if (dialogManager.getDialogOutput() == "unfreeze") { player.unfreeze(); dialogManager.setDialogOutputTo(""); } if (dialogManager.isActive() == false && endDialog) { eventCounter++; } break; case 1: player.unfreeze(); eventCounter++; break; case 2: eventCounter++; break; case 3: exitDoor.setIsLocked(); //exitDoor locked=false!! (unlock) roomSolved = true; eventCounter++; break; case 4: break; } if (roomSolved) { if (exitDoor.isLocked()) { File.Delete("dialog/room_3/ItemHolder.txt"); r4Dark = GameObject.Find("raum4D").GetComponent <SpriteRenderer>(); r4Dark.enabled = false; r3Dark = GameObject.Find("raum3D").GetComponent <SpriteRenderer>(); r3Dark.enabled = true; //audio.GetComponent<AudioSource> ().Stop (); endAndProceed(); } } } }