SetValue() public method

public SetValue ( string variableName, Yarn value ) : void
variableName string
value Yarn
return void
示例#1
0
    void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        if (loadingGame)
        {
            // Provide binary formatter a stream of bytes to read and create a save object from
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/gamesave.save", FileMode.Open);
            Save            save = (Save)bf.Deserialize(file);
            file.Close();

            foreach (var condition in save.sceneVars)
            {
                SceneItemManager.sceneItems.loadConditionStatuses[condition.loadIfThisVarTrue] = condition.varStatus;
            }

            player = FindObjectOfType <Player>();
            player.transform.position = new Vector3(save.playerX, save.playerY);

            dialogueVars = FindObjectOfType <ExampleVariableStorage>();
            for (int i = 0; i < save.dialogueVars.Count; i++)
            {
                object value;
                ExampleVariableStorage.SaveVariable variable = save.dialogueVars[i];

                switch (variable.type)
                {
                case Yarn.Value.Type.Number:
                    value = variable.valueAsFloat;
                    break;

                case Yarn.Value.Type.String:
                    value = variable.valueAsString;
                    break;

                case Yarn.Value.Type.Bool:
                    value = variable.valueAsBool;
                    break;

                case Yarn.Value.Type.Null:
                    value = null;
                    break;

                default:
                    throw new System.ArgumentOutOfRangeException();
                }

                var v = new Yarn.Value(value);

                dialogueVars.SetValue(variable.name, v);
            }



            FindObjectOfType <DialogueRunner>().dialogue.visitedNodes = save.nodesVisited;

            loadingGame = false;
        }
    }
