Exemple #1
0
    /// <summary>
    /// Loads in the game save data
    /// </summary>
    /// <returns>Deserialized Game Data</returns>
    public static GameSaveData LoadGameData(int f)
    {
        FolderNumber = f;
        GameSaveData saveData = null;
        string       dataPath = Application.persistentDataPath + folderName + GameSaveFileName + FileExtension;

        //make sure the file actually exists
        if (File.Exists(dataPath))
        {
            BinaryFormatter binaryFormatter = new BinaryFormatter();
            FileStream      fileStream      = File.Open(dataPath, FileMode.Open);

            try
            {
                saveData = (GameSaveData)binaryFormatter.Deserialize(fileStream);
            }
            catch (System.Exception e)
            {
                PlatformSafeMessage("Game Deserialization Failed: " + e.Message);
            }
            finally
            {
                //always close the fileStream
                fileStream.Close();
            }
        }
        gameData = saveData;
        return(saveData);
    }
Exemple #2
0
	public GameSaveData saveGame() {
		GameSaveData saveData = new GameSaveData();
		foreach (Pawn pawn in _pawns) {
			GameSaveData.PawnState pawnState = new GameSaveData.PawnState();
			pawnState.type = pawn.type;
			pawnState.gridIndex = pawn.gridIndex;
			pawnState.side = pawn.side;

			saveData.pawns.Add(pawnState);
		}

		saveData.combo = _combo;
		saveData.score = _score;
		saveData.exp = _exp;
		saveData.level = _level;
		saveData.turn = _gameRecord.turns;
		saveData.side = _turn;
		saveData.lastScoredPawnType = _titleLayer.getScorePawnType();
		
		for (int i = 0; i < _nextPawnTypes.Count; ++i) {
			saveData.nextPawns.Add(_nextPawnTypes[i]);
		}

		saveData.trashChance = _trashChance;
		saveData.backwardsChance = _backwardsChance;
		return saveData;
	}
Exemple #3
0
	public void loadGame(GameSaveData saveData) {
		foreach (GameSaveData.PawnState pawnState in saveData.pawns) {
			Vector2 gridPos = _chessBoard.gridIndexToPos(pawnState.gridIndex);
			putPawn((int)gridPos.x, (int)gridPos.y, pawnState.type, pawnState.side, true);
		}

		_combo = saveData.combo;
		_score = saveData.score;
		_exp = saveData.exp;
		_level = saveData.level;
		_expNextLevel = calculateExpNextLevel(_level);
		_turn = saveData.side;
		_trashChance = saveData.trashChance;
		_backwardsChance = saveData.backwardsChance;
		_titleLayer.setScorePawnType(saveData.lastScoredPawnType);

		_gameState = GameState.WaitingPutPawn;

		_newPawnCount = saveData.nextPawns.Count;
		_nextPawnTypes.Clear();
		for (int i = 0; i < _newPawnCount; ++i) {
			_nextPawnTypes.Add(saveData.nextPawns[i]);
		}

		_expBar.setExpRatio(_exp / _expNextLevel);

		_nextPawnStateInvalid = true;
		invalidUI();
		updateScenePawnState(false);
	}
Exemple #4
0
    public void LoadGame()
    {
        string path = Application.persistentDataPath + "/game.savedata";

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);

            GameSaveData data = formatter.Deserialize(stream) as GameSaveData;

            stream.Close();             //return data;

            ReloadCreatures(data);
            ReloadPlayer(data.player);

            makeGrana.grana = data.gems;

            calendarSystem.startTime = data.startTime;
        }
        else
        {
            Debug.LogError("Couldn't find save file in " + path);
            //return null;
        }
    }
Exemple #5
0
    public static void Trigger(GameSaveData saveDataArg, int saveFileNumberArg)
    {
        e.saveData       = saveDataArg;
        e.saveFileNumber = saveFileNumberArg;

        MMEventManager.TriggerEvent(e);
    }
