Esempio n. 1
0
    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();
    }
Esempio n. 2
0
 // 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());
     }
 }
Esempio n. 3
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
 }
Esempio n. 4
0
    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";
        }
    }
Esempio n. 5
0
 // 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;
     }
 }
Esempio n. 6
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.T))
     {
         foreach (string ii in ConversationTrigger.tokens)
         {
             Debug.Log(ii);
         }
         Debug.Log(ConversationTrigger.GetToken("dreshaReadyToFlashPyr"));
     }
 }
Esempio n. 7
0
    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";
    }
Esempio n. 8
0
    // 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);
        }
    }
Esempio n. 9
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         if (tokenRequired == "")
         {
             LoadUtils.LoadNewExplorationLevel(levelName, spawnPosition);
         }
         else if (ConversationTrigger.GetToken(tokenRequired))
         {
             LoadUtils.LoadNewExplorationLevel(levelName, spawnPosition);
         }
     }
 }
Esempio n. 10
0
    // Update is called once per frame
    void Update()
    {
        if (!triggersFinished[0] && ConversationTrigger.tokens.Contains("dreshaReadyToFlashFinishedImage2"))
        {
            triggersFinished[0] = true;
            // first event: Dresha flashes finished image, which triggers next convo
            highlighter.HighlightTimed(finishedImage, 2);
            ConversationTrigger.AddToken("dreshaFlashedFinishedImage2");
        }
        else if (!triggersFinished[1] && ConversationTrigger.tokens.Contains("dreshaReadyToFlashPartButtons"))
        {
            triggersFinished[1] = true;
            // second event: Dresha flashes part buttons
            highlightPartButtons(1f);
            enablePartButtons();
        }
        else if (ConversationTrigger.GetToken("wrongRotationDreshaReadyToFlashObj"))
        {
            // Dresha flashes selected obj and then lets the player try again
            highlightSelectedObj(1f);
            ConversationTrigger.AddToken("dreshaFlashedSelectedObj2");
        }
        else if (ConversationTrigger.GetToken("playerAttachedWrongFace") && !ConversationTrigger.GetToken("wrongFaceDreshaReadyToFlashBox"))
        {
            // wrong shape - Dresha just finished tryDifferentShape1 and
            // will now flash box and part menu for 2 seconds
            highlightPartButtons(2f);
            highlighter.HighlightTimed(GameObject.Find("longbox"), 2);
        }
        else if (ConversationTrigger.GetToken("showNextLevelButton2"))
        {
            StartCoroutine(waitAndEnableGoToNextLevel());
        }

        if (fuseEvent.done() && !done)
        {
            // player wins!
            // Dresha talks about next level
            // next level should not load until player finishes this convo

            //move conversation box to center
            //conversationSystem.GetComponent<RectTransform>().pivot = new Vector2(0.5f,1);
            //conversationSystem.GetComponent<RectTransform>().anchorMin = new Vector2(0.5f,1);
            //conversationSystem.GetComponent<RectTransform>().anchorMax = new Vector2(0.5f,1);
            //conversationSystem.GetComponent<RectTransform>().localPosition = new Vector3(0, 0, 0);

            // wait till convo is finished to display congrats text
            ConversationTrigger.AddToken("showNextLevelButton2");
        }
    }
Esempio n. 11
0
    private IEnumerator readLog()
    {
        // start log display
        ConversationTrigger.AddToken("read_fuser_log");

        // wait till conversation finishes
        while (!ConversationTrigger.GetToken("show_locate_button"))
        {
            yield return(new WaitForFixedUpdate());
        }

        //once convo is finished, Locate Hidden Materials button appears, triggered
        // by token given by read fuser log conversation
        locateButton.gameObject.SetActive(true);
    }
Esempio n. 12
0
    void Start()
    {
        sledgehammerStatic = sledgehammer;

        // Check token and activate if unlocked, but deselected.
        if (ConversationTrigger.GetToken("gear_sledgehammer"))
        {
            ActivateSledgehammer();
            Deselect();
        }
        else
        {
            // Disable if not unlocked.
            sledgehammerStatic.SetActive(false);
        }
    }