示例#2
0
    public void ResetEmotions()
    {
        gameEmotion = "nuetral";
        var True  = new Yarn.Value(true);
        var False = new Yarn.Value(false);

        variableStorage.SetValue("$Happy", False);
        variableStorage.SetValue("$Sad", False);
        variableStorage.SetValue("$Angry", False);
    }
    void InitializeYarnVariables()
    {
        Yarn.Value.Type boolType   = Yarn.Value.Type.Bool;
        Yarn.Value.Type stringType = Yarn.Value.Type.String;

        ExampleVariableStorage varStorage = _dialogueSystem.GetComponent <ExampleVariableStorage>(); //GameObject.Find ("DialogueSystem").GetComponent<ExampleVariableStorage>();

        // Create the base Yarn variables such as $CRIMESCENE, $VICTIM, $SUSPECT, $METHOD, $CRIMELOCATION, $TruthTeller1, 2, $PilotMention, $CookMention etc
        ExampleVariableStorage.DefaultVariable crimeSceneTDV    = new ExampleVariableStorage.DefaultVariable();
        ExampleVariableStorage.DefaultVariable victimTDV        = new ExampleVariableStorage.DefaultVariable();
        ExampleVariableStorage.DefaultVariable suspectTDV       = new ExampleVariableStorage.DefaultVariable();
        ExampleVariableStorage.DefaultVariable murderMethodTDV  = new ExampleVariableStorage.DefaultVariable();
        ExampleVariableStorage.DefaultVariable crimeLocationTDV = new ExampleVariableStorage.DefaultVariable();
        // Start of TT and Mention Variables
        ExampleVariableStorage.DefaultVariable truthTeller1TDV     = new ExampleVariableStorage.DefaultVariable();
        ExampleVariableStorage.DefaultVariable truthTeller2TDV     = new ExampleVariableStorage.DefaultVariable();
        ExampleVariableStorage.DefaultVariable misleadingCrewTDV   = new ExampleVariableStorage.DefaultVariable();
        ExampleVariableStorage.DefaultVariable cookMentionTDV      = new ExampleVariableStorage.DefaultVariable();
        ExampleVariableStorage.DefaultVariable engineerMentionTDV  = new ExampleVariableStorage.DefaultVariable();
        ExampleVariableStorage.DefaultVariable firstMateMentionTDV = new ExampleVariableStorage.DefaultVariable();
        ExampleVariableStorage.DefaultVariable medicMentionTDV     = new ExampleVariableStorage.DefaultVariable();
        ExampleVariableStorage.DefaultVariable pilotMentionTDV     = new ExampleVariableStorage.DefaultVariable();
        // Create the InterviewB mention variables
        ExampleVariableStorage.DefaultVariable tt1InterviewBOpenTDV        = new ExampleVariableStorage.DefaultVariable();
        ExampleVariableStorage.DefaultVariable tt2InterviewBOpenTDV        = new ExampleVariableStorage.DefaultVariable();
        ExampleVariableStorage.DefaultVariable misleadingInterviewBOpenTDV = new ExampleVariableStorage.DefaultVariable();
        ExampleVariableStorage.DefaultVariable culpritInterviewBOpenTDV    = new ExampleVariableStorage.DefaultVariable();
        // Create variables to track locked state of Interviews A and B for each crew member
        // ExampleVariableStorage.DefaultVariable firstMateIntAlockedTDV = new ExampleVariableStorage.DefaultVariable();
        // ExampleVariableStorage.DefaultVariable firstMateIntBlockedTDV = new ExampleVariableStorage.DefaultVariable();
        // ExampleVariableStorage.DefaultVariable cookIntAlockedTDV = new ExampleVariableStorage.DefaultVariable();
        // ExampleVariableStorage.DefaultVariable cookIntBlockedTDV = new ExampleVariableStorage.DefaultVariable();
        // ExampleVariableStorage.DefaultVariable engineerIntAlockedTDV = new ExampleVariableStorage.DefaultVariable();
        // ExampleVariableStorage.DefaultVariable engineerIntBlockedTDV = new ExampleVariableStorage.DefaultVariable();
        // ExampleVariableStorage.DefaultVariable medicIntAlockedTDV = new ExampleVariableStorage.DefaultVariable();
        // ExampleVariableStorage.DefaultVariable medicIntBlockedTDV = new ExampleVariableStorage.DefaultVariable();
        // ExampleVariableStorage.DefaultVariable pilotIntAlockedTDV = new ExampleVariableStorage.DefaultVariable();
        // ExampleVariableStorage.DefaultVariable pilotIntBlockedTDV = new ExampleVariableStorage.DefaultVariable();

        // Assign the types for the variables
        crimeSceneTDV.type   = stringType;
        victimTDV.type       = stringType;
        suspectTDV.type      = stringType;
        murderMethodTDV.type = stringType;
        // Assign the TT and Mention variable types
        truthTeller1TDV.type     = stringType;
        truthTeller2TDV.type     = stringType;
        misleadingCrewTDV.type   = stringType;
        cookMentionTDV.type      = stringType;
        engineerMentionTDV.type  = stringType;
        firstMateMentionTDV.type = stringType;
        medicMentionTDV.type     = stringType;
        pilotMentionTDV.type     = stringType;
        // Assign the InterviewB mention types
        tt1InterviewBOpenTDV.type        = stringType;
        tt2InterviewBOpenTDV.type        = stringType;
        misleadingInterviewBOpenTDV.type = stringType;
        culpritInterviewBOpenTDV.type    = stringType;
        // Assign the types for the Blocked Interview variables
        // firstMateIntAlockedTDV.type = stringType;
        // firstMateIntBlockedTDV.type = stringType;
        // cookIntAlockedTDV.type = stringType;
        // cookIntBlockedTDV.type = stringType;
        // engineerIntAlockedTDV.type = stringType;
        // engineerIntBlockedTDV.type = stringType;
        // medicIntAlockedTDV.type = stringType;
        // medicIntBlockedTDV.type = stringType;
        // pilotIntAlockedTDV.type = stringType;
        // pilotIntBlockedTDV.type = stringType;

        // Assign the names for these variables, this is the names that will be used to access them in Yarn
        crimeSceneTDV.name   = "$CRIMESCENE";
        victimTDV.name       = "$VICTIM";
        suspectTDV.name      = "$SUSPECT";
        murderMethodTDV.name = "$MURDERMETHOD";
        // Assign the names for the TT and Mention Variables
        truthTeller1TDV.name     = "$TruthTeller1";
        truthTeller2TDV.name     = "$TruthTeller2";
        misleadingCrewTDV.name   = "$MisleadingCrew";
        cookMentionTDV.name      = "$CookMention";
        engineerMentionTDV.name  = "$EngineerMention";
        firstMateMentionTDV.name = "$FirstMateMention";
        medicMentionTDV.name     = "$MedicMention";
        pilotMentionTDV.name     = "$PilotMention";
        // Assign the names for the InterviewB variables
        tt1InterviewBOpenTDV.name        = "$TT1InterviewBOpen";
        tt2InterviewBOpenTDV.name        = "$TT2InterviewBOpen";
        misleadingInterviewBOpenTDV.name = "$MisleadingInterviewBOpen";
        culpritInterviewBOpenTDV.name    = "$SuspectInterviewBOpen";
        // Assign the names for the locked interviews
        // firstMateIntAlockedTDV.name = "$FirstMateIntAlocked";
        // firstMateIntBlockedTDV.name = "$FirstMateIntBlocked";
        // cookIntAlockedTDV.name = "$CookIntAlocked";
        // cookIntBlockedTDV.name = "$CookIntBlocked";
        // engineerIntAlockedTDV.name = "$EngineerIntAlocked";
        // engineerIntBlockedTDV.name = "$EngineerIntBlocked";
        // medicIntAlockedTDV.name = "$MedicIntAlocked";
        // medicIntBlockedTDV.name = "$MedicIntBlocked";
        // pilotIntAlockedTDV.name = "$PilotIntAlocked";
        // pilotIntBlockedTDV.name = "$PilotIntBlocked";

        // Assign the values that will be held in these yarn Variables
        crimeSceneTDV.value   = MurderLocation;
        victimTDV.value       = Victim;
        suspectTDV.value      = Culprit;
        murderMethodTDV.value = MurderMethod;
        // Assign the values that will be held in the TT1, TT2 and mention yarn Variables
        truthTeller1TDV.value     = TruthTeller1;
        truthTeller2TDV.value     = TruthTeller2;
        misleadingCrewTDV.value   = MisleadingCrewMember;
        cookMentionTDV.value      = "false";
        engineerMentionTDV.value  = "false";
        firstMateMentionTDV.value = "false";
        medicMentionTDV.value     = "false";
        pilotMentionTDV.value     = "false";
        // Assign the values that will be held in InterviewB variables
        tt1InterviewBOpenTDV.value        = "false";
        tt2InterviewBOpenTDV.value        = "false";
        misleadingInterviewBOpenTDV.value = "false";
        culpritInterviewBOpenTDV.value    = "false";
        // Assign the values that will be held in crewIntA/B lock variables
        // firstMateIntAlockedTDV.value = "false";
        // firstMateIntBlockedTDV.value = "false";
        // cookIntAlockedTDV.value = "false";
        // cookIntBlockedTDV.value = "false";
        // engineerIntAlockedTDV.value = "false";
        // engineerIntBlockedTDV.value = "false";
        // medicIntAlockedTDV.value = "false";
        // medicIntBlockedTDV.value = "false";
        // pilotIntAlockedTDV.value = "false";
        // pilotIntBlockedTDV.value = "false";


        // Add each of these created Yarn Variables to our List that will hold them all
        varStorage.defaultVariables.Add(crimeSceneTDV);
        varStorage.defaultVariables.Add(victimTDV);
        varStorage.defaultVariables.Add(suspectTDV);
        varStorage.defaultVariables.Add(murderMethodTDV);
        // Adding the TT1, TT2 and mention variables to Yarn
        varStorage.defaultVariables.Add(truthTeller1TDV);
        varStorage.defaultVariables.Add(truthTeller2TDV);
        varStorage.defaultVariables.Add(misleadingCrewTDV);
        varStorage.defaultVariables.Add(cookMentionTDV);
        varStorage.defaultVariables.Add(engineerMentionTDV);
        varStorage.defaultVariables.Add(firstMateMentionTDV);
        varStorage.defaultVariables.Add(medicMentionTDV);
        varStorage.defaultVariables.Add(pilotMentionTDV);
        // Adding the InterviewBOpen variables
        varStorage.defaultVariables.Add(tt1InterviewBOpenTDV);
        varStorage.defaultVariables.Add(tt2InterviewBOpenTDV);
        varStorage.defaultVariables.Add(misleadingInterviewBOpenTDV);
        varStorage.defaultVariables.Add(culpritInterviewBOpenTDV);
        // Adding the InterviewLock variables
        // varStorage.defaultVariables.Add(cookIntAlockedTDV);
        // varStorage.defaultVariables.Add(cookIntBlockedTDV);
        // varStorage.defaultVariables.Add(engineerIntAlockedTDV);
        // varStorage.defaultVariables.Add(engineerIntBlockedTDV);
        // varStorage.defaultVariables.Add(firstMateIntAlockedTDV);
        // varStorage.defaultVariables.Add(firstMateIntBlockedTDV);
        // varStorage.defaultVariables.Add(medicIntAlockedTDV);
        // varStorage.defaultVariables.Add(medicIntBlockedTDV);
        // varStorage.defaultVariables.Add(pilotIntAlockedTDV);
        // varStorage.defaultVariables.Add(pilotIntBlockedTDV);


        // Now Actually Set the values
        varStorage.SetValue(crimeSceneTDV.name, new Yarn.Value(MurderLocation));
        varStorage.SetValue(victimTDV.name, new Yarn.Value(Victim));
        varStorage.SetValue(suspectTDV.name, new Yarn.Value(Culprit));
        varStorage.SetValue(murderMethodTDV.name, new Yarn.Value(MurderMethod));
        // Setting the TT1, TT2, and Mention variables
        varStorage.SetValue(truthTeller1TDV.name, new Yarn.Value(TruthTeller1));
        varStorage.SetValue(truthTeller2TDV.name, new Yarn.Value(TruthTeller2));
        varStorage.SetValue(misleadingCrewTDV.name, new Yarn.Value(MisleadingCrewMember));
        varStorage.SetValue(cookMentionTDV.name, new Yarn.Value("no"));
        varStorage.SetValue(engineerMentionTDV.name, new Yarn.Value("no"));
        varStorage.SetValue(firstMateMentionTDV.name, new Yarn.Value("no"));
        varStorage.SetValue(medicMentionTDV.name, new Yarn.Value("no"));
        varStorage.SetValue(pilotMentionTDV.name, new Yarn.Value("no"));
        // Setting the values for InterviewB variables
        varStorage.SetValue(tt1InterviewBOpenTDV.name, new Yarn.Value("false"));
        varStorage.SetValue(tt2InterviewBOpenTDV.name, new Yarn.Value("false"));
        varStorage.SetValue(misleadingInterviewBOpenTDV.name, new Yarn.Value("false"));
        varStorage.SetValue(culpritInterviewBOpenTDV.name, new Yarn.Value("false"));
        // Setting the interview lock variables
        // varStorage.SetValue (cookIntAlockedTDV.name, new Yarn.Value("false"));
        // varStorage.SetValue (cookIntBlockedTDV.name, new Yarn.Value("false"));
        // varStorage.SetValue (engineerIntAlockedTDV.name, new Yarn.Value("false"));
        // varStorage.SetValue (engineerIntBlockedTDV.name, new Yarn.Value("false"));
        // varStorage.SetValue (firstMateIntAlockedTDV.name, new Yarn.Value("false"));
        // varStorage.SetValue (firstMateIntBlockedTDV.name, new Yarn.Value("false"));
        // varStorage.SetValue (medicIntAlockedTDV.name, new Yarn.Value("false"));
        // varStorage.SetValue (medicIntBlockedTDV.name, new Yarn.Value("false"));

        // Go through as many cycles as we need to, in order to ensure that we create the proper yarn variables for each clue in the playthrough ("amountOfVoidClues")
        for (int i = 0; i < AMOUNT_OF_CLUES_PER_PLAYTHROUGH; i++)
        {
            // This integer will be converted to a string and appended to the end of each variable name.
            // E.G Clue1, Clue2, Clue3 etc
            int index = i + 1;


            // Make 4 temporary variables and set it to null everytime we begin the loop. 3 strings and one bool
            ExampleVariableStorage.DefaultVariable clueNameTDV         = new ExampleVariableStorage.DefaultVariable();
            ExampleVariableStorage.DefaultVariable clueRelatedCrew1TDV = new ExampleVariableStorage.DefaultVariable();
            ExampleVariableStorage.DefaultVariable clueRelatedCrew2TDV = new ExampleVariableStorage.DefaultVariable();
            ExampleVariableStorage.DefaultVariable clueFoundTDV        = new ExampleVariableStorage.DefaultVariable();
            ExampleVariableStorage.DefaultVariable clueLocationTDV     = new ExampleVariableStorage.DefaultVariable();

            // Assign the type of values that will be stored in each DefaultVariable type
            clueNameTDV.type         = stringType;
            clueRelatedCrew1TDV.type = stringType;
            clueRelatedCrew2TDV.type = stringType;
            clueFoundTDV.type        = boolType;
            clueLocationTDV.type     = stringType;

            //Assign the name for all of the created temporary variables, this is the name that will pop up in Yarn
            clueNameTDV.name         = "$Clue" + index.ToString(); // Clue1, Clue2 etc the number changes based on the value of i in the for loop
            clueRelatedCrew1TDV.name = "$Clue" + index.ToString() + "Owner1";
            clueRelatedCrew2TDV.name = "$Clue" + index.ToString() + "Owner2";
            clueFoundTDV.name        = "$Clue" + index.ToString() + "Found";
            clueLocationTDV.name     = "$Clue" + index.ToString() + "Location";


            // Assign the default values for each variable. This will be changed in ClueManager once each clue is found
            clueNameTDV.value         = " ";
            clueRelatedCrew1TDV.value = " ";
            clueRelatedCrew2TDV.value = " ";
            clueFoundTDV.value        = "false";
            clueLocationTDV.value     = " ";

            // Add each of these created Yarn Variables to our List that will hold them all
            varStorage.defaultVariables.Add(clueNameTDV);
            varStorage.defaultVariables.Add(clueRelatedCrew1TDV);
            varStorage.defaultVariables.Add(clueRelatedCrew2TDV);
            varStorage.defaultVariables.Add(clueFoundTDV);
            varStorage.defaultVariables.Add(clueLocationTDV);
        }
    }
