예제 #1
0
    public void SaveForest()
    {
        //get save file
        SaveGame prev_save;

        if (SaveGameSystem.DoesSaveGameExist(savePath) && SaveGameSystem.LoadGame(savePath) != null)
        {
            prev_save = SaveGameSystem.LoadGame(savePath);
        }

        else
        {
            prev_save        = new SaveGame();
            prev_save.data   = 500;
            prev_save.forest = new TreeData[treeGen.forestSize];
        }


        //update save file
        prev_save.data += 1;
        foreach (Tree tree in treeGen.forest)
        {
            prev_save.forest[tree.potNum] = new TreeData(tree);
        }
        SaveGameSystem.SaveGame(prev_save, savePath);
        Debug.Log("saved forest");
        flashPanel.GetComponent <Flash>().flashFor(0.5f);
    }
예제 #2
0
    public void load()
    {
        SaveGame prev_save;

        if (SaveGameSystem.DoesSaveGameExist(savePath) && SaveGameSystem.LoadGame(savePath) != null)
        {
            prev_save = SaveGameSystem.LoadGame(savePath);
            Debug.Log("found prev save. data: " + prev_save.data + "forestSize: " + prev_save.forest.Length);
            //if no trees are planted in the forest, generate a new bunch
            if (prev_save.forest[0] == null && treeGen.forest[0] == null)
            {
                treeGen.makeAForest();
            }

            else
            {
                treeGen.plantForest(prev_save.forest);
            }
        }
        else
        {
            Debug.Log("no prev save found");
            treeGen.makeAForest();
        }
    }
예제 #3
0
    public void loadAlmanac()
    {
        SaveGame prev_save;

        if (SaveGameSystem.DoesSaveGameExist(savePath) && SaveGameSystem.LoadGame(savePath) != null)
        {
            prev_save = SaveGameSystem.LoadGame(savePath);
            Debug.Log("found prev save. data: " + prev_save.data + "forestSize: " + prev_save.forest.Length);

            //get saved almanac
            if (prev_save.almanac != null)
            {
                for (int i = 0; i < prev_save.almanac.Length; i++)
                {
                    if (prev_save.almanac[i])
                    {
                        Almanac.loadFoundSpecies((Species)Almanac.speciesTypes[i]);
                    }
                }
            }
        }
        else
        {
            Debug.Log("no prev save found");
        }
    }
예제 #4
0
    public static void SaveAlmanac()
    {
        //get save file
        SaveGame prev_save;

        if (SaveGameSystem.DoesSaveGameExist(savePath) && SaveGameSystem.LoadGame(savePath) != null)
        {
            prev_save = SaveGameSystem.LoadGame(savePath);
        }

        else
        {
            prev_save        = new SaveGame();
            prev_save.data   = 500;
            prev_save.forest = new TreeData[treeGen.forestSize];
        }

        //update save file
        prev_save.almanac = new bool[Almanac.speciesTypes.Count];
        for (int i = 0; i < Almanac.speciesTypes.Count; i++)
        {
            if (((Species)Almanac.speciesTypes[i]).found)
            {
                prev_save.almanac[i] = true;
            }
            else
            {
                prev_save.almanac[i] = false;
            }
        }
        SaveGameSystem.SaveGame(prev_save, savePath);
        Debug.Log("saved almanac");
    }
    public void SaveGame()
    {
        ScenarioData data = CreateScenarioData();
        bool         succ = SaveGameSystem.SaveGame(data, "slot" + GlobalProfile.Slot + "_" + GlobalProfile.GetCurrentSceneName());

        GlobalProfile.getInstance().SaveGame();
    }
예제 #6
0
    public static IEnumerator StartGameScene(int index)
    {
        CustomRun.instance = new CustomRun();
        if (MetaDatas[index] == null)
        {
            MetaDatas[index] = new GameMetaData()
            {
                GameSlot    = index,
                LastPlayed  = DateTime.Now,
                FloorNumber = 1
            };
        }
        instance = new SaveGameSystem(MetaDatas[index]);
        var game  = instance.LoadGameFromFileAsync();
        var async = SceneManager.LoadSceneAsync(SceneConstants.PlayGame);

        async.allowSceneActivation = false;

        while (!async.isDone && !game.IsCompleted)
        {
            yield return(null);
        }
        instance.Game = game.Result;
        async.allowSceneActivation = true;
    }
