Beispiel #1
0
    public void LoadGame(SideMissionSaveData info, Sprite personInfo)
    {
        MissionSaveData temp = JsonUtility.FromJson <MissionSaveData>(info.missionSaveData);

        myHandinSlot.LoadGame(temp);

        p_numWanted = temp.totalNeeded;
        p_itemID    = temp.TurnInItemID;
        Reward      = info.reward;

        nameDisplay.text      = info.name;
        personDisplay.sprite  = personInfo;
        numWantedDisplay.text = p_numWanted.ToString();
        Item tempItem = itemDatabase.GetItem(p_itemID);

        itemDisplay.sprite     = tempItem.itemImage;
        goldRewardDisplay.text = Reward.ToString();

        beforeAcceptGroup.SetActive(info.beforeAcceptGroup);
        HandinGroup.SetActive(info.HandinGroup);
        CompletedGroup.SetActive(info.CompletedGroup);

        if (info.beforeAcceptGroup == false)
        {
            myHandinSlot.SetRequirements(p_itemID, temp.currentHandinNeeded);
            myHandinSlot.overlayImage.sprite = tempItem.itemImage;
            acceptButton.interactable        = false;
        }
    }
Beispiel #2
0
    public void LoadGame(MissionSaveData saveData)
    {
        TurnInItemID        = saveData.TurnInItemID;
        totalNeeded         = saveData.totalNeeded;
        currentHandinNeeded = saveData.currentHandinNeeded;

        quantityDisplay.text = currentHandinNeeded.ToString();
    }
Beispiel #3
0
    public MissionSaveData SaveGame()
    {
        MissionSaveData saveData = new MissionSaveData();

        saveData.currentHandinNeeded = currentHandinNeeded;

        return(saveData);
    }
Beispiel #4
0
    public SideMissionSaveData SaveGame()
    {
        MissionSaveData temp = myHandinSlot.SaveGame();

        temp.TurnInItemID = p_itemID;
        temp.totalNeeded  = p_numWanted;

        SideMissionSaveData saveData = new SideMissionSaveData();

        saveData.missionSaveData = JsonUtility.ToJson(temp);

        saveData.name              = nameDisplay.text;
        saveData.reward            = Reward;
        saveData.beforeAcceptGroup = beforeAcceptGroup.activeSelf;
        saveData.HandinGroup       = HandinGroup.activeSelf;
        saveData.CompletedGroup    = CompletedGroup.activeSelf;

        return(saveData);
    }
Beispiel #5
0
    public void Save(bool onlyOptions)
    {
        // Options
        saveFileData.options.musicVolume         = musicVolume.value;
        saveFileData.options.sfxVolume           = sfxVolume.value;
        saveFileData.options.gameSpeed           = gameSpeed.value;
        saveFileData.options.controlsSet         = controlsSet.value;
        saveFileData.options.controlScheme       = controlScheme.value;
        saveFileData.options.useAnimations       = useAnimations.value;
        saveFileData.options.trueHit             = trueHit.value;
        saveFileData.options.autoEnd             = autoEnd.value;
        saveFileData.options.autoSelectCharacter = autoSelectCharacter.value;

        if (!onlyOptions)
        {
            saveFileData.lastSaveFileIndex = saveIndex.value;
            // Update simple data
            simpleChapterName[saveIndex.value].value = loadMapID.value;
            simpleTotalDays[saveIndex.value].value   = currentTotalDays.value;
            simplePlayTimes[saveIndex.value].value   = currentPlayTime.value;

            // Setup save file data
            SaveData data = new SaveData {
                chapterName = simpleChapterName[saveIndex.value].value,
                totalDays   = simpleTotalDays[saveIndex.value].value,
                playTime    = simplePlayTimes[saveIndex.value].value,
                money       = currentMoney.value,
                scrap       = currentScrap.value
            };

            //Map data
            data.mapData = new MapSavePackage()
            {
                missionString = (currentMission.value != null) ? currentMission.value.uuid : "",
                mapIndex      = mapIndex.value
            };
            for (int i = 0; i < squad1.Count; i++)
            {
                data.mapData.squad1.Add(squad1.values[i].index);
            }
            for (int i = 0; i < squad2.Count; i++)
            {
                data.mapData.squad2.Add(squad2.values[i].index);
            }

            //Player data
            for (int i = 0; i < playerData.stats.Count; i++)
            {
                if (playerData.stats[i].charData == null)
                {
                    continue;
                }
                CharacterSaveData c = new CharacterSaveData();
                c.StoreData(playerData.stats[i], playerData.inventory[i], playerData.skills[i], playerData.baseInfo[i]);
                data.characters.Add(c);
            }
            for (int i = 0; i < playerData.items.Count; i++)
            {
                ItemSaveData item = new ItemSaveData();
                item.StoreData(playerData.items[i]);
                data.items.Add(item);
            }
            for (int i = 0; i < playerData.upgrader.listSize; i++)
            {
                UpgradeSaveData upgrade = new UpgradeSaveData();
                upgrade.StoreData(playerData.upgrader.upgrades[i]);
                data.upgrade.Add(upgrade);
            }
            for (int i = 0; i < playerData.missions.Count; i++)
            {
                MissionSaveData mission = new MissionSaveData();
                mission.StoreData(playerData.missions[i]);
                data.missions.Add(mission);
            }
            saveFileData.saveFiles[saveIndex.value] = data;
        }

        //Write to file
        XmlWriterSettings xmlWriterSettings = new XmlWriterSettings()
        {
            Indent = true
        };
        XmlSerializer serializer = new XmlSerializer(typeof(SavePackage));

        using (XmlWriter xmlWriter = XmlWriter.Create(_savePath, xmlWriterSettings)) {
            serializer.Serialize(xmlWriter, saveFileData);
        }
        if (onlyOptions)
        {
            Debug.Log("Successfully saved the options data!\n" + _savePath);
        }
        else
        {
            Debug.Log("Successfully saved the save data!\n" + _savePath);
        }
    }