Exemple #6
0
    public void loadSavedData()
    {
        try {
            if (File.Exists(Application.persistentDataPath + Constants.SAVE_GAME_RELATIVE_PATH))
            {
                BinaryFormatter bf = new BinaryFormatter();
                FileStream      fs = File.Open(Application.persistentDataPath + Constants.SAVE_GAME_RELATIVE_PATH, FileMode.Open);

                GameSaveData gsd = (GameSaveData)(bf.Deserialize(fs));
                fs.Close();

                foreach (string towerName in gsd._unlockedTowers)
                {
                    _unlockedTowers.Add(towerName);
                }

                foreach (int levelCompleted in gsd._completedLevels)
                {
                    _compledtedLevels [levelCompleted] = true;
                }

                foreach (int unlockedLevel in gsd._unlockedLevels)
                {
                    _unlockedLevels [unlockedLevel] = true;
                }

                Config.SOUND_VOLUME      = gsd._soundVolume;
                Config.MOUSE_SENSITIVITY = gsd._mouseSensitivity;
            }
        } catch (Exception e) {
            Debug.Log("There was a problem loading player data");
            Debug.Log(e);
        }
    }
Exemple #7
0
    public void ReloadCombinatorCreatures(GameSaveData data)
    {
        GameObject criatura1;
        GameObject criatura2;

        var combinatorComponent = combinator.GetComponent <Combinator>();

        if (combinatorComponent.criatura1)
        {
            Destroy(combinatorComponent.criatura1);             //destroi criatura 1
        }
        if (combinatorComponent.criatura2)
        {
            Destroy(combinatorComponent.criatura2);             //destrói criatura 2
        }

        if (data.combinatorCreature1 != null)
        {
            criatura1 = CreateCreature(data.combinatorCreature1);             //recria criatura 1
            criatura1.SetActive(false);
            combinatorComponent.criatura1 = criatura1.GetComponent <Criatura>();
        }
        if (data.combinatorCreature2 != null)
        {
            criatura2 = CreateCreature(data.combinatorCreature2);             //recria criatura 2
            criatura2.SetActive(false);
            combinatorComponent.criatura2 = criatura2.GetComponent <Criatura>();
        }
    }
        public GameData Load()
        {
            GameSaveData loadedData = BayatGames.SaveGameFree.SaveGame.Load <GameSaveData>(_saveFileName);
            GameData     gameData   = new GameData(loadedData);

            return(gameData);
        }
        public void Save(GameData gameData)
        {
            GameSaveData saveData = new GameSaveData(gameData);

            saveData.PlayerData = new PlayerData(gameData.playerPosition, gameData.bulletCount, gameData.playerHealth);
            BayatGames.SaveGameFree.SaveGame.Save <GameSaveData>(_saveFileName, saveData);
        }
Exemple #10
0
 public void SendShadowEvolveEquipItem(ulong uid, uint itemId, Action <Error, EquipItemInfo> call_back)
 {
     SmithShadowEvolveModel.RequestSendForm requestSendForm = new SmithShadowEvolveModel.RequestSendForm();
     requestSendForm.euid = uid.ToString();
     requestSendForm.iid  = (int)itemId;
     Protocol.Send(SmithShadowEvolveModel.URL, requestSendForm, delegate(SmithShadowEvolveModel ret)
     {
         EquipItemInfo equipItemInfo = null;
         if (ret.Error == Error.None)
         {
             equipItemInfo = MonoBehaviourSingleton <InventoryManager> .I.equipItemInventory.Find(uid);
             if (equipItemInfo != null)
             {
                 if (MonoBehaviourSingleton <StatusManager> .I.IsEquipping(equipItemInfo, -1))
                 {
                     MonoBehaviourSingleton <StatusManager> .I.UpdateEquip(equipItemInfo);
                 }
                 if (GameSaveData.instance.AddNewItem(ItemIcon.GetItemIconType(equipItemInfo.tableData.type), equipItemInfo.uniqueID.ToString()))
                 {
                     GameSaveData.Save();
                 }
             }
             MonoBehaviourSingleton <GameSceneManager> .I.SetNotify(GameSection.NOTIFY_FLAG.UPDATE_EQUIP_EVOLVE);
         }
         call_back(ret.Error, equipItemInfo);
     }, string.Empty);
 }