예제 #7
0
 public void SaveGame()
 {
     SaveGameSystem.SaveGame(messages, "slot" + Slot + "_messages");
     gameSlots.Slots[Slot].scenario = SceneManager.GetActiveScene().buildIndex;
     SaveGameSystem.SaveGame(gameSlots, "slots");
     SaveInventory();
 }
예제 #8
0
    // Volume Loader
    public void LoadVolume()
    {
        GameVolumeData data = SaveGameSystem.LoadVolume();

        musicSlider.value   = data.MusicVolume * 10;
        effectsSlider.value = data.EffectsVolume * 10;
    }
예제 #9
0
    // Use this for initialization
    void Start()
    {
        if (!almanac.isActiveAndEnabled)
        {
            almanac.gameObject.SetActive(true);
            //almanac.gameObject.SetActive(false);
        }

        //TO-DO: load game data, if any exists


        SaveGame g = new SaveGame();

        g.data = 50;
        SaveGameSystem.SaveGame(g, "b");
        SaveGame h = SaveGameSystem.LoadGame("b");

        if (h != null)
        {
            Debug.Log("wpring? " + h.forest.Length);
        }
        else
        {
            Debug.Log("doesnt work");
        }
    }
예제 #10
0
 private void Awake()
 {
     if (SaveGameSystem.CanSaveOrLoad())
     {
         SaveGameSystem.AddPersistentObject(this);
     }
 }
예제 #11
0
    public void load()
    {
        string     svname   = GameObject.Find("panelMenu").gameObject.transform.GetChild(1).GetComponent <InputField>().text;
        MySaveGame loadGame = SaveGameSystem.LoadGame(svname) as MySaveGame;


        numberOfPlayer    = loadGame.numberOfPlayer;
        VPsToWin          = loadGame.VPsToWin;
        barbarianPosition = loadGame.barbarianPosition;
        barbarianAttacked = loadGame.barbarianAttacked;
        barbarianStrength = loadGame.barbarianStrength;
        knightStrength    = loadGame.knightStrength;
        currentPhase      = loadGame.currentPhase;
// pgcard


        List <int> number      = loadGame.numbers;
        List <int> terrians    = loadGame.terrains;
        List <int> harbortypes = loadGame.harbortypes;


        for (int i = 0; i < numberOfPlayer; i++)
        {
            myPlayers._players[i].LoadData(myPlayers._players[i].connectionToClient, svname);
        }
        Debug.Log(loadGame);
        Debug.Log(loadGame.numbers);


        // TODO load
    }
예제 #12
0
    public void LoadOnEventOfYourChoice()
    {
        SaveGameData data = SaveGameSystem.LoadData();

        if (gm == null)
        {
            SceneManager.LoadScene(data.level);
            searchforgamemaster = true;
        }
        else
        {
            //
            gm.quest1 = data.quest1;
            gm.quest2 = data.quest2;
            gm.quest3 = data.quest3;
            //
            gm.healCounter  = data.healCounter;
            gm.enemyCounter = data.enemyCounter;
            //
            gm.Screenshake                 = data.screen_shake_active;
            gm.coins                       = data.coins;
            gm.bow_bought                  = data.bow;
            gm.hp                          = data.health;
            gm.maxHp                       = data.maxHealth;
            gm.healthpotions               = data.healthpotions;
            gm.maxHealthpotions            = data.maxHealthpotions;
            gm.chest_of_everlasting_wealth = data.chestLooted;
            Destroy(this.gameObject);
        }
    }
예제 #13
0
    public void CreateNew()
    {
        if (nameField.text == "")
        {
            Debug.Log("Name field is empty");
        }
        else
        {
            MySaveGame mySaveGame1 = new MySaveGame();
            mySaveGame1.playerName = nameField.text;
            mySaveGame1.species    = currentSpecies;
            mySaveGame1.classID    = currentClass;
            mySaveGame1.faceID     = currentFace;
            mySaveGame1.level      = 1;
            mySaveGame1.currentXP  = 0;

            // we will need to put inventory, skill bar, and talenttree in here
            System.DateTime epochStart = new System.DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc);
            int             cur_time   = (int)(System.DateTime.UtcNow - epochStart).TotalSeconds;
            SaveGameSystem.SaveGame(mySaveGame1, nameField.text + cur_time);

            SM.GetComponent <SceneManager>().CharacterSaveFile = nameField.text + cur_time;

            UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync("NewChar");
            UnityEngine.SceneManagement.SceneManager.LoadSceneAsync("WorldSelect", UnityEngine.SceneManagement.LoadSceneMode.Additive);
        }
    }
