public void CopyData(LevelData data) { highScore = data.highScore; unlocked = data.unlocked; scoreSoulFragments = data.scoreSoulFragments; collectedSouls = data.collectedSouls; medal = data.medal; levelName = data.levelName; nextlevel = data.nextlevel; timeAttackMode = data.timeAttackMode; trueLevelName = data.trueLevelName; score = data.score; time = data.time; completed = data.completed; passedRequirement = data.passedRequirement; soulFragmentRequirement = data.soulFragmentRequirement; }
public bool LoadLevelData(LevelData levelData) { if (File.Exists(Application.dataPath + "/save.dat")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.dataPath + "/save.dat", FileMode.Open); SaveData data = (SaveData)bf.Deserialize(file); levelData.scoreSoulFragments = data.m_levelData[levelData.levelID].soulFragment; levelData.score = data.m_levelData[levelData.levelID].score; levelData.collectedSouls = data.m_levelData[levelData.levelID].collectables; levelData.passedRequirement = data.m_levelData[levelData.levelID].passedRequirement; if (levelData.unlocked == false) levelData.unlocked = data.m_levelData[levelData.levelID].unlocked; file.Close(); return true; } return false; }
// Use this for initialization void Awake() { //Set control ref too itself if (control == null) { DontDestroyOnLoad (gameObject); levelData = GetComponent<LevelData>(); control = this; m_data = new SaveData(); } else if (control != this) //If there is already an intance of this object in the scene destroy it { Destroy(gameObject); } if(Application.loadedLevelName == "levelSelectMenu_wip00") { DataControl.control.LoadData(); } }