public static void SaveWorld(int seed, MapGeneration map, FactionHandler factions, SpellGeneration spells, LoreHandler lore) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/" + seed.ToString() + "world.data"; FileStream stream = new FileStream(path, FileMode.Create); WorldData worldData = new WorldData(factions, map, spells, lore); formatter.Serialize(stream, worldData); stream.Close(); }
void Awake() { instance = this; }
public WorldData(FactionHandler factionHandler, MapGeneration mapGeneration, SpellGeneration spellGeneration, LoreHandler loreHandler) { factions = new List <DummyFaction>(); foreach (FactionHandler.FactionArray f in factionHandler.factionArray) { DummyFaction d = new DummyFaction(); d.factionName = f.factionName; d.factionID = f.factionID; d.factionType = f.factionType; d.schoolType = f.schoolType; d.baseStrength = f.baseStrength; d.overallStrength = f.overallStrength; d.genHostility = f.genHostility; d.startTileX = f.startTileX; d.startTileY = f.startTileY; d.subservient = f.subservient; d.spellSystemEffect = (int)f.spellSystemEffect; d.primaryElementAssociation = (int)f.primaryElementAssociation; d.secondaryElementAssociation = (int)f.secondaryElementAssociation; d.knownSpells = f.knownSpells; d.willAct = f.willAct; d.recentlyRessurected = f.recentlyRessurected; d.resurgenceCounter = f.resurgenceCounter; d.relationships = f.relationships; foreach (GameObject g in f.domain) { d.domain[Mathf.RoundToInt(g.GetComponent <ChunkData>().corX), Mathf.RoundToInt(g.GetComponent <ChunkData>().corX)] = (int)g.GetComponent <ChunkData>().magicResource; } factions.Add(d); } remainingFactions = new List <DummyFaction>(); foreach (FactionHandler.FactionArray f in mapGeneration.remainingFactions) { DummyFaction d = new DummyFaction(); d.factionName = f.factionName; d.factionID = f.factionID; d.factionType = f.factionType; d.schoolType = f.schoolType; d.baseStrength = f.baseStrength; d.overallStrength = f.overallStrength; d.genHostility = f.genHostility; d.startTileX = f.startTileX; d.startTileY = f.startTileY; d.subservient = f.subservient; d.spellSystemEffect = (int)f.spellSystemEffect; d.primaryElementAssociation = (int)f.primaryElementAssociation; d.secondaryElementAssociation = (int)f.secondaryElementAssociation; d.knownSpells = f.knownSpells; d.willAct = f.willAct; d.recentlyRessurected = f.recentlyRessurected; d.resurgenceCounter = f.resurgenceCounter; d.relationships = f.relationships; foreach (GameObject g in f.domain) { d.domain[Mathf.RoundToInt(g.GetComponent <ChunkData>().corX), Mathf.RoundToInt(g.GetComponent <ChunkData>().corX)] = (int)g.GetComponent <ChunkData>().magicResource; } remainingFactions.Add(d); } livingSchools = new List <DummyFaction>(); foreach (FactionHandler.FactionArray f in spellGeneration.livingSchools) { DummyFaction d = new DummyFaction(); d.factionName = f.factionName; d.factionID = f.factionID; d.factionType = f.factionType; d.schoolType = f.schoolType; d.baseStrength = f.baseStrength; d.overallStrength = f.overallStrength; d.genHostility = f.genHostility; d.startTileX = f.startTileX; d.startTileY = f.startTileY; d.subservient = f.subservient; d.spellSystemEffect = (int)f.spellSystemEffect; d.primaryElementAssociation = (int)f.primaryElementAssociation; d.secondaryElementAssociation = (int)f.secondaryElementAssociation; d.knownSpells = f.knownSpells; d.willAct = f.willAct; d.recentlyRessurected = f.recentlyRessurected; d.resurgenceCounter = f.resurgenceCounter; d.relationships = f.relationships; foreach (GameObject g in f.domain) { d.domain[Mathf.RoundToInt(g.GetComponent <ChunkData>().corX), Mathf.RoundToInt(g.GetComponent <ChunkData>().corX)] = (int)g.GetComponent <ChunkData>().magicResource; } livingSchools.Add(d); } deadSchools = new List <DummyFaction>(); foreach (FactionHandler.FactionArray f in spellGeneration.deadSchools) { DummyFaction d = new DummyFaction(); d.factionName = f.factionName; d.factionID = f.factionID; d.factionType = f.factionType; d.schoolType = f.schoolType; d.baseStrength = f.baseStrength; d.overallStrength = f.overallStrength; d.genHostility = f.genHostility; d.startTileX = f.startTileX; d.startTileY = f.startTileY; d.subservient = f.subservient; d.spellSystemEffect = (int)f.spellSystemEffect; d.primaryElementAssociation = (int)f.primaryElementAssociation; d.secondaryElementAssociation = (int)f.secondaryElementAssociation; d.knownSpells = f.knownSpells; d.willAct = f.willAct; d.recentlyRessurected = f.recentlyRessurected; d.resurgenceCounter = f.resurgenceCounter; d.relationships = f.relationships; foreach (GameObject g in f.domain) { d.domain[Mathf.RoundToInt(g.GetComponent <ChunkData>().corX), Mathf.RoundToInt(g.GetComponent <ChunkData>().corX)] = (int)g.GetComponent <ChunkData>().magicResource; } deadSchools.Add(d); } year = mapGeneration.year; wealthArray = mapGeneration.wealthArray; livingFigures = loreHandler.importantLivingFigures; deadFigures = loreHandler.importantDeadFigures; historicalEvents = loreHandler.importantEvents; spellList = spellGeneration.spellList; spellNumber = spellGeneration.spellNumber; }