예제 #14
0
    public void SaveQuadro()
    {
        QuadroData data = CreateQuadroData();

        SaveGameSystem.SaveGame(data, "slot" + GlobalProfile.Slot + "_quadro");
        GlobalProfile.getInstance().SaveGame();
    }
    // Start is called before the first frame update
    void Start()
    {
        m_PInfo     = GameObject.Find("PersistentStorage").GetComponent <PersistentInfo_Script>();
        m_LocalUser = m_PInfo.m_UserData;
        m_LocalData = SaveGameSystem.LoadGame("LeaderboardData") as LeaderboardData;

        if (m_LocalData != null)
        {
            string top;
            if (m_LocalData.FindUser(m_LocalUser) > -1)
            {
                m_LocalUser = m_LocalData.GetUser(m_LocalUser.m_UserName);
                top         = m_LocalUser.m_UserName + " " + m_LocalUser.m_Score + " Rank: " + m_LocalUser.m_Rank;
            }
            else
            {
                top = "You have not scored yet.";
            }
            ChangeTopText(top);
            PopulateBoard();
        }
        else
        {
            string top = "No Leaderboard Available";
            ChangeTopText(top);
        }
    }
예제 #16
0
    public void createWorld()
    {
        int seedparse;

        if (nameField.text == "")
        {
            Debug.Log("Name field is empty");
        }
        else if (seedField.text == "" || !int.TryParse(seedField.text, out seedparse))
        {
            Debug.Log("Seed is empty or not an integer");
        }
        else
        {
            WorldSave newWorldSave = new WorldSave();
            newWorldSave.explored  = 0;
            newWorldSave.worldName = nameField.text;
            newWorldSave.seed      = seedparse;

            System.DateTime epochStart = new System.DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc);
            int             cur_time   = (int)(System.DateTime.UtcNow - epochStart).TotalSeconds;
            SaveGameSystem.SaveGame(newWorldSave, nameField.text + cur_time);

            SM.GetComponent <SceneManager>().WorldSaveFile = nameField.text + cur_time;

            WorldSelectContinue();
        }
    }
예제 #17
0
    public void LoadCharacter(string filename)
    {
        MySaveGame mySaveGame = SaveGameSystem.LoadGame(filename) as MySaveGame;

        // level = mySaveGame.level;
        // CurrentXP = mySaveGame.currentXP;
        species  = mySaveGame.species;
        face     = mySaveGame.faceID;
        classID  = mySaveGame.classID;
        charName = mySaveGame.playerName;

        // these will be replaced by our save file loading

        CurrentXP  = 0;
        level      = 1;
        ability[0] = 0;
        ability[1] = 1;


        // now that we can load from file,
        // we need to calculate all the side stuff
        // skill tree or class affects

        maxHP   = 100; //
        HPRegen = 1;   //
        MPRegen = 1;   //
        maxXP   = level * level + 1;
    }
예제 #18
0
    public void DeleteSave()
    {
        // O ideal é que apareça um dialoig de confirmação

        GlobalProfile.gameSlots.Slots.Remove(id);
        Destroy(gameObject);

        for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++)
        {
            string name = GetSceneNameByPath(SceneUtility.GetScenePathByBuildIndex(i));
            if (SaveGameSystem.DoesSaveGameExist("slot" + id + "_" + name))
            {
                SaveGameSystem.DeleteSaveGame("slot" + id + "_" + name);
            }
        }
        if (SaveGameSystem.DoesSaveGameExist("slot" + id + "_inventory"))
        {
            SaveGameSystem.DeleteSaveGame("slot" + id + "_inventory");
        }
        if (SaveGameSystem.DoesSaveGameExist("slot" + id + "_messages"))
        {
            SaveGameSystem.DeleteSaveGame("slot" + id + "_messages");
        }


        populate.RemovePage(this);
    }
    public void CreateNewCase()
    {
        Debug.Log("Creating new Case");

        Slot newSlot = new Slot(GlobalProfile.gameSlots.NextID(), 3 /* ID do Hall */, DateTime.Now, new DateTime());

        GlobalProfile.gameSlots.AddSlotToList(newSlot);
        SaveGameSystem.SaveGame(GlobalProfile.gameSlots, "slots");

        GameObject slotGO = Instantiate(slotsPrefab);

        slotGO.transform.SetParent(slotsGroup.transform, false);
        //slotGO.transform.SetAsFirstSibling();

        SlotUI ui = slotGO.GetComponent <SlotUI>();

        ui.populate    = this;
        ui.id          = newSlot.id;
        ui.dataInicio  = newSlot.date;
        ui.cenario     = newSlot.scenario;
        ui.tempoDeJogo = newSlot.gameTime;
        ui.fadeEffect  = fadeEffect;
        ui.gameObject.SetActive(false);

        AddToPage(ui);

        curr_page = pages.Count - 1;

        LoadPage(curr_page);
    }