Exemple #11
0
    /// <summary>
    /// Saves the game save data
    /// </summary>
    /// <param name="saveData">Data to save</param>
    private static bool SaveGameData(GameSaveData saveData)
    {
        if (!Web)
        {
            MakeDirectory();
        }

        string          dataPath        = Application.persistentDataPath + folderName + GameSaveFileName + FileExtension;
        BinaryFormatter binaryFormatter = new BinaryFormatter();
        FileStream      fileStream      = File.Open(dataPath, FileMode.OpenOrCreate);

        bool success = false;

        try
        {
            binaryFormatter.Serialize(fileStream, saveData);
            if (Web)
            {
                SyncFiles();
            }
            success = true;
        }
        catch (System.Exception e)
        {
            PlatformSafeMessage("Serialization Failed: " + e.Message);
        }
        finally
        {
            //always close the fileStream
            fileStream.Close();
        }
        return(success);
    }
Exemple #12
0
        private void ButGame_Click(object sender, EventArgs e)
        {
            Button       but  = sender as Button;
            int          id   = (int)but.Tag;
            GameSaveData data = CaroService.Storage.GameList.SingleOrDefault(x => x.id == id);

            if (data != null)
            {
                CaroService.Storage.CurrentIndex = id;
                SettingConfig.InitializeGameSaveSetting(data);
                CaroService.Player.PlayerName1 = data.PlayerName1;
                CaroService.Player.PlayerName2 = data.PlayerName2;
                CaroService.Player.Turn        = data.Turn;
                CaroService.Action.ResetAction();
                CaroService.Board.InitCaroBoard();
                CaroService.Board.DrawCaroBoard();
                CaroService.Winner.LoadSaveGame(data.Turn, data.CaroBoard);
                if (isSetting)
                {
                    Control parent = this.Parent;
                    parent.Hide();
                }
                else
                {
                    routes.Routing(Constants.MAIN);
                }
            }
            else
            {
                MessageBox.Show("Not Found Your Game", "Thông Báo", MessageBoxButtons.OK);
            }
        }
 public static void InitializeGameSaveSetting(GameSaveData data)
 {
     Rows         = data.Row;
     Columns      = data.Column;
     GameMode     = data.GameMode;
     BoardPattern = data.CaroBoard;
 }
Exemple #14
0
        public void Load(GameContext ctx, uint slot)
        {
            if (slot == 0)
            {
                ReadCommonSaveData(ctx);
                return;
            }

            string saveDir  = GetSaveDirectory(slot, out string savenum);
            string savePath = Path.Combine(saveDir, $"{savenum}.sav");

            byte[] bytes  = File.ReadAllBytes(savePath);
            var    reader = new MessagePackReader(bytes);
            var    save   = new GameSaveData(ref reader);

            int           i = 0;
            string        texPath;
            RenderContext rc = ctx.RenderContext;
            var           standaloneTextures = new List <Texture>();

            while (File.Exists(texPath = Path.Combine(saveDir, $"{i:D4}.png")))
            {
                Texture tex = rc.Content.LoadTexture(texPath, staging: false);
                standaloneTextures.Add(tex);
                i++;
            }

            ctx.MainProcess.Dispose();
            ctx.SysProcess = null;

            ctx.VM.RestoreVariables(save.Variables);
            ctx.MainProcess = new GameProcess(ctx, save.MainProcess, standaloneTextures);
        }
