Exemplo n.º 1
0
    public void ShowQuestDescription(int index)
    {
        description.SetActive(false);
        GetComponent <UITable>().Reposition();
        Debug.Log(index);
        JournalQuest quest = PlayerSaveData.reference.quests [index];

        Debug.Log(quest.stages [quest.currentStage]);
        description.SetActive(true);
        description.transform.SetSiblingIndex(index + 2);
        description.transform.GetChild(0).GetComponent <UILabel>().text = quest.stages [quest.currentStage].description;
        GetComponent <UITable>().Reposition();
    }
Exemplo n.º 2
0
    public IEnumerator Load(int index)
    {
        if (IsSaveExists(index))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/Save" + index.ToString() + ".sav", FileMode.Open);

            SaveData saveData = (SaveData)bf.Deserialize(file);

            //load quests data
            quests.Clear();
            foreach (QuestData data in saveData.quests)
            {
                Debug.Log(data.index);
                JournalQuest quest = JournalQuestsDatabase.reference.FindByIndex(data.index);
                quest.currentStage = data.currentStage;
                quests.Add(quest);
            }

            //load time data
            time.minutes = saveData.time.minutes;

            //load passengers data
            passengerData.passengers = saveData.passengerData.passengers;

            //load train equipment data
            InventorySystem.reference.Clear();
            yield return(null);

            for (int itemIndex = 0; itemIndex < saveData.equippedItems.Length; itemIndex++)
            {
                ItemData equippedItemData = saveData.equippedItems[itemIndex];
                if (equippedItemData.index != -1)
                {
                    Debug.Log("loading item index is " + equippedItemData.index);

                    InventorySystem.reference.InitItem(ItemDatabase.reference.FindByIndex(equippedItemData.index), InventorySystem.SlotType.Equipment);
                    trainData.equippedItems[itemIndex].info.durabilityInfo.current = trainData.equippedItems[itemIndex].info.durabilityInfo.max * equippedItemData.currentDurabilityPercent / 100;
                }
            }

            //load wagon items data
            foreach (WagonData data in wagonData)
            {
                data.items.Clear();
            }

            foreach (ItemData itemData in saveData.items)
            {
                InventorySystem.reference.InitItem(ItemDatabase.reference.FindByIndex(itemData.index), InventorySystem.SlotType.Wagon, itemData.wagonIndex, itemData.slotIndex);
                InventoryItem itemInfo = wagonData[itemData.wagonIndex].items[wagonData[itemData.wagonIndex].items.Count - 1].info;
                itemInfo.durabilityInfo.current = itemInfo.durabilityInfo.max * itemData.currentDurabilityPercent / 100;
            }

            townName = saveData.townName;
            LoadTownInfo(townName);

            MailQuestsController.reference.timeForQuest = saveData.worldData.mailData.remainingTime;
            MailQuestsController.reference.canComplete  = saveData.worldData.mailData.canComplete;
            MailQuestsController.reference.inProgress   = saveData.worldData.mailData.inProgress;

            QuestsController.globalParameters = saveData.questParameters;


            file.Close();
            Debug.Log("Loaded!");
        }
        yield return(true);
    }
 public int GetIndexOf(JournalQuest quest)
 {
     return(quests.IndexOf(quest));
 }