public override string ToJson() { Serializer startedSerializer = base.GetStartedSerializer(); startedSerializer.AddString("cmsVersion", this.replayData.CmsVersion); startedSerializer.AddString("battleVersion", this.replayData.BattleVersion); startedSerializer.AddString("battleId", this.battle.RecordID); startedSerializer.AddString("battleUid", this.battle.BattleUid); startedSerializer.AddDictionary <int>("seededTroopsDeployed", this.seededTroopsDeployed); startedSerializer.AddDictionary <int>("defendingUnitsKilled", this.defendingUnitsKilled); startedSerializer.AddDictionary <int>("attackingUnitsKilled", this.attackingUnitsKilled); startedSerializer.AddDictionary <int>("defenderGuildTroopsSpent", this.defenderGuildUnitsSpent); startedSerializer.AddDictionary <int>("attackerGuildTroopsSpent", this.attackerGuildUnitsSpent); startedSerializer.AddDictionary <int>("loot", this.lootEarned); startedSerializer.AddDictionary <int>("damagedBuildings", this.buildingHealthMap); if (this.buildingUids != null) { startedSerializer.AddDictionary <string>("buildingUids", this.buildingUids); } startedSerializer.AddArrayOfPrimitives <string>("unarmedTraps", this.unarmedTraps); startedSerializer.AddObject <BattleRecord>("replayData", this.replayData); startedSerializer.Add <int>("baseDamagePercent", this.battle.DamagePercent); startedSerializer.AddDictionary <int>("numVisitors", this.battle.NumVisitors); startedSerializer.Add <int>("stars", this.battle.EarnedStars); startedSerializer.AddBool("isUserEnded", this.battle.Canceled); startedSerializer.AddString("planetId", this.planetId); return(startedSerializer.End().ToString()); }
public string ToJson() { Serializer serializer = Serializer.Start(); serializer.Add <int>("capacity", this.totalStorageCapacity); Serializer serializer2 = Serializer.Start(); foreach (KeyValuePair <string, InventoryEntry> current in this.internalStorage) { serializer2.AddObject <InventoryEntry>(current.Key, current.Value); } serializer2.End(); serializer.Add <string>("storage", serializer2.ToString()); if (this.subStorage.Count > 0) { Serializer serializer3 = Serializer.Start(); foreach (KeyValuePair <string, InventoryStorage> current2 in this.subStorage) { serializer3.AddObject <InventoryStorage>(current2.Key, current2.Value); } serializer3.End(); serializer.Add <string>("subStorage", serializer3.ToString()); } return(serializer.End().ToString()); }
public override string ToJson() { Serializer startedSerializer = base.GetStartedSerializer(); startedSerializer.AddObject <PositionMap>("positions", this.PositionMap); return(startedSerializer.End().ToString()); }
public override void SaveInternal(Call call, object obj, string name = null) { for (int attempt = 0; attempt < 10; attempt++) { if (attempt > 0) { System.Threading.Thread.Sleep(attempt * 10); } try { using var stream = new FileStream(DataPath, FileMode.Create, FileAccess.ReadWrite, FileShare.Read); using var writer = new BinaryWriter(stream); var serializer = new Serializer(); serializer.Header.Name = name; serializer.AddObject(call, obj); serializer.Save(call, writer); break; } catch (Exception e) { call.Log.Add(e.Message); } } }
public int SerializeObject(Serializer serializer) { string backCover = ""; int backgroundID = 0; string resultType = ""; switch (Background) { case BackgroundColor bgc: backgroundID = bgc.SerializeObject(serializer); resultType = "BackgroundColor"; break; case BackgroundImage bgi: backgroundID = bgi.SerializeObject(serializer); resultType = "BackgroundImage"; break; } backCover += $"Background:&{backgroundID},{resultType}"; int backCoverID = serializer.AddObject(backCover); return(backCoverID); }
public override string ToJson() { Serializer serializer = Serializer.Start(); serializer.AddString("playerId", base.PlayerId); serializer.AddObject <PositionMap>("positions", this.PositionMap); return(serializer.End().ToString()); }
public override string ToJson() { Serializer startedSerializer = base.GetStartedSerializer(); startedSerializer.AddString("buildingId", this.BuildingId); startedSerializer.AddObject <Position>("position", this.Position); return(startedSerializer.End().ToString()); }
public int SerializeObject(Serializer serializer) { string backgroundImage = $"{nameof(Image)}:&{Image.SerializeObject(serializer)}"; int backgroundImageID = serializer.AddObject(backgroundImage); return(backgroundImageID); }
public override string ToJson() { Serializer serializer = Serializer.Start(); serializer.AddString("battleId", this.battleRecordId); serializer.AddObject <BattleRecord>("replayData", this.replayData); serializer.AddString("playerId", base.PlayerId); return(serializer.End().ToString()); }
public override string ToJson() { Serializer startedSerializer = base.GetStartedSerializer(); startedSerializer.AddString("buildingUid", this.BuildingUid); startedSerializer.AddObject <Position>("position", this.Position); startedSerializer.AddBool("payWithHardCurrency", this.PayWithHardCurrency); startedSerializer.AddString("tag", this.Tag); return(startedSerializer.End().ToString()); }
public string ToJson() { Serializer serializer = Serializer.Start(); foreach (string current in this.positions.Keys) { serializer.AddObject <Position>(current, this.positions[current]); } return(serializer.End().ToString()); }
public int SerializeObject(Serializer serializer) { string rectangle = $"{nameof(X)}:{X}\n"; rectangle += $"{nameof(Y)}:{Y}\n"; rectangle += $"{nameof(Width)}:{Width}\n"; rectangle += $"{nameof(Height)}:{Height}"; int rectangleID = serializer.AddObject(rectangle); return(rectangleID); }
public string ToJson() { Serializer serializer = Serializer.Start(); serializer.AddObject <CombatEncounter>("combatEncounter", this.CombatEncounter); serializer.AddArray <IBattleAction>("battleActions", this.battleActions); serializer.AddObject <BattleDeploymentData>("attackerDeploymentData", this.AttackerDeploymentData); serializer.AddObject <BattleDeploymentData>("defenderDeploymentData", this.DefenderDeploymentData); serializer.Add <int>("lootCreditsAvailable", this.LootCreditsAvailable); serializer.Add <int>("lootMaterialsAvailable", this.LootMaterialsAvailable); serializer.Add <int>("lootContrabandAvailable", this.LootContrabandAvailable); if (this.BuildingLootCreditsMap != null) { serializer.AddDictionary <int>("lootBuildingCreditsMap", this.BuildingLootCreditsMap); } if (this.BuildingLootMaterialsMap != null) { serializer.AddDictionary <int>("lootBuildingMaterialsMap", this.BuildingLootMaterialsMap); } if (this.BuildingLootContrabandMap != null) { serializer.AddDictionary <int>("lootBuildingContrabandMap", this.BuildingLootContrabandMap); } serializer.AddString("battleType", this.BattleType.ToString()); serializer.Add <int>("battleLength", this.BattleLength); serializer.Add <int>("lowFPS", (int)this.LowestFPS); serializer.Add <int>("lowFPSTime", (int)this.LowestFPSTime); serializer.AddString("battleVersion", this.BattleVersion); serializer.AddString("planetId", this.PlanetId); serializer.AddString("manifestVersion", this.CmsVersion); serializer.AddObject <BattleAttributes>("battleAttributes", this.BattleAttributes); if (this.victoryConditionsUids != null) { serializer.AddArrayOfPrimitives <string>("victoryConditions", this.victoryConditionsUids); } serializer.AddString("failureCondition", this.failureConditionUid); if (this.DefenderGuildTroops != null) { serializer.AddDictionary <int>("donatedTroops", this.DefenderGuildTroops); } if (this.AttackerGuildTroops != null) { serializer.AddDictionary <int>("donatedTroopsAttacker", this.AttackerGuildTroops); } if (this.DefenderChampions != null) { serializer.AddDictionary <int>("champions", this.DefenderChampions); } if (!string.IsNullOrEmpty(this.DefenseEncounterProfile)) { serializer.AddString("defenseEncounterProfile", this.DefenseEncounterProfile); } if (!string.IsNullOrEmpty(this.BattleScript)) { serializer.AddString("battleScript", this.BattleScript); } if (this.DisabledBuildings != null) { serializer.AddArrayOfPrimitives <string>("disabledBuildings", this.DisabledBuildings); } serializer.Add <uint>("simSeedA", this.SimSeed.SimSeedA); serializer.Add <uint>("simSeedB", this.SimSeed.SimSeedB); serializer.Add <float>("viewTimePreBattle", this.ViewTimePassedPreBattle); if (this.AttackerWarBuffs != null) { serializer.AddArrayOfPrimitives <string>("attackerWarBuffs", this.AttackerWarBuffs); } if (this.DefenderWarBuffs != null) { serializer.AddArrayOfPrimitives <string>("defenderWarBuffs", this.DefenderWarBuffs); } if (this.AttackerEquipment != null) { serializer.AddArrayOfPrimitives <string>("attackerEquipment", this.AttackerEquipment); } if (this.DefenderEquipment != null) { serializer.AddArrayOfPrimitives <string>("defenderEquipment", this.DefenderEquipment); } return(serializer.End().ToString()); }