Esempio n. 13
0
    void Start()
    {
        // Check tokens to see if boots are active.
        // Save is loaded somewhere else in an Awake() function.
        if (ConversationTrigger.GetToken("gear_rocketboots"))
        {
            ActivateBoots();

            // This is the first item you get, and it will be the one that always starts active when you load a game.
            // Therefore, we need this line here.
            ItemManager.SelectGear(0);
        }
        else
        {
            uiElement.gameObject.SetActive(false);
        }
    }
Esempio n. 14
0
    void Start()
    {
        invController      = transform.parent.parent.GetComponent <InventoryController>();
        indicator_s        = indicator;  // Need to ignore static limitations...
        build              = GetComponent <Button>();
        build.interactable = false;
        indicator.SetActive(false);

        build.onClick.AddListener(() =>
        {
            // Save player info before entering.
            // TODO: re-implement for final version of game?
            InventoryController.levelName = SceneManager.GetActiveScene().name;

            // Record data.
            SimpleData.WriteDataPoint("Constructing_Item", "", "", "", "", whatToBuild);
            //SimpleData.WriteStringToFile("ModeSwitches.txt", Time.time + ",MODESWITCH_TO," + whatToBuild);

            // Enter.

            // Special cases for tutorial progress.
            if (whatToBuild == "tutorial1")
            {
                if (ConversationTrigger.GetToken("done_with_tutorial_2"))
                {
                    LoadUtils.LoadScene("rocketBoots");
                }
                else if (ConversationTrigger.GetToken("done_with_tutorial_1"))
                {
                    LoadUtils.LoadScene("tutorial2");
                }
                else
                {
                    LoadUtils.LoadScene("tutorial1");
                }
            }
            else              // Normal function.
            {
                LoadUtils.LoadScene(whatToBuild);
            }

            invController.CloseInventory();
        });
    }
Esempio n. 15
0
    // When loading a save, this script checks to see if the player should be in a different level.
    // If they should be, it relocates them.

    void Start()
    {
        // Later levels should be higher in this list.
        if (ConversationTrigger.GetToken("reachedLevel_CityVault"))
        {
            LoadUtils.LoadNewExplorationLevel("CityVault", new Vector3(0, 5, 0));
            return;
        }

        if (ConversationTrigger.GetToken("reachedLevel_RuinedCity"))
        {
            LoadUtils.LoadNewExplorationLevel("RuinedCity", new Vector3(0, 5, 0));
            return;
        }
        else
        {
            transform.position = new Vector3(-160, -32, 60);
            Debug.Log("transformierung");
        }
    }
Esempio n. 16
0
    static void Refresh()
    {
        // Get Player.
        player = GameObject.FindGameObjectWithTag("Player");

        // Get every item manually. Add more as needed.
        boots  = player.GetComponent <RocketBoots>();
        hammer = player.GetComponent <Sledgehammer>();

        // Clear the list and rebuild because it's the safest solution I can think of.
        // Again. Add more items as needed.
        gear.Clear();
        if (ConversationTrigger.GetToken("gear_rocketboots"))
        {
            gear.Add(boots);
        }
        if (ConversationTrigger.GetToken("gear_sledgehammer"))
        {
            gear.Add(hammer);
        }
    }
Esempio n. 17
0
    //reset fadeOutPanel from last scene transition if needed
    private void OnEnable()
    {
        lowPowerText.enabled = false;

        //TODO: add condition for sledgehammer level
        if (ConversationTrigger.GetToken("finished_b4") && !ConversationTrigger.GetToken("finished_RB"))
        {
            disablePlayerControl();
            map.gameObject.SetActive(true);

            //reveal all rocket boots parts so player can collect them
            for (int i = 0; i < rocketBootParts.Length; i++)
            {
                rocketBootParts[i].SetActive(true);
            }

            screenFader.fadeIn(1f);
            map.doIntroMap(); // when this is done, it triggers startCountdown() and beginning of timed level
        }
        else
        {
            enablePlayerControl();
        }
    }
