public FactionRelationshipSaveData LoadFactionRelationships() { Debug.Log("Loading faction relationships"); string dataAsJson = LoadJsonString("Factions/relationships.json"); FactionRelationshipSaveData relationships = JsonUtility.FromJson <FactionRelationshipSaveData>(dataAsJson); return(relationships); }
public void Initialize() { GameEventHandler.OnShipDeath -= OnShipDeath; GameEventHandler.OnShipDeath += OnShipDeath; _allShips = new List <ShipBase>(); _allFactions = GameManager.Inst.DBManager.JsonDataHandler.LoadAllFactions(); _allParties = new List <MacroAIParty>(); _factionRelationships = new Dictionary <string, FactionRelationship>(); FactionRelationshipSaveData relationshipSaveData = GameManager.Inst.DBManager.JsonDataHandler.LoadFactionRelationships(); foreach (FactionRelationship relationship in relationshipSaveData.Relationships) { _factionRelationships.Add(relationship.Faction1 + relationship.Faction2, relationship); } /* * //for now manually create factions * Faction facp = new Faction(); * facp.ID = "player"; * facp.DisplayName = "Player"; * _allFactions.Add(facp.ID, facp); * * Faction fac1 = new Faction(); * fac1.ID = "otu"; * fac1.DisplayName = "Orion Trade Union"; * _allFactions.Add(fac1.ID, fac1); * * * Faction fac2 = new Faction(); * fac2.ID = "otu_patrol"; * fac2.DisplayName = "Union Patrol"; * _allFactions.Add(fac2.ID, fac2); * * Faction fac3 = new Faction(); * fac3.ID = "otu_civil_defense"; * fac3.DisplayName = "Union Civil Defense"; * _allFactions.Add(fac3.ID, fac3); * * Faction fac4 = new Faction(); * fac4.ID = "otu_navy"; * fac4.DisplayName = "Union Navy"; * _allFactions.Add(fac4.ID, fac4); * * Faction fac5 = new Faction(); * fac5.ID = "otu_task_force"; * fac5.DisplayName = "Union Task Force"; * _allFactions.Add(fac5.ID, fac5); * * facp.Relationships = new Dictionary<string, float>() * { * {fac1.ID, 0.5f}, * {fac2.ID, 0.5f}, * {fac3.ID, 0.5f}, * {fac4.ID, 0.5f}, * {fac5.ID, 0.5f} * }; * * fac1.Relationships = new Dictionary<string, float>() * { * {facp.ID, 1f}, * {fac2.ID, 1}, * {fac3.ID, 0}, * {fac4.ID, 1}, * {fac5.ID, 1} * }; * * fac2.Relationships = new Dictionary<string, float>() * { * {facp.ID, 0.5f}, * {fac1.ID, 1}, * {fac3.ID, 1}, * {fac4.ID, 1}, * {fac5.ID, 1} * }; * * fac3.Relationships = new Dictionary<string, float>() * { * {facp.ID, 0.5f}, * {fac1.ID, 0}, * {fac2.ID, 1}, * {fac4.ID, 1}, * {fac5.ID, 1} * }; * * fac4.Relationships = new Dictionary<string, float>() * { * {facp.ID, 0.5f}, * {fac1.ID, 1}, * {fac2.ID, 1}, * {fac3.ID, 1}, * {fac5.ID, 1} * }; * * fac5.Relationships = new Dictionary<string, float>() * { * {facp.ID, 0.5f}, * {fac1.ID, 1}, * {fac2.ID, 1}, * {fac3.ID, 1}, * {fac4.ID, 1} * }; */ MacroAI = new MacroAI(); MacroAI.Initialize(); PartySpawner = new PartySpawner(); PartySpawner.Initialize(); foreach (KeyValuePair <string, Faction> faction in _allFactions) { PartySpawner.GenerateFactionLoadouts(faction.Value); } }