public void findAllDialogElements() { //Find the button script buttonEvents = GameObject.Find("GameControl").GetComponent <GameButtons> (); //Pause the game buttonEvents.pause(); //Activate all dialog elements for (int i = 0; i < GameObject.Find("dialogue_elements").transform.childCount; i++) { GameObject.Find("dialogue_elements").transform.GetChild(i).gameObject.SetActive(true); } //Find dialogelements and give them references dialogTextBox = GameObject.Find("dialogue_ingame").GetComponent <Text> (); characterName = GameObject.Find("dialogue_name").GetComponent <Text> (); questInfo = GameObject.Find("quest_info_text").GetComponent <Text> (); nextButton = GameObject.Find("dialogue_next"); //Placement characetername nameLeftPos = new Vector3(215.0f, -25.0f); nameRightPos = new Vector3(570.0f, -25.0f); //Character text color. Made to destinct who is talking. Color match character animation color textColorPlayer = "#173E3CFF"; textColorBoss = "#4F3430FF"; //all dialog is here setDialog(); //Starts first dialog. dialogBoss(0); }
private void loadWorldMaster() { //Finds dialogboxes dialogTextBox = GameObject.Find("dialogue_ingame").GetComponent <Text> (); characterName = GameObject.Find("dialogue_name").GetComponent <Text> (); questInfo = GameObject.Find("quest_info_text").GetComponent <Text> (); pauseText = GameObject.Find("pause"); buttonEvents = GameObject.Find("GameControl").GetComponent <GameButtons> (); //Finds characterportretts marineCharacterWindow = GameObject.Find("Portrett2_marine"); shopKeeperCharacterWindow = GameObject.Find("Portrett2_shopkeeper"); bossCharacterWindow = GameObject.Find("Portrett2_boss"); //Find new nextbutton and add function to happen with click nextButton = GameObject.Find("dialogue_next"); nextButton.GetComponent <Button> ().onClick.AddListener(nextDialog); //Get the bubble and the windows around talkBubble = GameObject.Find("bubble_ingame"); avatarWindow = GameObject.Find("avatar1"); avatarWindow2 = GameObject.Find("avatar2"); //pause game buttonEvents.pause(); }
void Start() { //Find all objects needed dialogTextBox = GameObject.Find("dialogue_ingame").GetComponent <Text> (); characterName = GameObject.Find("dialogue_name").GetComponent <Text> (); questInfo = GameObject.Find("quest_info_text").GetComponent <Text> (); buttonEvents = GameObject.Find("GameControl").GetComponent <GameButtons> (); compass = GameObject.Find("compass_needle").GetComponent <PointTowards> (); //Position characternames nameLeftPos = new Vector3(217.0f, -25.0f); nameRightPos = new Vector3(612.0f, -25.0f); //position shopkeeper name in shop nameShop = new Vector3(215.4f, 73.2f); //Textcolor based on character textColorPlayer = "#173E3CFF"; textColorShopkeeper = "#631911FF"; textColorMarine = "#323A46FF"; //Arrays to check if player has pressed all buttons wadCheck [0] = false; wadCheck [1] = false; wadCheck [2] = false; qeCheck [0] = false; qeCheck [1] = false; //Pause at startup buttonEvents.pause(); //Turn off shooting shootingAllowed(false, "NULL"); //Fill arrays with text dialogInArray(); //set quest info questInfo.text = "Talk to Shopkeeper."; //Trigger dialog here dialog(0); //The speed the buttons blink at blinkingButtonSpeed = 0.025f; }
public void findAllDialogElements() { //Find the button script buttonEvents = GameObject.Find ("GameControl").GetComponent<GameButtons> (); //Pause the game buttonEvents.pause (); //Activate all dialog elements for (int i = 0; i < GameObject.Find("dialogue_elements").transform.childCount; i++) { GameObject.Find("dialogue_elements").transform.GetChild (i).gameObject.SetActive (true); } //Find dialogelements and give them references dialogTextBox = GameObject.Find ("dialogue_ingame").GetComponent<Text> (); characterName = GameObject.Find ("dialogue_name").GetComponent<Text> (); questInfo = GameObject.Find ("quest_info_text").GetComponent<Text> (); nextButton = GameObject.Find ("dialogue_next"); //Placement characetername nameLeftPos = new Vector3(215.0f, -25.0f); nameRightPos = new Vector3 (570.0f, -25.0f); //Character text color. Made to destinct who is talking. Color match character animation color textColorPlayer = "#173E3CFF"; textColorBoss = "#4F3430FF"; //all dialog is here setDialog (); //Starts first dialog. dialogBoss (0); }
//Function that keeps track of what is going to happen with each dialog public void dialogBoss(int dialogNumber) { //this is player dialog. Right color and position is applied if (dialogNumber == 1 || dialogNumber == 6 || dialogNumber == 9) { Debug.Log("NextDialog with character: " + characters[1]); //Sets dialog and character setDialog(characters[1], dialogTexts [dialogNumber]); //Moves name closer to portrait if (characterName.gameObject.GetComponent <RectTransform>().anchoredPosition != nameLeftPos) { Debug.Log("Change character"); characterName.gameObject.GetComponent <RectTransform>().anchoredPosition = nameLeftPos; } //Changes color on text which is closer to character ColorUtility.TryParseHtmlString(textColorPlayer, out tempColor); } //This is boss dialog. else { //Sets dialog and character Debug.Log("NextDialog with character: " + characters[0]); setDialog(characters [0], dialogTexts [dialogNumber]); //Moves name closer to portrait if (characterName.gameObject.GetComponent <RectTransform>().anchoredPosition != nameRightPos) { Debug.Log("Change character"); characterName.gameObject.GetComponent <RectTransform>().anchoredPosition = nameRightPos; } //Changes color on text which is closer to character ColorUtility.TryParseHtmlString(textColorBoss, out tempColor); } //Sets charactername and dialog color after which character that is talking characterName.color = tempColor; dialogTextBox.color = tempColor; //Dialogoptions if (dialogNumber == 0) { //Set quest questInfo.text = "Talk to Sir Pincushion"; } else if (dialogNumber == 2) { //animate boss GameObject.Find("Portrett2_boss").GetComponent <Animator> ().SetBool("isHappyBoss", true); } else if (dialogNumber == 6) { //Animate player GameObject.Find("Portrett").GetComponent <Animator> ().SetBool("isAngryMainCharacter", true); } else if (dialogNumber == 7) { //If boss animation from dialog 2 is still running it must be stopped before next animation is played if (GameObject.Find("Portrett2_boss").GetComponent <Animator> ().GetBool("isHappyBoss") == true) { GameObject.Find("Portrett2_boss").GetComponent <Animator> ().SetBool("isHappyBoss", false); } //Play boss animation GameObject.Find("Portrett2_boss").GetComponent <Animator> ().SetBool("isAngryBoss", true); } else if (dialogNumber == 9) { //Animate player GameObject.Find("Portrett").GetComponent <Animator> ().SetBool("isAngryMainCharacter", true); } else if (dialogNumber == 10) { //animate boss GameObject.Find("Portrett2_boss").GetComponent <Animator> ().SetBool("isAngryBoss", true); } else if (dialogNumber == 11) { //Set questinfo and prepare everything for fight with boss. questInfo.text = "Defeat Sir Pincushion"; activateScripts(); doneTaling = true; buttonEvents.pause(); //Turn off dialogelements for (int i = 0; i < GameObject.Find("dialogue_elements").transform.childCount; i++) { GameObject.Find("dialogue_elements").transform.GetChild(i).gameObject.SetActive(false); } } else if (dialogNumber == 12) { //Happy player when boss is dead. Last dialog before endscreen if (GameObject.Find("Portrett")) { GameObject.Find("Portrett").GetComponent <Animator> ().SetBool("isHappyMainCharacter", true); } } }
public void dialog(int stage) { //Player dialog: 1, 5, 10, 15, 20, 25, 38, 40, 42 //Marine dialog: 20 //Dialog runs here if (stage == 1 || stage == 5 || stage == 10 || stage == 15 || stage == 20 || stage == 25 || stage == 38 || stage == 41 || stage == 43) { //Sets dialog and character setDialog(character [1], dialogTexts [stage]); //Moves name closer to portrait if (characterName.gameObject.GetComponent <RectTransform>().anchoredPosition != nameLeftPos) { characterName.gameObject.GetComponent <RectTransform>().anchoredPosition = nameLeftPos; } //Changes color on text which is closer to character ColorUtility.TryParseHtmlString(textColorPlayer, out tempColor); } else if (stage == 23) { //Sets dialog and character setDialog(character [2], dialogTexts [stage]); //Moves name closer to portrait if (characterName.gameObject.GetComponent <RectTransform>().anchoredPosition != nameRightPos) { characterName.gameObject.GetComponent <RectTransform>().anchoredPosition = nameRightPos; } //Changes color on text which is closer to character ColorUtility.TryParseHtmlString(textColorMarine, out tempColor); } else { if (stage == 35 && GameControl.control.health == 100) { setDialog(character [0], "It seems like you havent got a scratch! Good for you! Next time you come back with broken ship you can repair your ship here. Click “V” to continue."); } else { //Sets dialog and character setDialog(character [0], dialogTexts [stage]); } //Moves name closer to portrait if (SceneManager.GetActiveScene().name != "Shop") { if (characterName.gameObject.GetComponent <RectTransform> ().anchoredPosition != nameRightPos) { characterName.gameObject.GetComponent <RectTransform> ().anchoredPosition = nameRightPos; } } else { if (characterName.gameObject.GetComponent <RectTransform> ().anchoredPosition != nameShop) { characterName.gameObject.GetComponent <RectTransform> ().anchoredPosition = nameShop; } } //Changes color on text which is closer to character ColorUtility.TryParseHtmlString(textColorShopkeeper, out tempColor); } characterName.color = tempColor; dialogTextBox.color = tempColor; //Pause, activate guns and other stuff here switch (stage) { case (9): //Player is tested in control buttonEvents.pause(); pauseText.SetActive(false); questInfo.text = "Move using W A D."; nextButton.SetActive(false); break; case (10): //Player is done testing. Talking to shopkeepr buttonEvents.pause(); pauseText.SetActive(true); questInfo.text = "Talk to Shopkeeper."; break; case (13): //Player is testing shooting buttonEvents.pause(); pauseText.SetActive(false); nextButton.SetActive(false); shootingAllowed(true, "GameObject"); questInfo.text = "Fire sidcanons using Q and E."; break; case (14): //Player is done testing tlaing to shopkeeper buttonEvents.pause(); pauseText.SetActive(true); shootingAllowed(true, "NULL"); questInfo.text = "Talk to Shopkeeper."; break; case (18): //Player is testing special weapon buttonEvents.pause(); pauseText.SetActive(false); questInfo.text = "Fire special weapon using Mouse2, then Mouse1."; nextButton.SetActive(false); break; case (19): //done testing talking to shopkeeper buttonEvents.pause(); pauseText.SetActive(true); questInfo.text = "Talk to Shopkeeper."; break; case (20): //Gets angry after finding out that he has to pay for bullets GameObject.Find("Portrett").GetComponent <Animator> ().SetBool("isAngryMainCharacter", true); break; case (21): //Shopkeeper finds player reaction funny GameObject.Find("Portrett2_shopkeeper").GetComponent <Animator> ().SetBool("isHappyShopkeeper", true); break; case (23): //Spawns enemy makeTutorialEnemy(); changeCharacterWindow(); break; case (24): //Talk to him changeCharacterWindow(); break; case (25): //Fight him! changeCharacterWindow(); buttonEvents.pause(); questInfo.text = "Destroy Marineship."; compass.goTarget = GameObject.FindGameObjectWithTag("aiShip"); pauseText.SetActive(false); nextButton.SetActive(false); break; case (26): //Listen to shopkeeper changeCharacterWindow(); scrapHolder = (GameObject.FindGameObjectsWithTag("scrap")); scrapCount = scrapHolder.Length; Debug.Log("Scraps left to pick up: " + scrapCount); buttonEvents.pause(); pauseText.SetActive(true); nextButton.SetActive(true); break; case (27): //Loot enemy buttonEvents.pause(); questInfo.text = "Pickup loot."; pauseText.SetActive(false); nextButton.SetActive(false); break; case (28): //Enter shop compass.goTarget = GameObject.Find("shop1"); questInfo.text = "Enter store."; enterStore = true; break; case (32): //Show how to buy special bullets clearButtons(); blinkingButtons [0] = GameObject.Find("special").GetComponent <Button> (); blinkingButtons [0].enabled = true; GameObject.Find("button_yes").GetComponent <Button> ().enabled = true; nextButton.SetActive(false); break; case (33): //Read what shopkeeper says clearButtons(); changeButtonInteractivity(false); nextButton.SetActive(true); break; case (34): //Enter repairmenu nextButton.SetActive(false); blinkingButtons [0] = GameObject.Find("button_repair").GetComponent <Button> (); blinkingButtons [0].enabled = true; break; case (35): //Fix ship clearButtons(); blinkingButtons [0] = GameObject.Find("button_v").GetComponent <Button> (); nextButton.SetActive(false); GameObject.Find("button_v").GetComponent <Button> ().enabled = true; GameObject.Find("button_x").GetComponent <Button> ().enabled = true; changeButtonInteractivity(true); GameObject.Find("ExitButton").GetComponent <Button> ().enabled = false; break; case (36): //Exit shop clearButtons(); GameObject.Find("button_v").GetComponent <Button> ().enabled = false; GameObject.Find("ExitButton").GetComponent <Button> ().enabled = true; blinkingButtons [0] = GameObject.Find("ExitButton").GetComponent <Button> (); break; case (37): //Enter world. Talk to shopkeeper changeCharacterWindow(); bossCharacterWindow.SetActive(false); questInfo.text = "Talk to shopkeeper."; pauseText.SetActive(true); break; case (44): //Enter world for reals questInfo.text = "Find ancient cog!"; talkBubble.SetActive(false); avatarWindow.SetActive(false); avatarWindow2.SetActive(false); pauseText.SetActive(false); buttonEvents.pause(); Destroy(this.gameObject); break; default: break; } }