Esempio n. 18
0
 // Update is called once per frame
 void Update()
 {
     //Debug.Log("startBeginningConvo is already here? " + ConversationTrigger.GetToken("startBeginningConvo"));
     // finished recharging after power failure, show Try Again? button to restart level
     if (ConversationTrigger.GetToken("outOfPower"))
     {
         ConversationTrigger.RemoveToken("outOfPower");
         showTryAgainButton();
     }
     // when Dresha has finished the restart message, reenable controls and start level again with countdown
     else if (ConversationTrigger.GetToken("doneRestarting") && ConversationTrigger.GetToken("letsRestart"))
     {
         ConversationTrigger.RemoveToken("letsRestart");
         ConversationTrigger.RemoveToken("doneRestarting");
         StartCoroutine(doCountdownAndEnableControls());
     }
     // first time level is started: as soon as recharging animation and starting conversation has finished, start level with countdown
     else if (ConversationTrigger.GetToken("startBeginningConvo") && ConversationTrigger.GetToken("doneWithBeginningConvo"))
     {
         ConversationTrigger.RemoveToken("startBeginningConvo");
         ConversationTrigger.RemoveToken("doneWithBeginningConvo");
         StartCoroutine(doCountdownAndEnableControls());
     }
 }
Esempio n. 19
0
    // Update is called once per frame
    void Update()
    {
        // first event: Dresha flashes finished image, which triggers next convo
        if (!triggersFinished[0] && ConversationTrigger.tokens.Contains("dreshaReadyToFlashFinishedImage"))
        {
            triggersFinished[0] = true;
            highlighter.HighlightTimed(finishedImage, 2);
            ConversationTrigger.AddToken("dreshaFlashedFinishedImage");

            // second event: Dresha creates Pyr, which triggers next convo
        }
        else if (!triggersFinished[1] && ConversationTrigger.tokens.Contains("dreshaReadyToCreatePyr"))
        {
            triggersFinished[1] = true;
            StartCoroutine(createPyrWait());

            // third event: Dresha rotates Pyr left, then down
        }
        else if (!triggersFinished[2] && ConversationTrigger.tokens.Contains("dreshaReadyToRotatePyr"))
        {
            triggersFinished[2] = true;
            StartCoroutine(rotatePyrWait());

            // fourth event: Dresha highlights the two black regions: Pyr's and the corresponding fuseTo on the cube
        }
        else if (!triggersFinished[3] && ConversationTrigger.tokens.Contains("dreshaReadyToPointToBlackRegions"))
        {
            triggersFinished[3] = true;
            StartCoroutine(pointToBlackRegionsWait());

            // fifth event: Dresha's failed connect attempt with error message
        }
        else if (!triggersFinished[4] && ConversationTrigger.tokens.Contains("dreshaReadyToTryAttaching"))
        {
            triggersFinished[4] = true;
            StartCoroutine(tryAttachPyrWait());

            // sixth event: Welder interface fizzes to life and all controls are enabled
        }
        else if (!triggersFinished[5] && ConversationTrigger.tokens.Contains("dreshaReadyToEnableControls"))
        {
            triggersFinished[5] = true;
            StartCoroutine(enableInterfaceWait());
        }
        else if (!triggersFinished[6] && ConversationTrigger.tokens.Contains("dreshaReadyToFlashPyrButton"))
        {
            triggersFinished[6] = true;
            // seventh event: Dresha flashes part buttons ("Click on this!")
            // highlight until button is clicked
            foreach (Button b in partButtons)
            {
                Highlighter.Highlight(b.gameObject);
            }
            ConversationTrigger.AddToken("dreshaFlashedPyrButton");
        }
        else if (!triggersFinished[7] && ConversationTrigger.tokens.Contains("dreshaReadyToFlashPyr"))
        {
            triggersFinished[7] = true;
            //player has already clicked Pyr button and has just started talking about the Pyr's black part
            //eighth event: Dresha flashes selectedObj
            foreach (Button b in partButtons)
            {
                Highlighter.Unhighlight(b.gameObject);
            }
            highlightSelectedObj();             // highlight until is face is selected
        }
        else if (!triggersFinished[8] && ConversationTrigger.tokens.Contains("dreshaReadyToFlashBox"))
        {
            triggersFinished[8] = true;
            //ninth event: Dresha flashes Box
            Highlighter.Highlight(GameObject.Find("box"));
            ConversationTrigger.AddToken("dreshaFlashedBox");
        }
        else if (!triggersFinished[9] && ConversationTrigger.tokens.Contains("playerReadyToMoveCamera") &&
                 Input.GetMouseButtonDown(0))
        {
            triggersFinished[9] = true;
            unhighlightSelectedObj();
            Highlighter.Unhighlight(GameObject.Find("box"));
            //tenth event: player just depressed mouse key to begin dragging camera
            // figure out later how to get this to work for an actual drag
            ConversationTrigger.AddToken("playerMovedCamera");
        }
        else if (!triggersFinished[10] && ConversationTrigger.tokens.Contains("dreshaReadyToFlashBoxAgain"))
        {
            triggersFinished[10] = true;
            Highlighter.Highlight(GameObject.Find("box"));             // highlight until its face is selected
        }
        else if (triggersFinished[10] && !triggersFinished[11] && selectPart.getSelectedFuseTo() != null)
        {
            triggersFinished[11] = true;
            // player has selected a FuseTo
            Highlighter.Unhighlight(GameObject.Find("box"));
            ConversationTrigger.AddToken("playerSelectedAFuseTo");
        }
        else if (!triggersFinished[12] && ConversationTrigger.tokens.Contains("dreshaReadyToFlashPyrAgain"))
        {
            triggersFinished[12] = true;
            // Dresha has just told player to select the selectedObj's attachment
            highlightSelectedObj(1f);
        }
        else if (!triggersFinished[13] && triggersFinished[12] == true &&
                 selectPart.getSelectedObject() != null)
        {
            triggersFinished[13] = true;
            // player just selected pyr's attachment (or some other selectedObject, if we're allowing different shapes
            highlightSelectedObj(1f);
            ConversationTrigger.AddToken("playerSelectedAnObj");
        }
        else if (!triggersFinished[14] && ConversationTrigger.tokens.Contains("dreshaReadyToFlashConnectButton"))
        {
            triggersFinished[14] = true;
            // Dresha will now flash connect button and explain it
            Highlighter.Highlight(connectButton.gameObject);
            ConversationTrigger.AddToken("dreshaFlashedConnectButton");
        }
        else if (!triggersFinished[15] && ConversationTrigger.tokens.Contains("dreshaReadyToFlashGizmo"))
        {
            triggersFinished[15] = true;
            // Dresha will now flash rotation gizmo and explain it
            Highlighter.Unhighlight(connectButton.gameObject);
            StartCoroutine(highlightGizmoWait());
        }
        else if (!triggersFinished[16] && ConversationTrigger.tokens.Contains("dreshaReadyToFlashPyrAfterGizmo"))
        {
            triggersFinished[16] = true;
            // Dresha will now flash selectedObj once again
            highlightSelectedObj(1f);
            ConversationTrigger.AddToken("dreshaFlashedPyrAfterGizmo");
        }
        else if (!triggersFinished[17] && ConversationTrigger.tokens.Contains("readyToEnableConnectButton"))
        {
            triggersFinished[17] = true;

            //turn tutorial mode off - this restores normal functionality of connect button
            //this also enables connect button - Dresha is already talking
            selectPart.setTutorialOn(false);
        }
        else if (!triggersFinished[18] && ConversationTrigger.GetToken("wrongRotationDreshaReadyToFlashObj"))
        {
            // Dresha flashes selected obj and then lets the player try again
            highlightSelectedObj(1f);
            ConversationTrigger.AddToken("wrongRotationDreshaFlashedObj");
        }
        else if (triggersFinished[17] && ConversationTrigger.GetToken("playerAttachedWrongFace") && !ConversationTrigger.GetToken("wrongFaceDreshaReadyToFlashBox"))
        {
            // wrong shape - Dresha just finished tryDifferentShape1 and
            // will now flash box and part menu for 2 seconds
            highlightPartButtons();
            highlighter.HighlightTimed(GameObject.Find("box"), 1);
        }
        else if (ConversationTrigger.GetToken("showNextLevelButton"))
        {
            StartCoroutine(waitAndEnableGoToNextLevel());
        }

        if (fuseEvent.done() && !done)
        {
            // player wins!
            // Dresha talks about next level
            // next level should not load until player finishes this convo
            done = true;
            ConversationTrigger.AddToken("playerFinishedTutorial1");
        }
    }