Exemple #15
0
    /// <summary>
    /// Don't use! Old way of saving
    /// </summary>
    /// <returns></returns>
    //private IEnumerator SaveRoutine()
    //{
    //    UIManager.Singleton.SetSaveGameIcon(true);

    //    yield return new WaitForEndOfFrame();
    //    GameSaveData.GetAllData();

    //    Directory.CreateDirectory(Application.persistentDataPath + @"\SaveGames\");

    //    var serializer = new XmlSerializer(typeof(GameSaveData));
    //    //var stream = new FileStream(Path.Combine(Application.persistentDataPath + @"\SaveGames\", "SaveData.xml"), FileMode.Create);
    //    var stream = new FileStream(Path.Combine(Application.persistentDataPath + @"\SaveGames\", StoreManager.StoreName + ".xml"), FileMode.Create);
    //    serializer.Serialize(stream, GameSaveData);
    //    stream.Close();

    //    //Debug.Log("Game Saved: " + Path.Combine(Application.persistentDataPath + @"\SaveGames\", "SaveData.xml"));
    //    Debug.Log("Game Saved: " + Path.Combine(Application.persistentDataPath + @"\SaveGames\", StoreManager.StoreName + ".xml"));

    //    yield return new WaitForEndOfFrame();

    //    UIManager.Singleton.SetSaveGameIcon(false);

    //}

    public void LoadGame(string fileName)
    {
        var serializer = new XmlSerializer(typeof(GameSaveData));
        //var stream = new FileStream(Path.Combine(Application.persistentDataPath + @"\SaveGames\", "SaveData.xml"), FileMode.Open);
        var stream = new FileStream(Path.Combine(Application.persistentDataPath + @"\SaveGames\", fileName), FileMode.Open);

        GameSaveData = serializer.Deserialize(stream) as GameSaveData;
        stream.Close();

        if (GameSaveData != null)
        {
            GameSaveData.ApplyDataToGame();

            MusicEnabled = PlayerPrefsX.GetBool(SettingsMusic, true);
            SoundEnabled = PlayerPrefsX.GetBool(SettingsSound, true);

            //UIManager.Singleton.SetSound(SoundEnabled);
            //UIManager.Singleton.SetMusic(MusicEnabled);

            UIManager.Singleton.SetOptionsToggles(MusicEnabled, SoundEnabled);
            EconomyManager.Singleton.JustLoadedSavedGame = true;
        }
        else
        {
            UIManager.Singleton.ShowMessage("No Saves", "No savegames found!");
        }
    }
Exemple #16
0
    /// <summary>
    /// Deactivates all other fires, saves the game.
    /// </summary>
    /// <param name="player"></param>
    public void StartFire(GameObject player)
    {
        if (!activated)
        {
            animator.Play("SaveTorchFlicker");
            audioSource.Play();

            //Only have one fire active at once
            SavePoint[] points = FindObjectsOfType <SavePoint>();

            foreach (SavePoint point in points)
            {
                if (point != this)
                {
                    point.StopFire();
                }
            }

            GameSaveData gsd = new GameSaveData(transform.position.x, transform.position.y, player.GetComponent <PlayerController>());
            SaveGame.Save(gsd);

            player.GetComponent <PlayerController>().RefillHealth();
            //lightSource.enabled = true;
            activated = true;
        }
    }
Exemple #17
0
    private void Start()
    {
        GameSaveData data = GameData.LoadData();

        for (int id = 0; id < LevelManager.Instance.levels.levels.Length; id++)
        {
            if (id > data.highestLevel + 1)
            {
                Instantiate(DummyButtonPrefab, transform);
                continue;
            }

            string levelName = LevelManager.Instance.levels.levels[id];

            UI_LevelButton newButton = Instantiate(LevelButtonPrefab, transform).GetComponent <UI_LevelButton>();
            newButton.parentElement = this;

            float completionTime = 0.0f;

            // get player's progress data
            if (data.levelData.ContainsKey(levelName))
            {
                completionTime = data.levelData[levelName].completionTime;
            }

            // Initialize the button with player's data too
            newButton.Init(id, completionTime);
            //newButton.transform.GetChild(0).GetComponent<Text>().text = (id+1).ToString();
        }
    }
 public static void Delete()
 {
     SaveData.DeleteKey(SaveData.Key.Game);
     instance = new GameSaveData();
     SaveData.SetData(SaveData.Key.Game, instance);
     SaveData.Save();
 }
Exemple #19
0
 public void SendLogInBonus(Action <bool> callback)
 {
     logInBonus             = null;
     logInBonusLimitedCount = 0;
     GameSaveData.instance.showIAPAdsPop = string.Empty;
     Protocol.Send(LoginBonusModel.URL, delegate(LoginBonusModel ret)
     {
         bool obj = false;
         if (ret.Error == Error.None)
         {
             obj        = true;
             logInBonus = ret.result;
             GameSaveData.instance.logInBonus = ret.result;
             GameSaveData.Save();
             int i = 0;
             for (int count = logInBonus.Count; i < count; i++)
             {
                 if (logInBonus[i].priority > 0)
                 {
                     logInBonusLimitedCount++;
                 }
             }
             IsRecvLogInBonus = true;
         }
         if (callback != null)
         {
             callback(obj);
         }
     }, string.Empty);
 }
    public static bool Load(string filename, Dictionary <string, int> fields)
    {
        string path = Path.Combine(Application.streamingAssetsPath, filename) + ".json";

        if (File.Exists(path))
        {
            string       jsonData   = File.ReadAllText(path);
            GameSaveData loadedData = JsonUtility.FromJson <GameSaveData>(jsonData);

            for (int i = 0; i < loadedData.items.Count; ++i)
            {
                fields.Add(loadedData.items[i].key, loadedData.items[i].value);
            }

////////
            Debug.Log("Data loaded, dictionary contains: " + fields.Count + " entries");
            foreach (KeyValuePair <string, int> item in fields)
            {
                Debug.Log("PAIR: " + item.Key + ", " + item.Value);
            }
////////
        }
        else
        {
            Debug.LogError("Cannot find file \" " + path + "\"!");
            return(false);
        }

        return(true);
    }
Exemple #21
0
 //--------------------------------------------------------------------------------------------------
 //-- LOAD
 //--------------------------------------------------------------------------------------------------
 public void Load()
 {
     if (File.Exists(path))
     {
         BinaryFormatter bf   = new BinaryFormatter();
         FileStream      file = File.Open(path, FileMode.Open);
         lastSaveData = (GameSaveData)bf.Deserialize(file);
         file.Close();
         Debug.Log("Current Level:" + lastSaveData.currentLevel);
         string        level     = SceneManager.GetActiveScene().name;
         LevelSaveData levelData = lastSaveData.GetLevelDataFor(level);
         if (levelData == null)
         {
             Debug.Log("Level Data null");
         }
         else
         {
             Debug.Log("Level Data found!");
             ActivateSavePoints(levelData);
             DeleteCollectables(levelData);
             SetSpawnPosition(levelData);
             SkipCutScenes(levelData);
         }
     }
 }
Exemple #22
0
        static void Main(string[] args)
        {
            // Where we get and set save data
            GameSaveData data;

            SaveSystem<GameSaveData>.directory = @"C:\Test";

            bool wasLoaded;

            try {
                data = SaveSystem<GameSaveData>.LoadData("test.savedata");
                wasLoaded = true;
            }
            catch(Exception) {
                data = new GameSaveData("test.savedata");
                wasLoaded = false;
            }

            if(wasLoaded) {
                Console.WriteLine(data.testFloat);
                Console.WriteLine(data.testString);
            }
            // Set either adds or changes a value
            data.testFloat = new Random().Next();
            data.testString = Guid.NewGuid().ToString();

            if(wasLoaded) {
                Console.ReadLine();
            }

            // If file exists on disk, will overwrite, otherwise will create a new file on disk
            SaveSystem<GameSaveData>.WriteData(data);
        }
Exemple #23
0
    void ShowGuidCircles(bool isTut)
    {
        if (isTut)
        {
            _tutorialCounter++;
            if (_tutorialCounter > 3)
            {
                _tutorialFinished = true;
                GameSaveData.DoneTutorialSight();
                return;
            }
        }

        foreach (var obj in _guideCirclesList)
        {
            Destroy(obj);
        }
        _guideCirclesList.Clear();

        foreach (var obj in _commonPics)
        {
            var circle = Instantiate(_circleObj, obj.transform.position, _circleObj.transform.rotation, obj.transform);
            var rectTr = circle.GetComponent <RectTransform>();
            rectTr.Rotate(0, 0, Rand(1, 360));
            circle.GetComponent <Image>().color = isTut ? Color.green : Color.black;
            rectTr.gameObject.SetActive(true);
            var seq = DOTween.Sequence();
            seq.Append(rectTr.DOScale(1.1f, .2f));
            seq.Append(rectTr.DOScale(1.0f, .2f));
            seq.SetLoops(isTut ? -1 : 3);
            _guideCirclesList.Add(circle);
        }
    }
Exemple #24
0
    // Start is called before the first frame update
    void Start()
    {
        //Get Components
        entity      = GetComponent <Entity2D>();
        bCollider   = GetComponent <BoxCollider2D>();
        sRenderer   = GetComponent <SpriteRenderer>();
        dustSystem  = GetComponent <ParticleSystem>();
        animator    = GetComponent <Animator>();
        audioSource = GetComponent <AudioSource>();

        //Setup Input
        controls = new ControlScheme();
        controls.InGame.Enable();
        controls.InGame.Right.started  += Right_started;
        controls.InGame.Right.canceled += Right_canceled;
        controls.InGame.Left.started   += Left_started;
        controls.InGame.Left.canceled  += Left_canceled;

        controls.InGame.Jump.started  += Jump_started;
        controls.InGame.Jump.canceled += Jump_canceled;

        controls.InGame.Respawn.started += Respawn_started;

        //Makes a save at the start if one does not exsist
        if (!File.Exists(Path.Combine(Application.persistentDataPath, SaveGame.fileName)))
        {
            GameSaveData gsd = new GameSaveData(transform.position.x, transform.position.y, this);
            SaveGame.Save(gsd);
        }

        Application.targetFrameRate = 60;
    }
Exemple #25
0
    void Start()
    {
        string saveDataFile = gameTempSavePath;

        if (System.IO.File.Exists(saveDataFile))
        {
            // load game save and goto game main ui directly
            GameObject gameMainUI = ScreenManager.instance().get("GameMainUI");
            MainState  mainState  = gameMainUI.GetComponent <MainState>();
            try {
                GameSaveData saveData = (GameSaveData)PlatformUtils.readObject(saveDataFile, typeof(GameSaveData));
                ScreenManager.show(gameMainUI, true);
                mainState.restart();
                mainState.loadGame(saveData);

                clearSave();
                return;
            } catch (System.Exception e) {
                if (Application.isEditor)
                {
                    throw e;
                }

                Debug.Log(e.ToString());
                ScreenManager.show(gameMainUI, false);
            } finally {
                System.IO.File.Delete(saveDataFile);
            }
        }

        ScreenManager.instance().show("StartMenu", true);
    }
Exemple #26
0
        public bool UpdateGameById(int gameId, GameSaveData update, SQLConnecter connecter)
        {
            string updateCommand = string.Format("UPDATE Game set Row='{0}', Column='{1}', PlayerName1='{2}', PlayerName2='{3}', GameMode='{4}', Turn='{5}', CaroBoard='{6}' where id='{5}'",
                                                 update.Row, update.Column, update.PlayerName1, update.PlayerName2, update.GameMode, update.Turn, update.CaroBoard, gameId);

            return(ExecuteCommand(updateCommand, connecter.connection));
        }
Exemple #27
0
    public void SendEvolveEquipItem(ulong uid, uint evolve_id, ulong[] uniq_ids, Action <Error, EquipItemInfo> call_back)
    {
        SmithEvolveModel.RequestSendForm requestSendForm = new SmithEvolveModel.RequestSendForm();
        requestSendForm.euid = uid.ToString();
        requestSendForm.vid  = (int)evolve_id;
        List <string> list = new List <string>();

        for (int i = 0; i < uniq_ids.Length; i++)
        {
            list.Add(uniq_ids[i].ToString());
        }
        requestSendForm.meids = list;
        Protocol.Send(SmithEvolveModel.URL, requestSendForm, delegate(SmithEvolveModel ret)
        {
            EquipItemInfo equipItemInfo = null;
            if (ret.Error == Error.None)
            {
                equipItemInfo = MonoBehaviourSingleton <InventoryManager> .I.equipItemInventory.Find(uid);
                if (equipItemInfo != null)
                {
                    if (MonoBehaviourSingleton <StatusManager> .I.IsEquipping(equipItemInfo, -1))
                    {
                        MonoBehaviourSingleton <StatusManager> .I.UpdateEquip(equipItemInfo);
                    }
                    if (GameSaveData.instance.AddNewItem(ItemIcon.GetItemIconType(equipItemInfo.tableData.type), equipItemInfo.uniqueID.ToString()))
                    {
                        GameSaveData.Save();
                    }
                }
                MonoBehaviourSingleton <GameSceneManager> .I.SetNotify(GameSection.NOTIFY_FLAG.UPDATE_EQUIP_EVOLVE);
            }
            call_back(ret.Error, equipItemInfo);
        }, string.Empty);
    }
    public static void Save()
    {
        //init();
        //Debug.Log ("Savingg");
        m_saveData = new GameSaveData();

        m_am.save(m_saveData.ActionManagerData);
        m_bm.save(m_saveData.BuildingManagerData);
        m_tm.save(m_saveData.TimeManagerData);
        m_cm.save(m_saveData.CoopManagerData);
        m_um.save(m_saveData.UserDataManagerData);
        m_im.save(m_saveData.InvestigationManagerData);
        m_lm.save(m_saveData.LogicManagerData);
        m_worldm.canalManager.save(m_saveData.CanalManagerData);
        m_pm.save(m_saveData.PenalizationManagerData);
        m_phasem.save(m_saveData.PhaseManagerData);
        m_plaguem.save(m_saveData.PlagueManagerData);
        m_rm.save(m_saveData.RankingManagerData);
        m_rom.save(m_saveData.RiceObjectManagerData);
        m_worldm.WeedFactory.save(m_saveData.WeedFactoryData);
        m_workerm.save(m_saveData.WorkerManagerData);
        m_worldm.save(m_saveData.WorldTerrainData);
        m_tutMan.save(m_saveData.tutorialManagerData);


        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Application.persistentDataPath + "/savedGames.gd");

        bf.Serialize(file, m_saveData);
        file.Close();
        PlayerPrefs.SetInt("LoadData", 1);
    }
Exemple #29
0
    /// <summary>
    /// called when the save file dat needs updating
    /// </summary>
    public void Refresh()
    {
        saveLevelNameBox.Reset();

        GameSaver.FolderNumber = saveNumber;
        //check if the file already exists
        if (File.Exists(GameSaver.SaveName))
        {
            //File Exists
            newButton.gameObject.SetActive(false);
            playButton.gameObject.SetActive(true);
            deleteButton.gameObject.SetActive(true);

            //get the name of the level saved on
            GameSaveData saveData = GameSaver.LoadGameData(saveNumber);
            saveLevelNameBox.OnTriggerKeyPressed(saveData.currentLevel);
        }
        else
        {
            //File doesn't exist
            newButton.gameObject.SetActive(true);
            playButton.gameObject.SetActive(false);
            deleteButton.gameObject.SetActive(false);

            //blank name field
            saveLevelNameBox.OnTriggerKeyPressed("---");
        }
    }
    /// <summary>
    /// Overrides saved game with isRelevant = false
    /// </summary>
    public void ResetData()
    {
        GameSaveData data = new GameSaveData();

        data._isRelevant = false;
        SaveData(data);
    }
Exemple #31
0
    //--------------------------------------------------------------------------------------------------
    //-- SAVE
    //--------------------------------------------------------------------------------------------------

    public void Save(SavePoint savePoint)
    {
        lastSaveData = CreateSaveData(savePoint);
        Thread _t1 = new Thread(SaveToFile);

        _t1.Start();
    }
Exemple #32
0
    public static float gameCompletion(GameSaveData data)
    {
        // How to beat the game 100%:
        //
        // 7 Red Wing levels
        // 5 Green Wing levels
        // 4 Blue Wing levels
        // 3 switches to pull at the end of each wing
        // 3 secrets to find in the last level of each wing
        // 1 final TV to insert the tape into in the Finale
        //
        // 23 things to do in total

        float progress = data.levelProgress[0] + data.levelProgress[1] + data.levelProgress[2];
        progress += (data.gameProgress[0] > 0 ? 1 : 0) + (data.gameProgress[1] > 0 ? 1 : 0) + (data.gameProgress[2] > 0 ? 1 : 0);
        progress += (data.gameSecrets[0] ? 1 : 0) + (data.gameSecrets[1] ? 1 : 0) + (data.gameSecrets[2] ? 1 : 0);
        progress += (data.gameComplete ? 1 : 0);

        return Mathf.Floor(progress * 100f / 23f);
    }
Exemple #33
0
    void Awake()
    {
        // If there's no save file, don't bother with any loading. Just go straight to the living room

        if (!File.Exists(filename))
        {
            SceneManager.LoadScene(1);
            return;
        }

        // Otherwise, we have something to load. Get the data from the save file and store it

        BinaryFormatter bf = new BinaryFormatter();
        FileStream file = File.Open(filename, FileMode.Open);
        data = (GameSaveData)bf.Deserialize(file);
        file.Close();

        printGameSaveData(data);

        text = GameObject.Find("Text").GetComponent<Text>();
        textActive = GameObject.Find("TextActive").GetComponent<Text>();
        textDisabled = GameObject.Find("TextDisabled").GetComponent<Text>();
        textOutline = GameObject.Find("Text").GetComponent<Outline>();
        textActiveOutline = GameObject.Find("TextActive").GetComponent<Outline>();
        textDisabledOutline = GameObject.Find("TextDisabled").GetComponent<Outline>();
        sounds = GetComponents<AudioSource>();
        fx = FindObjectOfType<PostProcessing>();
        audioExtrasPlayer = transform.Find("AudioExtras").GetComponent<AudioSource>();

        dataCompletion = gameCompletion(data);
        tMain[0] = "== " + dataCompletion + "% COMPLETE ==" + tMain[0];
    }
Exemple #34
0
 public static void printGameSaveData(GameSaveData data)
 {
     /*string output;
     output = "| start in: " + data.levelStart + " "
            + "| level progress: {" + data.levelProgress[0] + ", " + data.levelProgress[1] + ", " + data.levelProgress[2] + "} "
            + "| game progress: {" + data.gameProgress[0] + ", " + data.gameProgress[1] + ", " + data.gameProgress[2] + "} "
            + "| secrets: {" + data.gameSecrets[0] + ", " + data.gameSecrets[1] + ", " + data.gameSecrets[2] + "} "
            + "| complete: " + (data.gameComplete ? "yes" : "no") + " |\n"
            + "| total completion: " + gameCompletion(data) + "% |";
     Debug.Log(output);*/
 }
Exemple #35
0
    // Saving
    public void saveGame(string levelStart)
    {
        // Save game data to file

        BinaryFormatter bf = new BinaryFormatter();
        FileStream file = File.Open(GameLoad.filename, FileMode.Create);

        GameSaveData data = new GameSaveData();
        data.levelStart = levelStart;
        data.levelProgress = LEVEL_PROGRESS;
        data.gameProgress = GAME_PROGRESS;
        data.gameSecrets = GAME_SECRETS;
        data.gameComplete = GAME_COMPLETE;

        bf.Serialize(file, data);
        file.Close();

        GameLoad.printGameSaveData(data);
    }
    public void Save()
    {
        BinaryFormatter bf = new BinaryFormatter();
        FileStream file = File.Create(Application.persistentDataPath + "/GameSaveData.dat");

        GameSaveData data = new GameSaveData();

        data.gameSaveDataName1 = this.gameSaveSlot1;
        data.gameSaveId1 = this.gameSaveId1;

        data.gameSaveDataName2 = this.gameSaveSlot2;
        data.gameSaveId2 = this.gameSaveId2;

        data.gameSaveDataName3 = this.gameSaveSlot3;
        data.gameSaveId3 = this.gameSaveId3;

        data.idDisponivel = this.idDisponivel;
        bf.Serialize(file, data);
        file.Close();
    }