IEnumerator enableInterfaceWait() { yield return(new WaitForSeconds(1f)); //destroy pyramid and start anew eventSystem.GetComponent <CreatePartTutorial1>().clearPartsCreated(); //enable part buttons foreach (Button b in partButtons) { b.interactable = true; } //enable clickability of black regions on all parts foreach (GameObject a in attachments) { BoxCollider bcollide = a.GetComponent <BoxCollider>(); if (bcollide == null) { a.GetComponent <MeshCollider>().enabled = true; } else { bcollide.enabled = true; } } yield return(new WaitForSeconds(1f)); ConversationTrigger.AddToken("dreshaEnabledInterface"); }
// Enable the text box, supplying a trigger. This is generally better when possible, since it will set name / escape rule. public static void Enable(ConversationTrigger trigger) { // Make sure we didn't lose our ref somehow... if (textBox == null || textBox.isActiveAndEnabled == false) { textBox = thisObject.GetComponentInChildren <ScrollingText>(); textBox.enabled = true; } // Make sure the dictionary is prepped if a "bad" key is given. if (!ConversationsDB.convos.ContainsKey(trigger.conversationName)) { ConversationsDB.LoadConversationsFromFiles(); } textBox.ApplyConversation(ConversationsDB.convos[trigger.conversationName]); currentConversationName = trigger.conversationName; currentEscRule = trigger.allowEscape; if (trigger.conversationName == "nowhere") { SoftDisable(); return; } SetStarterName(trigger.nameOfStarter); FakeActive(thisObject, true); currentlyEnabled = true; AllowMouse(); // Oneshot destroys the trigger and marks it with a token so it never comes back again. Ever. // You'll have to delete the save file to have it trigger again. if (trigger.oneShot) { Destroy(trigger); ConversationTrigger.AddToken("oneShot_" + trigger.conversationName); } }
// activate the fuser and then run the Fuser interface // script for before any batteries have been collected public void ActivateFuserFirstLook() { fuserActive = true; fuserStatic.SetActive(true); ConversationTrigger.AddToken("gear_fuser"); StartCoroutine(firstLookAtFuser()); }
IEnumerator waitThenAddToken(string token, float seconds) { yield return(new WaitForSeconds(seconds)); ConversationTrigger.AddToken(token); Debug.Log("Added token " + token + " successfully!"); }
// sets what partsNeeded and batteriesBuilt should be depending on // player's progress private void setCounterMaximums() { // CHANGE when more levels are added if (!ConversationTrigger.GetToken("finished_b1")) { partsNeeded = 4; batteriesNeeded = 4; } else if (!ConversationTrigger.GetToken("finished_b2")) { partsNeeded = 3; batteriesNeeded = 4; } else if (!ConversationTrigger.GetToken("finished_b3")) { partsNeeded = 3; batteriesNeeded = 4; } else if (!ConversationTrigger.GetToken("finished_b4")) { partsNeeded = 4; batteriesNeeded = 4; } else { partsNeeded = 0; batteriesNeeded = 0; } }
// Update is called once per frame void Update() { // show timer and number of rotations remaining at top if (!displayedTimerAndRotations && ConversationTrigger.GetToken("finishedConst_21")) { displayedTimerAndRotations = true; timeRemainingPanel.alpha = 1; rotationsRemainingPanel.alpha = 1; timeRemainingPanel.blocksRaycasts = true; rotationsRemainingPanel.blocksRaycasts = true; } // draw player's attention to the timer and rotation limit else if (!flashedTimerAndRotations && ConversationTrigger.GetToken("finishedConst_22")) { flashedTimerAndRotations = true; StartCoroutine(showImageAndAddToken(arrowToTimePanel, SHOW_IMAGE_DURATION, "finishedFlashingTimerAndRotations")); StartCoroutine(showImage(arrowToRotationsPanel, SHOW_IMAGE_DURATION)); highlighter.HighlightTimed(timeRemainingPanel.gameObject, 2); highlighter.HighlightTimed(rotationsRemainingPanel.gameObject, 2); } // player just clicked Ready! answer, so start countdown else if (!startedCountdown && ConversationTrigger.GetToken("finishedConst_23")) { ConversationTrigger.AddToken("doneWithBeginningConvo"); startedCountdown = true; // do countdown // as soon as countdown finishes, enable player controls with one flash StartCoroutine(doCountdownAndEnableControls()); } // if player runs out of time or rotations, start level over // should put checks for this in timer and rotation panels, replace BatteryIndicator with them // in RotationGizmo stuff }
// Called when an item is picked up. Prepares the tokens for saving. public static void ConvertInventoryToTokens() { // Remove all current inventory tokens. (anything containing "item|") List <string> toRemove = new List <string>(); // Need a list because you cannot modify a hashset while iterating over it. foreach (string ii in ConversationTrigger.tokens) { if (ii.Contains("item|")) { toRemove.Add(ii); } } foreach (string ii in toRemove) { ConversationTrigger.RemoveToken(ii, false); } // Create and add the tokens to model the inventory. // "item|PATH|COUNT" List <string> toAdd = new List <string>(); // Need a list because you cannot modify a hashset while iterating over it. foreach (KeyValuePair <string, InvItem> ii in items) { string newToken = "item|"; newToken += ii.Value.pickup.GetComponent <PickUp>().prefabPath; newToken += "|"; newToken += ii.Value.quantity; toAdd.Add(newToken); } foreach (string ii in toAdd) { ConversationTrigger.AddToken(ii, false); } SaveController.Save(); }
private void DrawTargetingStage() { DrawOverrideNameSubsection(npcObject); EditorGUILayout.LabelField("Targeting", EditorStyles.boldLabel); EditorWindowTools.StartIndentedSection(); ConversationTrigger conversationTrigger = npcObject.GetComponentInChildren <ConversationTrigger>(); BarkTrigger barkTrigger = npcObject.GetComponentInChildren <BarkTrigger>(); bool hasOnTriggerEnter = ((conversationTrigger != null) && (conversationTrigger.trigger == DialogueTriggerEvent.OnTriggerEnter)) || ((barkTrigger != null) && (barkTrigger.trigger == DialogueTriggerEvent.OnTriggerEnter)); bool hasOnUse = ((conversationTrigger != null) && (conversationTrigger.trigger == DialogueTriggerEvent.OnUse)) || ((barkTrigger != null) && (barkTrigger.trigger == DialogueTriggerEvent.OnUse)); bool needsColliders = hasOnTriggerEnter || hasOnUse; bool hasAppropriateColliders = false; if (hasOnTriggerEnter) { hasAppropriateColliders = DrawTargetingOnTriggerEnter(); } if (hasOnUse) { hasAppropriateColliders = DrawTargetingOnUse() || hasAppropriateColliders; } if (!needsColliders) { EditorGUILayout.HelpBox("The NPC doesn't need any targeting components. Click Next to proceed.", MessageType.Info); } if (GUILayout.Button("Select NPC", GUILayout.Width(100))) { Selection.activeGameObject = npcObject; } EditorWindowTools.EndIndentedSection(); DrawNavigationButtons(true, (hasAppropriateColliders || !needsColliders), false); }
private IEnumerator doCountdownAndEnableControls() { while (!ConversationTrigger.GetToken("readyToStartTimer")) { yield return(new WaitForFixedUpdate()); } ConversationTrigger.RemoveToken("introTimer"); ConversationTrigger.RemoveToken("readyToStartTimer"); StartCoroutine(introTimer()); countdownPanel.alpha = 1; for (int i = 3; i > 0; i--) { countdownText.text = "" + i; audioSource.PlayOneShot(countdownSound); yield return(new WaitForSeconds(1f)); } countdownText.text = "GO!"; audioSource.PlayOneShot(finalCountSound); yield return(new WaitForSeconds(1f)); countdownPanel.alpha = 0; enablePlayerControl(); timer.startTimer(); }
private IEnumerator waitThenRestart(float seconds, string token) { yield return(new WaitForSeconds(seconds)); ConversationTrigger.AddToken(token); enablePlayerControl(); }
// Update is called once per frame void Update() { //Debug.Log(ConversationTrigger.GetToken("firstPickup")); // finished recharging after power failure if (ConversationTrigger.GetToken("outOfPower") && ConversationTrigger.GetToken("hasPower")) { ConversationTrigger.RemoveToken("outOfPower"); ConversationTrigger.RemoveToken("hasPower"); StartCoroutine(rechargingAndRestart()); } // when Dresha has finished the restart message, reenable controls else if (ConversationTrigger.GetToken("doneRestarting") && ConversationTrigger.GetToken("letsRestart")) { ConversationTrigger.RemoveToken("letsRestart"); ConversationTrigger.RemoveToken("doneRestarting"); enablePlayerControl(); } // first time level is started: may want this for as soon as the tutorial before first part is over else if (ConversationTrigger.GetToken("startBeginningConvo") && ConversationTrigger.GetToken("doneWithBeginningConvo")) { ConversationTrigger.RemoveToken("startBeginningConvo"); ConversationTrigger.RemoveToken("doneWithBeginningConvo"); StartCoroutine(doCountdownAndEnableControls()); } }
public void incParts() { if (partsFound == 0) { setCounterMaximums(); // figure out how many batteries are needed for next Construction level } partsFound++; partsFoundText.text = "Battery Parts: " + partsFound + "/" + partsNeeded; showBatteryParts(); if (partsFound == partsNeeded) { partsDone = true; // reset battery pickup conversation for next battery level ConversationTrigger.RemoveToken("picked_up_a_battery"); batteriesBuilt++; // technically, they're not built yet. But they will be when the player returns to scene. StartCoroutine(waitThenHide(6)); readyForNextLevel.Invoke(); } //if (partsDone && partCounter.allPartsCollected()) { // fadeScreen.fadeOut(3f); // resetCounter(); // partCounter.resetCounter(); // levelTimer.stopTimer(); // levelTimer.resetTimer(); // InventoryController.levelName = SceneManager.GetActiveScene().name; // StartCoroutine(waitThenLoadLevel(3f, whatToBuild)); //} }
void Start() { if (WindChimes != null && PartsSounds != null) { PartsSounds.clip = WindChimes; PartsSounds.Play(); } // check deleteToken. if ((deleteToken != "" && ConversationTrigger.GetToken(deleteToken)) || (autoDelete && ConversationTrigger.GetToken("autodelete_" + pickupName))) { Destroy(gameObject); } // We need to rename all the bits under the model of the pickup, if there are any. // The reason for this is names will conflict with names inside construction mode, and // construction mode uses a ton of GameObject.Find... Weird things start to happen! //TODO better fix than this maybe? I've been putting this one off for a while. foreach (Transform ii in GetComponentsInChildren <Transform>()) { //ii.name = "NAME CHANGED TO PREVENT BUGS"; ii.name += "_fix"; } }
//disables/enables connect-related conversation tokens //to prevent infinite triggers since they aren't oneshots //called every time Connect button is invoked once player has control public void resetConnectTokens() { //BRANCH: if attaching works, go to conversation playerAttachToFinish // if attaching is wrong rotation, go to conversation tryRotatingAgain // if attaching is wrong shape, go to conversation tryDifferentShape // These triggers are NOT oneshots if (triggersFinished[17]) { string fuseStatus = fuseEvent.getFuseStatus(); ConversationTrigger.RemoveToken("playerRotationIncorrect"); // to stop infinite triggers ConversationTrigger.RemoveToken("wrongRotationDreshaReadyToFlashObj"); // to stop infinite triggers ConversationTrigger.RemoveToken("blockTryRotatingAgain2"); // to stop infinite triggers ConversationTrigger.RemoveToken("playerAttachedWrongFace"); // to stop infinite triggers ConversationTrigger.RemoveToken("wrongFaceDreshaReadyToFlashBox"); // to stop infinite triggers ConversationTrigger.RemoveToken("playerAttachedSuccessfully"); ConversationTrigger.RemoveToken("wrongRotationDreshaFlashedObj"); // to stop infinite triggers if (fuseStatus.Equals("wrongFace")) { // player tried to attach but selected the wrong FuseTo // Dresha will now tell player to select a different FuseTo ConversationTrigger.AddToken("playerAttachedWrongFace"); // convo tryDifferentShape } else if (fuseStatus.Equals("wrongRotation")) { // player tried to attach but rotation wasn't right // Dresha will now tell player to try a different rotation ConversationTrigger.AddToken("playerRotationIncorrect"); // convo tryRotatingAgain } else if (fuseStatus.Equals("success")) { ConversationTrigger.AddToken("playerAttachedSuccessfully"); //this triggers a one-shot } } }
IEnumerator rotateTwiceWrongPartScript() { Highlighter.Unhighlight(zUp); rotationScript.runManualRotation(b1p1, 0, 0, -90); yield return(new WaitForSeconds(2f)); ConversationTrigger.AddToken("finishedRotatingTwiceWrongPart"); }
private void enablePartButtons() { ConversationTrigger.AddToken("dreshaFlashedPartButtons"); foreach (Button b in partButtons) { b.enabled = true; } }
IEnumerator pointToBlackRegionsWait() { selectPart.selectObject(GameObject.Find("pyr_box_attach")); selectPart.selectFuseTo(GameObject.Find("box_tri_attach")); yield return(new WaitForSeconds(1f)); ConversationTrigger.AddToken("dreshaPointedToBlackRegions"); }
void Start() { GetComponentInChildren <Text>().text = choiceText; GetComponent <Button>().onClick.AddListener(() => // Adds an event to the button { ConversationController.Enable(choicePointer); ConversationTrigger.AddToken(choiceToken); }); }
IEnumerator showImageAndAddToken(Image imgToFlash, float time, string token) { imgToFlash.enabled = true; yield return(new WaitForSeconds(time)); imgToFlash.enabled = false; ConversationTrigger.AddToken(token); }
private IEnumerator waitAndThenAddToken(float seconds, string token) { //this, combined with the doneRestarting token from the opening conversation, will start the //level countdown after the opening conversation is complete // if there is no opening conversation, simply add the line // ConversationTrigger.AddToken("doneRestarting") yield return(new WaitForSeconds(seconds)); ConversationTrigger.AddToken(token); }
// Use this for initialization void Start () { REF = this; trigger = this.GetComponent<ConversationTrigger>(); UpdateDisplay(); // trigger.TryStartConversation(this.gameObject.transform); Time.timeScale = 1f; DialogueLua.SetVariable("FullGameOwned",SaveGameUtils.fullGameOwned); }
private IEnumerator resetConstruction() { tryAgainButton.gameObject.SetActive(false); rechargingText.enabled = true; // simple ... progress animation for recharging text // takes 3 seconds for recharging animation to complete StartCoroutine(rechargingAnimation()); // put starting part back to where it was Debug.Log("Setting " + startingPart + " position to " + startingPartOffscreenPos + "!"); startingPart.transform.SetPositionAndRotation(startingPartOffscreenPos, startingPartRotation); // reset victoryPrefab, otherwise it does weird stuff once level is complete fuseEvent.resetVictoryPrefab(); // and reset camera cameraControls.gameObject.transform.SetPositionAndRotation(new Vector3(-90, 45, -3.36f), Quaternion.Euler(0, 0, 0)); // and reset the number of rotations, time remaining, and fuseCount rotationsRemainingPanel.GetComponent <RotationCounter>().resetRotations(); if (timeRemainingPanel != null) { timeRemainingPanel.GetComponent <Timer>().resetTimer(); } fuseEvent.resetFuseCount(); yield return(new WaitForSeconds(4f)); screenFader.fadeIn(0.5f); //flicker screen back in // flickeringTime = 0.5f; // while (flickeringTime > 0) // { // flickerLength = Random.Range(0.01f, 0.1f); // fadeOutScreen.enabled = false; // yield return new WaitForSeconds(flickerLength); // fadeOutScreen.enabled = true; // flickeringTime -= flickerLength; // } // fadeOutScreen.enabled = false; if (tutorial != null) { tutorial.enableTooltips(); } yield return(new WaitForSeconds(1f)); Debug.Log("Starting zoom up animation!"); StartCoroutine(startingPartZoomUp()); //Dresha talks and part zooms up yield return(new WaitForSeconds(1f)); ConversationTrigger.AddToken("letsRestart"); }
IEnumerator rotatePyrWait() { yield return(new WaitForSeconds(0.5f)); pyramid = GameObject.Find("tutorial1_pyrPrefab(Clone)"); rotationScript.runManualRotation(pyramid, 0f, -90f, 0f); rotationScript.runManualRotation(pyramid, 0f, 0f, -90f); yield return(new WaitForSeconds(1f)); ConversationTrigger.AddToken("dreshaRotatedPyr"); }
IEnumerator createPyrWait() { yield return(new WaitForSeconds(0.5f)); eventSystem.GetComponent <CreatePartTutorial1>().createPyr(); rotationScript.Disable(); GameObject.Find("pyr_box_attach").GetComponent <BoxCollider>().enabled = false; yield return(new WaitForSeconds(1f)); ConversationTrigger.AddToken("dreshaCreatedPyr"); }
void Update() { if (Input.GetKeyDown(KeyCode.T)) { foreach (string ii in ConversationTrigger.tokens) { Debug.Log(ii); } Debug.Log(ConversationTrigger.GetToken("dreshaReadyToFlashPyr")); } }
private void setWhatToBuild() { // CHANGE this every time a new battery level is added if (!ConversationTrigger.GetToken("finished_b1")) { whatToBuild = "b1"; Exp_firstBattery_b2.enabled = true; } else if (!ConversationTrigger.GetToken("finished_b2")) { whatToBuild = "b2"; Exp_firstBattery_b3.enabled = true; } else if (!ConversationTrigger.GetToken("finished_b3")) { whatToBuild = "b3"; Exp_firstBattery_b4.enabled = true; } else if (!ConversationTrigger.GetToken("finished_b4")) { whatToBuild = "b4"; } else if (!ConversationTrigger.GetToken("finished_RB")) { whatToBuild = "rocketBoots"; } else if (!ConversationTrigger.GetToken("finished_b5")) { whatToBuild = "b5"; } else if (!ConversationTrigger.GetToken("finished_b6")) { whatToBuild = "b6"; } else if (!ConversationTrigger.GetToken("finished_b7")) { whatToBuild = "b7"; } else if (!ConversationTrigger.GetToken("finished_b8")) { whatToBuild = "b8"; } else if (!ConversationTrigger.GetToken("finished_sledgehammer")) { whatToBuild = "sledgehammer"; } else { whatToBuild = "none"; } //TESTING ONLY whatToBuild = "b4"; }
IEnumerator highlightGizmoWait() { // maybe should highlight only the sliders instead? foreach (Transform child in rotationGizmo.transform) { highlighter.HighlightTimed(child.gameObject, 2); } yield return(new WaitForSeconds(1f)); ConversationTrigger.AddToken("dreshaFlashedGizmo"); }
private void enableControlsAndAddToken(string token) { highlightGizmo(4f); for (int i = 0; i < partButtons.Length; i++) { highlighter.HighlightTimed(partButtons[i].gameObject, 4f); } highlighter.HighlightTimed(fuseButton.gameObject, 4f); highlighter.HighlightTimed(controlsButton.gameObject, 4f); ConversationTrigger.AddToken(token); }
// Scans the list of items, adds icons for each one. public void Repopulate() { // Clear out the big image. bigImage.color = new Color(1f, 1f, 1f, 0f); // Destroy everything currently in the list. foreach (GameObject ii in cluesInList) { Destroy(ii); } // Convert special tokens to clues. // Clue sprites must be under Resources/Clues for this to work. //! Clue sprites must also have the same name as the item name. foreach (string ii in ConversationTrigger.tokens) { if (ii.Contains("clue_")) { string clueName = ii.Substring(5); AddClue(clueName, Resources.Load <Sprite>("Clues/" + clueName)); } } // Actually repopulate. foreach (KeyValuePair <string, Sprite> ii in clues) //foreach (InvItem ii in InventoryController.items) { // Create the object. GameObject instance = Instantiate(clueBase); ClueButtonBridge cbb = instance.GetComponent <ClueButtonBridge>(); cbb.bigImage = bigImage; cbb.clueSprite = ii.Value; // Set parent and internals. instance.transform.SetParent(this.transform, false); instance.GetComponent <Image>().sprite = ii.Value; // Check if the clue has already been solved. // Hardcoding this for the sake of sanity. if (ConversationTrigger.GetToken("autodelete_Key 1 Dangly T") && ii.Key == "CityPart1" || ConversationTrigger.GetToken("autodelete_Key 1 Upright L") && ii.Key == "CityPart2" || ConversationTrigger.GetToken("autodelete_Key 1 Upright Rect") && ii.Key == "CityPart3" || ConversationTrigger.GetToken("autodelete_Key 1 Upright T") && ii.Key == "CityPart4" || ConversationTrigger.GetToken("autodelete_Key 1 Walking Pants") && ii.Key == "CityPart5" || ConversationTrigger.GetToken("autodelete_Key 1 Waluigi") && ii.Key == "CityPart6") { instance.GetComponent <Image>().color = new Color(0.25f, 0.25f, 0.25f); } // Add to object list. cluesInList.Add(instance); } }
//does nothing when Pyr button is clicked subsequent times public void playerClicksAPartButton() { if (!partButtonClicked) { partButtonClicked = true; foreach (Button b in partButtons) { Highlighter.Unhighlight(b.gameObject); } ConversationTrigger.AddToken("playerClicksPyrButton"); } }
IEnumerator tryAttachPyrWait() { yield return(new WaitForSeconds(1f)); fuseEvent.initiateFuse(); //deselect the active part selectPart.resetSelectedObject(); //deselect tri FuseTo selectPart.resetSelectedFuseTo(); yield return(new WaitForSeconds(1f)); ConversationTrigger.AddToken("dreshaTriedToAttach"); }
void OnSelectedUsable(Usable usable) { NGUITools.SetActive(mainControl.gameObject, true); if(usable!=null) { string actionText = usable.defaultActionText; // iTween.FadeTo(mainControl.gameObject,1.0f,0.25f); _trigger = usable.GetComponent<ConversationTrigger>(); #if UNITY_IPHONE || UNITY_ANDROID string output = "Press chat icon "+actionText+" "+usable.GetName(); label.text = output.ToUpper(); #else string output = "Press Space "+actionText +" "+ usable.GetName(); label.text = output.ToUpper(); #endif } }
public void doConversation(string aConversationName) { SaveGameUtils.setTutorialFlags(); DialogueLua.SetVariable("Tutorials",SaveGameUtils.TUTORIALS_ON); DialogueLua.SetVariable("UsersCash",ChampionshipSeason.ACTIVE_SEASON.getUsersTeam().cash); trigger = this.GetComponent<ConversationTrigger>(); trigger.conversation = aConversationName; trigger.OnUse(); }
public void Awake() { DialogueLua.SetVariable("Tutorials",SaveGameUtils.TUTORIALS_ON); SaveGameUtils.setTutorialFlags(); if(!RaceEndFinances.showFinance) { DialogueLua.SetVariable("UsersCash",ChampionshipSeason.ACTIVE_SEASON.getUsersTeam().cash); trigger = this.GetComponent<ConversationTrigger>(); trigger.conversation = "Welcome Conversation"; trigger.TryStartConversation(this.transform); } else { RaceEndFinances.showFinance = false; GameObject g =NGUITools.AddChild(GameObject.Find ("UI Root").gameObject,this.endOfRaceFinancesPrefab); Debug.Log (g.name); endOfRaceFinances = g.GetComponent<EndOfRaceFinances>(); endOfRaceFinances.onCloseFinances += onCloseFinances; } }
private void onCloseFinances() { DialogueLua.SetVariable("Tutorials",SaveGameUtils.TUTORIALS_ON); trigger = this.GetComponent<ConversationTrigger>(); GTTeam myTeam = ChampionshipSeason.ACTIVE_SEASON.getUsersTeam(); // For example, warn the user if contracts are going to expire myTeam.endRaceActions(); trigger.conversation = "Welcome Conversation"; trigger.TryStartConversation(this.transform); Destroy(endOfRaceFinances.gameObject); }
public void doConversation(string aConversationName) { conversationTrigger = this.GetComponent<ConversationTrigger>(); if(conversationTrigger==null) { conversationTrigger = this.gameObject.AddComponent<ConversationTrigger>(); sendMessage = this.gameObject.GetComponent<SendMessageOnDialogueEvent>(); } if(aConversationName=="TutorialOverheating"&&DialogueLua.GetVariable("HintArrowOverheating").AsInt==2) { } else { Time.timeScale = 4f; onSimSpeedChange(); } conversationTrigger.conversation = aConversationName; conversationTrigger.OnUse(); }
public void showTopButtons() { if(interfacePanel!=null) interfacePanel.gameObject.SetActive(true); trigger = this.GetComponent<ConversationTrigger>(); trigger.conversation = "Welcome Conversation"; trigger.OnUse(); }