Esempio n. 20
0
 bool checkToken()
 {
     return(ConversationTrigger.GetToken(tokenToCheck));
 }
Esempio n. 21
0
    void Start()
    {
        invController = transform.parent.parent.parent.GetComponent <InventoryController>();

        GetComponent <Button>().onClick.AddListener(() =>           // Adds an event to the button
        {
            //Debug.Log("Recipe Button Pressed: " + myRecipe.recipeName);

            // Destroy everything on the right.
            foreach (GameObject jj in recPop.iconsInList)
            {
                Destroy(jj);
            }
            // Clear the flag list.
            constructFlags.Clear();

            // Actually repopulate.
            foreach (InvItem jj in myRecipe.components)
            {
                // Create the object.
                GameObject instanceTile = Instantiate(recPop.tileBase);

                // Set parent and internals.
                instanceTile.transform.SetParent(recPop.rightPane.transform, false);
                instanceTile.GetComponentInChildren <Text>().text = InventoryController.GetQuantity(jj.itemName) + " / " + jj.quantity.ToString();


                // Find the correct icon from the inventory.
                if (InventoryController.items.ContainsKey(jj.itemName))
                {
                    InventoryPopulator.AddIcon(InventoryController.items[jj.itemName].pickup, instanceTile.transform);
                }
                else
                {
                    instanceTile.GetComponentInChildren <Image>().sprite = questionMark;
                }


                // Decide whether to make Construct button selectable.
                if (InventoryController.GetQuantity(jj.itemName) >= jj.quantity)
                {
                    constructFlags.Add(true);
                }
                else
                {
                    constructFlags.Add(false);
                }

                // Add to object list.
                recPop.iconsInList.Add(instanceTile);
            }

            // Check the flags for each item in the recipe to see if we have all the items.
            foreach (bool bb in constructFlags)
            {
                if (!bb)
                {
                    recPop.constructButton.interactable = false;
                    break;
                }
                else
                {
                    recPop.constructButton.interactable = true;
                }
            }

            // Remove all other listeners so only the one we add in the next line will work.
            // This stops several scenes from loading at once, causing terrible things.
            recPop.constructButton.onClick.RemoveAllListeners();

            recPop.constructButton.onClick.AddListener(() =>
            {
                // Save player info before entering.
                InventoryController.levelName = SceneManager.GetActiveScene().name;

                // Close the inventory for safety on updates.
                //invController.CloseInventory();

                // Ensure cursor is active.
                //Cursor.visible = true;
                //Cursor.lockState = CursorLockMode.None;

                // Record data.
                SimpleData.WriteStringToFile("ModeSwitches.txt", Time.time + ",MODESWITCH_TO," + myRecipe.recipeDesc);

                // Enter.

                // Special cases for tutorial progress.
                if (myRecipe.recipeDesc == "tutorial1")
                {
                    if (ConversationTrigger.GetToken("done_with_tutorial_2"))
                    {
                        LoadUtils.LoadScene("construction");
                    }
                    else if (ConversationTrigger.GetToken("done_with_tutorial_1"))
                    {
                        LoadUtils.LoadScene("tutorial2");
                    }
                    else
                    {
                        LoadUtils.LoadScene("tutorial1");
                    }
                }
                else                  // Normal function.
                {
                    LoadUtils.LoadScene(myRecipe.recipeDesc);
                }

                invController.CloseInventory();
            });
        });
    }
