private int GetTriggeredWarbler()
    {
        Yarn.Unity.InMemoryVariableStorage questMemory = Services.DialogueController.InMemoryVariableStorage;
        bool foundChild1 = questMemory.GetValue(Str.Child1String).AsBool;
        bool foundChild2 = questMemory.GetValue(Str.Child2String).AsBool;
        bool foundChild3 = questMemory.GetValue(Str.Child3String).AsBool;

        if (foundChild1 && !warblerFound[0])
        {
            warblerFound[0] = true;
            return(0);
        }
        else if (foundChild2 && !warblerFound[1])
        {
            warblerFound[1] = true;
            return(1);
        }
        else if (foundChild3 && !warblerFound[2])
        {
            warblerFound[2] = true;
            return(2);
        }

        Logger.Warning("No warblers have been found, yet GetTriggeredWarbler was called");
        return(0);
    }
Example #2
0
    public IEnumerator LoadDataCO()
    {
        loadingSave = true;
        //DeserializeJson(saveName);
        Data data = DeserializeData(Str.SaveName);

        Yarn.Unity.InMemoryVariableStorage questMemory = Services.DialogueController.InMemoryVariableStorage;
        questMemory.SetValue(Str.Child1String, data.warblerChildrenStatus.foundChild1);
        questMemory.SetValue(Str.Child2String, data.warblerChildrenStatus.foundChild2);
        questMemory.SetValue(Str.Child3String, data.warblerChildrenStatus.foundChild3);

        questMemory.SetValue(Str.SeedString, data.itemStatus.foundSeed);
        questMemory.SetValue(Str.SoilString, data.itemStatus.foundSoil);
        questMemory.SetValue(Str.RainString, data.itemStatus.foundRain);

        seedItem.transform.position = ToVec3(data.itemStatus.seedPos);
        soilItem.transform.position = ToVec3(data.itemStatus.soilPos);
        rainItem.transform.position = ToVec3(data.itemStatus.rainPos);

        if (data.playerHolding.itemHolding != QuestItem.QuestItemEnum.None)
        {
            QuestItem holding = null;
            switch (data.playerHolding.itemHolding)
            {
            case QuestItem.QuestItemEnum.Seed:
                holding = seedItem;
                break;

            case QuestItem.QuestItemEnum.Soil:
                holding = soilItem;
                break;

            case QuestItem.QuestItemEnum.Rain:
                holding = rainItem;
                break;

            case QuestItem.QuestItemEnum.None:
                Logger.Warning("Thought to be holding quest item, holding None quest item");
                break;
            }
            Services.PlayerItemHolder.AttachToTransform(holding);
        }

        Services.PlayerMovement.ForceTransform(ToVec3(data.playerData.position), ToQuat(data.playerData.rotation));

        foreach (QuestStageData questStageData in data.questStageData)
        {
            for (int i = 0; i < questStageData.stage; i++)
            {
                QuestManager.AdvanceQuest(questStageData.quest);
                yield return(null);
            }
        }
        yield return(null);

        loadingSave = false;
    }
 //get the references to the dialouge runner on the Gameobject
 private void Start()
 {
     instance = GameObject.Find("Dialogue/Dialogue Runner").GetComponent <InMemoryVariableStorage>();
 }
Example #4
0
    public void SaveData()
    {
        return;

        Logger.Warning("Saving data...");
        QuestStageData[] questStagesArray =
        {
            new QuestStageData {
                quest = Str.Main, stage = mainQuest.QuestStage
            },
            new QuestStageData {
                quest = Str.Warbler, stage = warblerQuest.QuestStage
            },
            new QuestStageData {
                quest = Str.Frog, stage = frogQuest.QuestStage
            },
            new QuestStageData {
                quest = Str.Turtle, stage = turtleQuest.QuestStage
            }
        };

        PlayerData playerData = new PlayerData
        {
            position = ToArray(Services.PlayerMovement.transform.position),
            rotation = ToArray(Services.PlayerMovement.transform.rotation)
        };

        PlayerHolding playerHolding = new PlayerHolding {
            itemHolding = Services.PlayerItemHolder._holdingItem ?
                          Services.PlayerItemHolder._currentlyHeldItem.GetComponent <QuestItem>().itemEnum :
                          QuestItem.QuestItemEnum.None
        };

        Yarn.Unity.InMemoryVariableStorage questMemory = Services.DialogueController.InMemoryVariableStorage;

        WarblerChildrenStatus warblerChildrenStatus = new WarblerChildrenStatus {
            foundChild1 = questMemory.GetValue(Str.Child1String).AsBool,
            foundChild2 = questMemory.GetValue(Str.Child2String).AsBool,
            foundChild3 = questMemory.GetValue(Str.Child3String).AsBool
        };

        ItemStatus itemStatus = new ItemStatus {
            foundSeed = questMemory.GetValue(Str.SeedString).AsBool,
            foundSoil = questMemory.GetValue(Str.SoilString).AsBool,
            foundRain = questMemory.GetValue(Str.RainString).AsBool,
            seedPos   = ToArray(seedItem.transform.position),
            soilPos   = ToArray(soilItem.transform.position),
            rainPos   = ToArray(rainItem.transform.position)
        };

        Data saveData = new Data {
            questStageData        = questStagesArray,
            playerData            = playerData,
            playerHolding         = playerHolding,
            warblerChildrenStatus = warblerChildrenStatus,
            itemStatus            = itemStatus
        };

        SerializeData(Str.SaveName, saveData);

        //SerializeJson(saveName, saveData);
        Logger.Warning("Data saved successfully.");
    }