예제 #20
0
    void LoadInventory(TextureManager manager)
    {
        dirty = false;
        InventorySave inventory = SaveGameSystem.LoadGame("slot" + Slot + "_inventory") as InventorySave;

        if (inventory == null)
        {
            return;
        }

        if (items == null)
        {
            items = new List <InventoryItem>();
        }

        items.Clear();
        for (int i = 0; i < inventory.displayName.Count; i++)
        {
            Sprite sp = manager.GetSpritePista(inventory.items[i]);
            items.Add(
                new InventoryItem(
                    inventory.items[i],
                    inventory.displayName[i],
                    sp,
                    inventory.descriptions[i]
                    )
                );
        }
    }
예제 #21
0
 // Start is called before the first frame update
 void Start()
 {
     if (SaveGameSystem.DoesSaveGameExist("slot" + GlobalProfile.Slot + "_quadro"))
     {
         LoadQuadroData(SaveGameSystem.LoadGame("slot" + GlobalProfile.Slot + "_quadro") as QuadroData);
     }
 }
예제 #22
0
    //Load values from save into current session
    public void LoadValues()
    {
        SaveData load = SaveGameSystem.LoadGame("Profile" + currentPlayer);

        currentLevel = load.currentLevel;
        currentLives = load.currentLives;
        currentScore = load.currentScore;
    }
예제 #23
0
    public void SaveGameToFile()
    {
        int        keysCollected     = Player.GetComponent <PickUpKey>().KeysCollected;
        GameObject breadcrumbsParent = Player.GetComponent <Breadcrumbs>().BreadcrumbsParent;

        SaveGameSystem.SaveGameToFile(new SaveGame(DungeonParameters, Player,
                                                   ItemsParent, breadcrumbsParent, keysCollected, GetTimeElapsed()));
    }
예제 #24
0
    public string QuickLoad(string file)
    {
        WorldSave myWorldSave = SaveGameSystem.LoadGame(file) as WorldSave;

        string worldName = myWorldSave.worldName;

        return(worldName + " Seed: " + myWorldSave.seed + " explored:" + myWorldSave.explored);
    }
예제 #25
0
 public void LoadGame(TextureManager manager)
 {
     if (SaveGameSystem.DoesSaveGameExist("slot" + Slot + "_messages"))
     {
         messages = SaveGameSystem.LoadGame("slot" + Slot + "_messages") as SerializedMessages;
     }
     LoadInventory(manager);
 }
예제 #26
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = GameObject.FindObjectOfType <SaveGameSystem>();
        }

        DontDestroyOnLoad(gameObject);
    }
예제 #27
0
 public void LoadDungeonFromSave()
 {
     try
     {
         GM.Instance.SaveGame          = SaveGameSystem.LoadGameFromFile();
         GM.Instance.DungeonParameters = GM.Instance.SaveGame.DungeonParameters;
         SceneManager.LoadScene("Dungeon");
     }
     catch (Exception) {}
 }
예제 #28
0
    //Save values from current session
    public void SaveValues()
    {
        SaveData save = new SaveData();
        SaveData load = SaveGameSystem.LoadGame("Profile" + currentPlayer);

        save.highscore    = Mathf.Max(load.highscore, currentScore);
        save.currentScore = currentScore;
        save.currentLives = currentLives;
        save.currentLevel = currentLevel;
        SaveGameSystem.SaveGame(save, "Profile" + currentPlayer);
    }
예제 #29
0
 // Start is called before the first frame update
 void Start()
 {
     if (!SaveGameSystem.DoesSaveGameExist("slot0"))
     {
         NewSave.gameObject.SetActive(true);
     }
     else
     {
         NewSave.gameObject.SetActive(false);
     }
 }
예제 #30
0
    //Check highscore and reset all other vals
    public void ResetSave()
    {
        SaveData save = new SaveData();
        SaveData load = SaveGameSystem.LoadGame("Profile" + currentPlayer);

        save.highscore    = Mathf.Max(load.highscore, currentScore);
        save.currentScore = 0;
        save.currentLives = 5;
        save.currentLevel = 0;
        SaveGameSystem.SaveGame(save, "Profile" + currentPlayer);
    }