示例#4
0
    // Update is called once per frame
    void Update()
    {
        if (starting == 0)
        {
            if (debugMode && Input.GetKey(KeyCode.Space)) //Debug Feature, starts the rhythm game. In the future, the rhythm game should be started based on the dialogue script.
            {
                begin();
            }
        }
        if (starting == 1)
        {
            startTimer += Time.deltaTime;
            if (startTimer > 1)
            {
                startScale = Mathf.Lerp(startScale, maxScale, 0.1f);
                if (startScale > maxScale + 0.1f)
                {
                    startScale = maxScale;
                }
                transform.localScale = new Vector2(startScale, startScale);
            }
            if (startTimer > 2 && startTimer < 2.1f)
            {
                fret.startingScaling();
            }
            if (startTimer > 3)
            {
                starting = 2;
            }
        }
        else if (starting == 2)
        {
            if (Input.GetKey(KeyCode.Escape)) //Closes the rhythm game. In the future, this could also pass a value to the dialog manager so characters can comment on how you quit.
            {
                end();
            }
            miss = false;


            float angle = ((2 * Mathf.PI) * ((script.songPosinBeats % 3) / 3));
            //float angle = 0;
            this.transform.localPosition = PointOnCircle(angle, r);
            //Debug.Log(angle);

            //Code for pressing keys
            if (Input.GetKeyDown(KeyCode.W)) //When a key is pressed
            {
                wasdK = "U";                 //Set which one was pressed
                if (!rk)                     //If this is the first key pressed, note that one key has been pressed
                {
                    primed    = true;
                    lk        = true;
                    primeCool = pcN;
                }
                else //If this is the second key pressed, then confirm that a key combination has been entered
                {
                    keyed = true;
                }
            }
            else if (Input.GetKeyDown(KeyCode.A))
            {
                wasdK = "L";
                if (!rk)
                {
                    primed    = true;
                    lk        = true;
                    primeCool = pcN;
                }
                else
                {
                    keyed = true;
                }
            }
            else if (Input.GetKeyDown(KeyCode.S))
            {
                wasdK = "D";
                if (!rk)
                {
                    primed    = true;
                    lk        = true;
                    primeCool = pcN;
                }
                else
                {
                    keyed = true;
                }
            }
            else if (Input.GetKeyDown(KeyCode.D))
            {
                wasdK = "R";
                if (!rk)
                {
                    primed    = true;
                    lk        = true;
                    primeCool = pcN;
                }
                else
                {
                    keyed = true;
                }
            }

            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                arrowK = "U";
                if (!lk)
                {
                    primed    = true;
                    rk        = true;
                    primeCool = pcN;
                }
                else
                {
                    keyed = true;
                }
            }
            else if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                arrowK = "L";
                if (!lk)
                {
                    primed    = true;
                    rk        = true;
                    primeCool = pcN;
                }
                else
                {
                    keyed = true;
                }
            }
            else if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                arrowK = "D";
                if (!lk)
                {
                    primed    = true;
                    rk        = true;
                    primeCool = pcN;
                }
                else
                {
                    keyed = true;
                }
            }
            else if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                arrowK = "R";
                if (!lk)
                {
                    primed    = true;
                    rk        = true;
                    primeCool = pcN;
                }
                else
                {
                    keyed = true;
                }
            }

            //A key is pressed
            if (keyed && cooldown <= 0)
            {
                lk   = false;
                rk   = false;
                keys = wasdK + arrowK;
                pressedKeyText.text = keys;
                if (inZone == true) //If the timing is correct
                {
                    //fret.noteRipple();
                    fret.noteRippleParticles();
                    if (keys.Equals(target)) //If the note is correct, add score and trigger feedback
                    {
                        //score++;
                        //Debug.Log(score);

                        inZone = false;
                        fret.fretHit(true);
                        hit = true;
                        //fret.noteRipple(true);
                    }
                    else //Otherwise trigger negative feedback
                    {
                        fret.fretHit(false);
                        //score--;
                        strikes += 1;
                        miss     = true;
                        //fret.noteRipple(false);
                    }
                }
                // else //Timing incorrect, negative feedback
                // {
                //     fret.fretHit(false);
                //     //score--;
                //     miss = true;
                //     strikes += 1;
                // }
                cooldown = cN;
                primed   = false;
                keyed    = false;
                wasdK    = "";
            }

            cooldown -= Time.deltaTime;

            if (primed && inZone) //If one note has been pressed, trigger a miss if no other note is pressed within 0.1 seconds
            {
                if (primeCool <= 0)
                {
                    Debug.Log("Decrementing the score within primed");
                    fret.fretHit(false);
                    primed = false;
                    lk     = false;
                    rk     = false;
                    wasdK  = "";
                    arrowK = "";
                    //score--;
                    //strikes += 1;
                    hit = false;
                }
                primeCool -= Time.deltaTime;
            }

            if (strikes > 0)
            {
                lifeSprite5.SetActive(false);
            }
            if (strikes > 1)
            {
                lifeSprite4.SetActive(false);
            }
            if (strikes > 2)
            {
                lifeSprite3.SetActive(false);
            }
            if (strikes > 3)
            {
                lifeSprite2.SetActive(false);
            }
            if (strikes > 4)
            {
                lifeSprite1.SetActive(false);
            }

            phaseCheck();
            phaseText.text = "Phase: " + phase;
            //if (phase == 2)
            //scoreText.text = "Lives: " + (3 - strikes);
            //else
            //scoreText.text = ""+score;
            //scoreText.text = "";
            scoreText.text = "" + score + "/" + songNoteLength;

            if (score >= songNoteLength)
            {
                //You win, pass a value to dialogue
                varStor.SetValue("$completedRhythm", new Yarn.Value(1));
                starting = 3;
                endTimer = 0;
            }
        }
        if (starting == 3) //The end, wait 3 seconds before closing to give the song time to close out.
        {
            this.transform.position = PointOnCircle(0, r);
            if (endTimer > 3)
            {
                end();
            }
            else if (endTimer > 1)
            {
                if (endTimer < 1.1f)
                {
                    foreach (GameObject lifeSprite in lifeSprites)
                    {
                        lifeSprite.SetActive(false);
                    }
                    fret.endingScaling(); //The fret handles it's own scaling process, just has to be told to start scaling down
                }
                startScale = Mathf.Lerp(startScale, 0, 0.1f);
                if (startScale < 0.1f)
                {
                    startScale = 0;
                }
                transform.localScale = new Vector2(startScale, startScale);
            }
            endTimer += Time.deltaTime;
        }
    }