Esempio n. 22
0
    // Update is called once per frame
    void Update()
    {
        //step = MOVEMENT_SPEED * Time.deltaTime;
        //bb1Start.transform.position = Vector3.MoveTowards(bb1Start.transform.position, baseStartPosition, step);
        // Wait till intro text is done, then enable Tooltip scripts on each of the objects that have them
        // Also after intro text is done, change ScrollingText's enableScroll to false
        if (!tooltipsEnabled && ConversationTrigger.GetToken("finished_cameraControls"))
        {
            tooltipsEnabled            = true;
            scrollingText.enableScroll = false;
            for (int i = 0; i < allTooltips.Length; i++)
            {
                allTooltips[i].enabled = true;
            }
        }


        //if (!disableTutorial)
        //{
        //    // show Dresha moving starting part into position from bottom of screen
        //    if (!ConversationTrigger.GetToken("finishedMovingbb1") && ConversationTrigger.GetToken("finishedConst_1"))
        //    {
        //        step = MOVEMENT_SPEED * Time.deltaTime;
        //        bb1.transform.position = Vector3.MoveTowards(bb1.transform.position, baseStartPosition, step);
        //        if (bb1.transform.position.Equals(baseStartPosition))
        //        {
        //            Debug.Log("finished moving!");
        //            ConversationTrigger.AddToken("finishedMovingbb1");
        //        }
        //    }

        //    // draw player's attention to the part buttons at the bottom of the screen
        //    else if (!flashedPartButtons && ConversationTrigger.GetToken("finishedConst_2"))
        //    {
        //        flashedPartButtons = true;
        //        StartCoroutine(showImageAndAddToken(arrowPartButtons, SHOW_IMAGE_DURATION, "finishedFlashingPartButtons"));
        //        highlightPartButtons(2f);

        //    }

        //    // Dresha clicks the part button, part appears
        //    else if (!clickedB1P1Button && ConversationTrigger.GetToken("finishedConst_3"))
        //    {
        //        clickedB1P1Button = true;
        //        b1p1Button.onClick.Invoke();
        //        StartCoroutine(waitThenAddToken("finishedSelectingPart", 2f));
        //        StartCoroutine(waitThenMoveCamera(-32f, -13f, 0f, -70f, -25.5f, 13.76f, 1f, 1f));

        //    }

        //    // draw player's attention to the finished image at the top left of the screen
        //    else if (!flashedFinishedImage && ConversationTrigger.GetToken("finishedConst_4"))
        //    {
        //        flashedFinishedImage = true;
        //        StartCoroutine(showImageAndAddToken(arrowFinishedImageLeft.GetComponent<Image>(), SHOW_IMAGE_DURATION, "finishedFlashingFinishedImage"));
        //        StartCoroutine(showImage(arrowFinishedImageUp.GetComponent<Image>(), SHOW_IMAGE_DURATION));
        //        highlighter.HighlightTimed(finishedImage, 2);

        //    }

        //    // Dresha selects the black area on bb1
        //    else if (!selectedFuseTo && ConversationTrigger.GetToken("finishedConst_5"))
        //    {
        //        selectedFuseTo = true;
        //        //hardcoded normal here since we don't have pointer raycast
        //        selectPart.setFuseToNormal(Vector3.right);
        //        bb1_b1p2_a1 = GameObject.Find("bb1_b1p2_a1");
        //        StartCoroutine(waitThenSelectFuseTo(bb1_b1p2_a1, 1f));
        //        StartCoroutine(waitThenAddToken("finishedSelectingbb1_a1", 4f));
        //    }

        //    // Dresha selects the black area on b1p1
        //    else if (!selectedAC && ConversationTrigger.GetToken("finishedConst_6"))
        //    {
        //        selectedAC = true;
        //        b1p1 = GameObject.Find("b1p1Prefab(Clone)");
        //        b1p1_bb1_a1 = b1p1.transform.GetChild(1).gameObject;

        //        StartCoroutine(waitThenSelectObject(b1p1_bb1_a1, 2f));
        //        StartCoroutine(waitThenAddToken("finishedSelectingb1p1_a1", 4f));
        //    }

        //    // Dresha rotates once along y axis - should go so the black part is facing up
        //    else if (!rotatedOnceWrongPart && ConversationTrigger.GetToken("finishedConst_7"))
        //    {
        //        rotatedOnceWrongPart = true;
        //        StartCoroutine(rotateWrongPartScript());
        //    }

        //    //Then Dresha rotates once along z axis - should go so the black part is facing bb1
        //    else if (!rotatedTwiceWrongPart && ConversationTrigger.GetToken("finishedConst_8"))
        //    {
        //        rotatedTwiceWrongPart = true;
        //        StartCoroutine(rotateTwiceWrongPartScript());
        //    }

        //    //Then Fuse button is shown/pointed to
        //    else if (!flashedFuseButton && ConversationTrigger.GetToken("finishedConst_9"))
        //    {
        //        flashedFuseButton = true;
        //        StartCoroutine(showImageAndAddToken(arrowFuseButton.GetComponent<Image>(), SHOW_IMAGE_DURATION, "finishedFlashingFuseButton"));
        //        highlighter.HighlightTimed(fuseButton.gameObject, 2);
        //    }

        //    //Then Dresha tries to attach the wrong two parts
        //    else if (!attemptedWrongPartFuse && ConversationTrigger.GetToken("finishedConst_10"))
        //    {
        //        attemptedWrongPartFuse = true;
        //        StartCoroutine(waitThenInitiateFuse(1f));
        //        StartCoroutine(waitThenAddToken("finishedWrongPartFuseAttempt", 2f));
        //    }

        //    //Then Dresha selects a different part - the correct one (b1p2)
        //    else if (!clickedB1P2Button && ConversationTrigger.GetToken("finishedConst_11"))
        //    {
        //        clickedB1P2Button = true;
        //        b1p2Button.onClick.Invoke();
        //        StartCoroutine(waitThenAddToken("finishedSelectingSecondPart", 2f));
        //    }

        //    //Then Dresha selects the wrong black area on b1p2
        //    else if (!selectedSecondAC && ConversationTrigger.GetToken("finishedConst_12"))
        //    {
        //        selectedSecondAC = true;
        //        // move camera so the black area to be selected is visible
        //        StartCoroutine(waitThenMoveCamera(-6.8f, -61.9f, 0f, 1.48f, 17.63f, 51.15f, 1f, 1f));

        //        b1p2 = GameObject.Find("b1p2Prefab(Clone)");
        //        b1p2_bb1_a2 = b1p2.transform.GetChild(2).gameObject;

        //        StartCoroutine(waitThenSelectObject(b1p2_bb1_a2, 2f));
        //        StartCoroutine(waitThenAddToken("finishedSelectingb1p2_a2", 4f));
        //    }

        //    //Then Dresha rotates again
        //    else if (!rotatedOnceWrongFace && ConversationTrigger.GetToken("finishedConst_13"))
        //    {
        //        rotatedOnceWrongFace = true;
        //        // move camera so player can see how the part is aligned as it's rotated
        //        StartCoroutine(waitThenMoveCamera(39.7f, -3.1f, 0f, -85.65f, 96.72f, 19.76f, 1f, 1f));

        //        StartCoroutine(rotateWrongFaceScript());
        //    }

        //    //Then Dresha tries to attach to wrong black area
        //    else if (!attemptedWrongFaceFuse && ConversationTrigger.GetToken("finishedConst_14"))
        //    {
        //        attemptedWrongFaceFuse = true;
        //        fuseEvent.initiateFuse();
        //        StartCoroutine(waitThenAddToken("finishedWrongFaceFuseAttempt", 3f));
        //    }

        //    //Then Dresha selects the correct black area on b1p2
        //    else if (!selectedThirdAC && ConversationTrigger.GetToken("finishedConst_15"))
        //    {
        //        selectedThirdAC = true;
        //        // move camera so the black area to be selected is visible
        //        //StartCoroutine(waitThenMoveCamera(-6.8f, -61.9f, 0f, 1.48f, 17.63f, 51.15f, 1f, 1f));

        //        b1p2_bb1_a1 = b1p2.transform.GetChild(1).gameObject;

        //        StartCoroutine(waitThenSelectObject(b1p2_bb1_a1, 2f));
        //        selectPart.deselectObject(b1p2_bb1_a2);
        //        StartCoroutine(waitThenAddToken("finishedSelectingb1p2_a1", 4f));
        //    }

        //    //Then Dresha tries to fuse with incorrect rotation
        //    else if (!attemptedWrongRotationFuse && ConversationTrigger.GetToken("finishedConst_16"))
        //    {
        //        attemptedWrongRotationFuse = true;
        //        StartCoroutine(waitThenInitiateFuse(1f));
        //        StartCoroutine(waitThenAddToken("finishedWrongRotationFuseAttempt", 2f));
        //    }

        //    //Then Dresha enables your controls
        //    else if (!enabledControls && ConversationTrigger.GetToken("finishedConst_17"))
        //    {
        //        enabledControls = true;
        //        bottomPanel.blocksRaycasts = true;
        //        cameraControls.controlsDisabled = false;
        //        rotationScript.controlsDisabled = false;
        //        selectPart.controlsDisabled = false;
        //        enableControlsAndAddToken("finishedEnablingControls");
        //    }
        //    // Once player attaches their first part, Dresha congratulates them

        //    // Once player finishes building, Dresha says we've got more batteries to build
    }