public void CreateNewGame(int raceID, int classID) { m_playerData[SelectSlot].isNewGame = false; TRace tRace = ActivePlayerData.unlockedRaces[raceID].GetTRace(); TClass tClass = ActivePlayerData.unlockedClasses[classID].GetTClass(); List <int> skillDeck = new List <int>(); for (int i = 0; i < 5; i++) { skillDeck.Add(tClass.skillSet[0].Hash); } for (int i = 0; i < 4; i++) { skillDeck.Add(tClass.skillSet[1].Hash); } skillDeck.Add(tRace.skill.Hash); EntityAttribute attribute = (tRace.attribute + tClass.attribute) / 2; m_activeWorldData = new WorldData() { seed = System.DateTime.Now.ToString(), selectClassID = classID, selectRaceID = raceID, attribute = attribute, HealthPoints = attribute.maxHealth, gainedRelicHashes = new List <int>() { classID.GetTClassFromID().relic.Hash, raceID.GetTRaceFromID().relic.Hash }, learnedSkillHashes = skillDeck, worldMap = new List <Location>(), stageLocations = new List <Location>(), currentStage = 0, characterLocation = new Location(4, 0), enterAreaDirection = Location.Up, worldBound = new Location(8, -1) }; AreaChunks = new AreaData[0]; sr = new System.Random(ActiveWorldData.seed.GetStableHashCode()); //SaveAll(); }
public void LoadAll() { string filePath; SelectSlot = PlayerPrefs.GetInt(selectSlotKey, -1); for (int i = 0; i < 3; i++) { filePath = GetFilePath(saveKeys[i]); if (File.Exists(filePath)) { LoadData(filePath, ref m_playerData[i]); } if (SelectSlot == -1 && m_playerData[i].name != null) { SelectSlot = i; } } if (SelectSlot == -1) { PlayerPrefs.SetInt(selectSlotKey, -1); return; } if (m_playerData[SelectSlot].name == null) { SelectSlot = -1; for (int i = 0; i < 3; i++) { if (m_playerData[i].name != null) { SelectSlot = i; } } if (SelectSlot == -1) { PlayerPrefs.SetInt(selectSlotKey, -1); return; } } if (ActivePlayerData.isNewGame) { Debug.Log("Game Loaded"); return; } filePath = GetFilePath("GameData_" + ActivePlayerData.name); LoadData(filePath, ref m_activeWorldData); AreaChunks = new AreaData[m_activeWorldData.mapFileCnt]; for (int i = 0; i < m_activeWorldData.mapFileCnt; i++) { filePath = GetFilePath("GameData_" + ActivePlayerData.name + "_MapChunk" + i); LoadData(filePath, ref AreaChunks[i]); } sr = new System.Random(ActiveWorldData.seed.GetStableHashCode()); for (int i = 0; i < ActiveWorldData.randomCnt; i++) { sr.Next(); } Debug.Log("Game Loaded"); }