示例#5
0
    public ExampleVariableStorage varStor;       //The example variable storage for the yarn system. Used to tell dialogue when the puzzle is completed.

    // Start is called before the first frame update
    void Start()
    {
        varStor.SetValue("$completedPuzzle", new Yarn.Value(0)); //Set the value to 0 at the start
    }
示例#6
0
 private void Coin_OnSceneChange(int scene)
 {
     VS.SetValue("$money", new Yarn.Value(coins + startCoins));
 }
    public void PopulateYarnVars()
    {
        for (int i = 0; i < _clueInfoOfCollected.Count; i++)
        {
            //Checking if clueInfo we're loading has a tag of "Clue" (set in ClueItem), and making sure it has NOT been added to Yarn's list yet.
            if (_clueInfoOfCollected[i].isClue && !_clueInfoOfCollected[i].addedToYarn)
            {
                // Set the Clue Name in Yarn
                string yarnClueVariableName      = "$Clue" + yarnIndex.ToString();
                string yarnClueFoundVariableName = yarnClueVariableName + "Found";
                // Add the Clue#Owner1 and Clue#Owner2 variables
                string yarnClueOwner1VariableName   = yarnClueVariableName + "Owner1";
                string yarnClueOwner2VariableName   = yarnClueVariableName + "Owner2";
                string yarnClueLocationVariableName = yarnClueVariableName + "Location";
                foreach (ExampleVariableStorage.DefaultVariable c in yarnVarRef.defaultVariables)
                {
                    //TODO make this a switch statement
                    Yarn.Value yarnVal;

                    // Checks for the yarn variable name (Clue#) and sets the appropriate value
                    if (c.name == yarnClueVariableName)
                    {
                        c.value = _clueInfoOfCollected[i].clueName;
                    }


                    // Checks for the yarn variable name related to Clue#Found and sets it to the appropriate value
                    if (c.name == yarnClueFoundVariableName)
                    {
                        c.value = "true";
                    }


                    // Checks if the yarn variable name related to Clue#Owner1 and sets it to the appropriate value
                    if (c.name == yarnClueOwner1VariableName)
                    {
                        //c.value = "Cook";
                        c.value = _clueInfoOfCollected[i].clueOwner1;
                    }


                    // Checks for the yarn variable name related to Clue#Owner2 and sets it to the appropriate value
                    if (c.name == yarnClueOwner2VariableName)
                    {
                        c.value = _clueInfoOfCollected[i].clueOwner2;
                    }


                    // Checks for the yarn variable name related to Clue#Location and sets it to the appropriate value
                    if (c.name == yarnClueLocationVariableName)
                    {
                        c.value = _clueInfoOfCollected[i].location;
                    }

                    if (c.value == "true")
                    {
                        yarnVarRef.SetValue(c.name, new Yarn.Value(true));
                    }
                    else
                    {
                        yarnVarRef.SetValue(c.name, new Yarn.Value(c.value));
                    }
                }
                // Yarn.Value yarnClueValue = new Yarn.Value(_clueInfoOfCollected[i].clueName);
                // yarnClueValue.variableName = yarnClueVariableName;
                //yarnVarRef.SetValue(yarnClueValue.variableName, yarnClueValue);

                //// Set the ClueFound variable in Yarn
                //string yarnClueFound = yarnClueVariableName + "Found";
                //Yarn.Value yarnClueFoundValue = new Yarn.Value("true");
                //yarnClueValue.variableName = yarnClueFound;
                //yarnVarRef.SetValue(yarnClueFoundValue.variableName, yarnClueFoundValue);

                yarnIndex++;
                _clueInfoOfCollected[i] = new ClueInfo(_clueInfoOfCollected[i], true); // F**K THIS LINE!!!!!!
            }
        }
    }