private QuestData HandlingQuestData(QuestSaveData questData) { TalkerData questGiver = DialogueManager.Instance.Talkers[questData.originalGiverID]; if (!questGiver) { return(null); } QuestData quest = questGiver.questInstances.Find(x => x.Model.ID == questData.questID); if (!quest) { return(null); } AcceptQuest(quest); foreach (ObjectiveSaveData od in questData.objectiveDatas) { foreach (ObjectiveData o in quest.Objectives) { if (o.ID == od.objectiveID) { o.CurrentAmount = od.currentAmount; break; } } } return(quest); }
private void GatherQuestsData() { QuestSystem questSystem = GameObject.Find("QuestSystem").GetComponent <QuestSystem>(); var gameQuests = questSystem.GetQuestsList(); quests = new QuestSaveData[gameQuests.Count]; for (int i = 0; i < quests.Length; i++) { quests[i] = new QuestSaveData(gameQuests[i].Tag, gameQuests[i].Description, gameQuests[i].IsFinished); } }
public void LoadFromSave(QuestSaveData data) { IsComplete = data.IsCompleted; _progress = data.Progress; }
//Function called from SaveLoadManager.cs to load in saved quest data public void LoadQuestLogData(List <string> qSave_) { //Looping through each quest save data class that was loaded foreach (string loadQuest in qSave_) { //De-serializing the loaded quest string to a QuestSaveData class QuestSaveData questData = JsonUtility.FromJson(loadQuest, typeof(QuestSaveData)) as QuestSaveData; //Creating a new quest to hold the laoded data Quest q = new Quest(); //Setting all of the basic quest info q.questName = questData.questName; q.questDescription = questData.questDescription; q.isQuestFailed = questData.isQuestFailed; q.canBeAbandoned = questData.canBeAbandoned; q.questTimeHours = questData.questHours; q.currentHours = questData.currentHours; q.failOnTimeReached = questData.failOnTimeReached; if (questData.turnInLocationObj == "") { q.turnInQuestLoaction = null; } else { PrefabIDTagData turnInLocData = JsonUtility.FromJson(questData.turnInLocationObj, typeof(PrefabIDTagData)) as PrefabIDTagData; GameObject turnInLocObj = IDManager.globalReference.GetPrefabFromID(turnInLocData.objType, turnInLocData.iDNumber); q.turnInQuestLoaction = turnInLocObj.GetComponent <MapLocation>(); } //Looping through all of our travel destinations q.destinationList = new List <QuestTravelDestination>(); for (int td = 0; td < questData.travelDestinations.Count; ++td) { //Getting a new quest destination class to add to our quest's list QuestTravelDestination questDestination = new QuestTravelDestination(); //Getting the map location for this destination string loadLoc = questData.travelDestinations[td]; PrefabIDTagData mapLocData = JsonUtility.FromJson(loadLoc, typeof(PrefabIDTagData)) as PrefabIDTagData; GameObject mapLocObj = IDManager.globalReference.GetPrefabFromID(mapLocData.objType, mapLocData.iDNumber); questDestination.requiredLocation = mapLocObj.GetComponent <MapLocation>(); questDestination.locationVisited = questData.destinationTraveledTo[td]; //Adding the quest destination to our quest q.destinationList.Add(questDestination); } //Looping through all of our kill lists q.killList = new List <QuestKillRequirement>(); for (int kr = 0; kr < questData.killTargets.Count; ++kr) { //Getting a new quest kill class to add to our quest's list QuestKillRequirement questKill = new QuestKillRequirement(); //Getting the character to kill for this requirement string loadKill = questData.killTargets[kr]; GameObjectSerializationWrapper targetObj = JsonUtility.FromJson(loadKill, typeof(GameObjectSerializationWrapper)) as GameObjectSerializationWrapper; questKill.killableEnemy = targetObj.objToSave.GetComponent <Character>(); questKill.killsRequired = questData.requiredKillAmount[kr]; questKill.currentKills = questData.currentKillAmount[kr]; //Adding the kill requirement to our quest q.killList.Add(questKill); } //Looping through all of our fetch items q.fetchList = new List <QuestFetchItems>(); for (int fi = 0; fi < questData.fetchItems.Count; ++fi) { //Getting a new fetch item class to add to our quest's list QuestFetchItems questFetch = new QuestFetchItems(); //Getting the item to collect for this requirement string loadItem = questData.fetchItems[fi]; PrefabIDTagData itemData = JsonUtility.FromJson(loadItem, typeof(PrefabIDTagData)) as PrefabIDTagData; GameObject itemObj = IDManager.globalReference.GetPrefabFromID(itemData.objType, itemData.iDNumber); questFetch.collectableItem = itemObj.GetComponent <Item>(); questFetch.itemsRequired = questData.requiredItemAmount[fi]; questFetch.currentItems = questData.currentItemAmount[fi]; //Adding the item requirement to our quest q.fetchList.Add(questFetch); } //Looping through all of our escort characters q.escortList = new List <QuestEscortCharacter>(); for (int ec = 0; ec < questData.escortCharacters.Count; ++ec) { //Getting a new escort class to add to our quest's list QuestEscortCharacter questEscort = new QuestEscortCharacter(); //Getting the character to escort for this requirement string loadChar = questData.escortCharacters[ec]; GameObjectSerializationWrapper charObj = JsonUtility.FromJson(loadChar, typeof(GameObjectSerializationWrapper)) as GameObjectSerializationWrapper; questEscort.characterToEscort = charObj.objToSave.GetComponent <Character>(); questEscort.isCharacterDead = questData.areEscortsDead[ec]; //Adding the escort requirement to our quest q.escortList.Add(questEscort); } //Looping through all of our item rewards q.itemRewards = new List <QuestItemReward>(); for (int ir = 0; ir < questData.itemRewards.Count; ++ir) { //Getting a new item reward class to add to our quest's list QuestItemReward itemReward = new QuestItemReward(); //Getting the item that is awarded string loadItem = questData.itemRewards[ir]; PrefabIDTagData itemData = JsonUtility.FromJson(loadItem, typeof(PrefabIDTagData)) as PrefabIDTagData; GameObject itemObj = IDManager.globalReference.GetPrefabFromID(itemData.objType, itemData.iDNumber); itemReward.rewardItem = itemObj.GetComponent <Item>(); itemReward.amount = questData.itemRewardAmounts[ir]; //Adding the item reward to our quest q.itemRewards.Add(itemReward); } //Looping through all of our action rewards q.actionRewards = new List <QuestActionReward>(); for (int ar = 0; ar < questData.actionRewards.Count; ++ar) { //Getting a new action reward class to add to our quest's list QuestActionReward actionReward = new QuestActionReward(); //Getting the action object that is awarded string loadAction = questData.actionRewards[ar]; PrefabIDTagData actionData = JsonUtility.FromJson(loadAction, typeof(PrefabIDTagData)) as PrefabIDTagData; GameObject actionObj = IDManager.globalReference.GetPrefabFromID(actionData.objType, actionData.iDNumber); actionReward.rewardAction = actionObj.GetComponent <Action>(); actionReward.rewardDistribution = questData.actionDistributionTypes[ar]; //Adding the action reward to our quests q.actionRewards.Add(actionReward); } //Adding the loaded quest to our quest log this.questLog.Add(q); } }