Inheritance: Yarn.Unity.VariableStorageBehaviour
Ejemplo n.º 1
0
    //[SerializeField]
    //private bool touchControlled;

    void Awake()
    {
        music = FMODUnity.RuntimeManager.CreateInstance("event:/Music");

        music.start();

        music.getParameter("Clue", out Clues);

        music.getParameter("Loyalty", out Loyalty);

        Loyalty.setValue(10);

        yarnVarRef = yarnVarRefObj.GetComponent <ExampleVariableStorage>();

        // Populate the Singleton with the followint if and else if statements
        if (S == null)
        {
            S = this;
        }
        else if (S != null)
        {
            Destroy(this);
        }
        //Make sure that the GameObject this is attached to is not deleted on load
        DontDestroyOnLoad(gameObject);
    }
Ejemplo n.º 2
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;
        }
    }
Ejemplo n.º 3
0
    private ExampleVariableStorage EVS;     //Cache class reference since get component calls are not free

    // Use this for initialization
    void Start()
    {
        displayText = gameObject.GetComponent <Text>();

        dialogue = SceneChanger.Yarn;
        EVS      = dialogue.GetComponent <ExampleVariableStorage>();

        //Only update money when changing scenes, instead of every frame
        SceneChanger.instance.OnSceneChange += UpdateMoney;
    }
Ejemplo n.º 4
0
    void Start()
    {
        EnterFreeState();

        inputManager = GetComponent <GAME_input_manager> ();
        //inventoryManager = GetComponent<GAME_inventory_manager> ();
        menuManager            = GetComponent <GAME_menu_manager> ();
        dialogRunner           = GetComponent <Yarn.Unity.DialogueRunner> ();
        variableStorageManager = GetComponent <ExampleVariableStorage> ();
        yarnUIManager          = GetComponent <YARN_ui_manager> ();
    }
Ejemplo n.º 5
0
    public void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);

        inventory                 = FindObjectOfType <Inventory>();
        player                    = FindObjectOfType <Player>();
        dialogueVars              = FindObjectOfType <ExampleVariableStorage>();
        SceneManager.sceneLoaded += OnSceneLoaded;
    }
Ejemplo n.º 6
0
    void Start()
    {
        VS = SceneChanger.instance.GetComponentInChildren <ExampleVariableStorage>();

        //Get coin count from yarn variable
        var m = VS.GetValue("$money");

        startCoins   = (int)m.AsNumber;
        displayCoins = startCoins;

        //Add ill gotten gains to yarn var
        SceneChanger.instance.OnSceneChange += Coin_OnSceneChange;

        myChild = GetComponentInChildren <Text>();

        //Set initial coins
        if (myChild)
        {
            myChild.text = TotalCoins() > 0 ? "$" + TotalCoins() : "u broke";
        }
    }
 void Start()
 {
     yarnVarRef = dialogueSystem.GetComponent <ExampleVariableStorage>();
     //InitializeVariableStorage ();
     InitializeYarnVariables();
 }
    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);
        }
    }