diff --git a/WorldOfTheThreeKingdoms/GameGlobal/StaticMethods.cs b/WorldOfTheThreeKingdoms/GameGlobal/StaticMethods.cs index e3eee32c5..fd113f398 100644 --- a/WorldOfTheThreeKingdoms/GameGlobal/StaticMethods.cs +++ b/WorldOfTheThreeKingdoms/GameGlobal/StaticMethods.cs @@ -422,9 +422,12 @@ public static void LoadFromString(Dictionary list, string dataString) char[] separator = new char[] { ' ', '\n', '\r', '\t' }; string[] strArray = dataString.Split(separator, StringSplitOptions.RemoveEmptyEntries); list.Clear(); - for (int i = 0; i < strArray.Length; i += 2) + if(strArray.Length>=2) { - list.Add(int.Parse(strArray[i]), int.Parse(strArray[i + 1])); + for (int i = 0; i < strArray.Length; i += 2) + { + list.Add(int.Parse(strArray[i]), int.Parse(strArray[i + 1])); + } } } @@ -557,6 +560,42 @@ public static string SaveToString(Dictionary intList) } return builder.ToString(); } + + public static string SaveToString(List> List) + { + if (List == null) + { + return ""; + } + StringBuilder builder = new StringBuilder(); + foreach (KeyValuePair num in List) + { + builder.Append(num.Key.ToString() + " " + num.Value.ToString() + " "); + } + return builder.ToString(); + } + public static void LoadFromString(List> list, string dataString) + { + char[] separator = new char[] { ' ', '\n', '\r', '\t' }; + string[] strArray = dataString.Split(separator, StringSplitOptions.RemoveEmptyEntries); + list.Clear(); + for (int i = 0; i < strArray.Length; i += 2) + { + list.Add(new KeyValuePair(int.Parse(strArray[i]), int.Parse(strArray[i + 1]))); + } + } + public static GameObjects.zainanlei LoadzainanfromString(string zainanstring) + { + char[] separator = new char[] { ' ', '\n', '\r', '\t' }; + string[] strArray = zainanstring.Split(separator, StringSplitOptions.RemoveEmptyEntries); + GameObjects.zainanlei zainan = new GameObjects.zainanlei(); + for (int i = 0; i < strArray.Length; i += 2) + { + zainan.zainanleixing = int.Parse(strArray[i]); + zainan.shengyutianshu = int.Parse(strArray[i + 1]); + } + return zainan; + } } } diff --git a/WorldOfTheThreeKingdoms/GameObjects/Architecture.cs b/WorldOfTheThreeKingdoms/GameObjects/Architecture.cs index bb077ed9e..1bff07716 100644 --- a/WorldOfTheThreeKingdoms/GameObjects/Architecture.cs +++ b/WorldOfTheThreeKingdoms/GameObjects/Architecture.cs @@ -254,7 +254,7 @@ public void Init() public bool DayLocationLoyaltyNoChange; public float DayRateIncrementOfInternal; - [DataMember] + //[DataMember] public Legion DefensiveLegion; [DataMember] public int DefensiveLegionID; @@ -7576,7 +7576,7 @@ public Routeway GetConnectedRouteway(Architecture end) } return null; } - [DataMember] + //[DataMember] public PersonList ConvinceDestinationPersonList = new PersonList(); public PersonList GetConvinceDestinationPersonList(Faction faction) { @@ -14703,7 +14703,7 @@ public FreeText jianzhubiaoti set; } */ - [DataMember] + //[DataMember] public qizi jianzhuqizi { get; diff --git a/WorldOfTheThreeKingdoms/GameObjects/Faction.cs b/WorldOfTheThreeKingdoms/GameObjects/Faction.cs index 195949e66..4231dc407 100644 --- a/WorldOfTheThreeKingdoms/GameObjects/Faction.cs +++ b/WorldOfTheThreeKingdoms/GameObjects/Faction.cs @@ -264,9 +264,7 @@ public void Init() public string SectionsString { get; set; } public SectionList Sections = new SectionList(); - [DataMember] - public Dictionary SpyMessageCloseList = new Dictionary(); - + public bool StopToControl; public MilitaryKindTable TechniqueMilitaryKinds = new MilitaryKindTable(); diff --git a/WorldOfTheThreeKingdoms/GameObjects/GameScenario.cs b/WorldOfTheThreeKingdoms/GameObjects/GameScenario.cs index 445f8a1cb..ce4ce1f35 100644 --- a/WorldOfTheThreeKingdoms/GameObjects/GameScenario.cs +++ b/WorldOfTheThreeKingdoms/GameObjects/GameScenario.cs @@ -589,7 +589,7 @@ public void ClearPersonWorkCache() } [DataMember] - private CaptiveList captiveData = new CaptiveList(); + public CaptiveList captiveData = new CaptiveList(); public CaptiveList Captives { @@ -3232,7 +3232,7 @@ public List ProcessScenarioData(bool fromScenario, bool editing = false) } } - if (this.captiveData != null) + if (this.captiveData != null && !editing) { foreach (Captive captive in this.captiveData) { @@ -3812,6 +3812,7 @@ void ClearTempDic() CloseIds.Clear(); HatedIds.Clear(); MarriageGranterId.Clear(); + PersonRelationIds.Clear(); } private void alterTransportShipAdaptibility() @@ -4584,8 +4585,10 @@ public bool SaveGameScenario(string LoadedFileName, bool saveMap, bool saveCommo { this.GameTime = 0; } - - this.GameTime += (int)DateTime.Now.Subtract(sessionStartTime).TotalSeconds; + if(!editing) + { + this.GameTime += (int)DateTime.Now.Subtract(sessionStartTime).TotalSeconds; + } sessionStartTime = DateTime.Now; List errors = new List(); @@ -4609,16 +4612,18 @@ public bool SaveGameScenario(string LoadedFileName, bool saveMap, bool saveCommo this.Troops.GameObjects = this.Troops.GameObjects.OrderBy(x => x.ID).ToList(); this.TroopEvents.GameObjects = this.TroopEvents.GameObjects.OrderBy(x => x.ID).ToList(); this.DiplomaticRelations.DiplomaticRelations = this.DiplomaticRelations.DiplomaticRelations.OrderBy(x => x.Value.RelationFaction1ID).ToDictionary(x => x.Key, y => y.Value); - //this.FatherIds = this.FatherIds - //this.MotherIds = this.MotherIds - //this.SpouseIds = this.SpouseIds - //this.BrotherIds = this.BrotherIds - //this.SuoshuIds = this.SuoshuIds - //this.CloseIds = this.CloseIds - //this.HatedIds = this.HatedIds - //this.PersonRelationIds = this.PersonRelationIds - //try - //{ + if(editing) + { + this.FatherIds = this.FatherIds.OrderBy(x => x.Key).ToDictionary(x => x.Key, y => y.Value); + this.MotherIds = this.MotherIds.OrderBy(x => x.Key).ToDictionary(x => x.Key, y => y.Value); + this.SpouseIds = this.SpouseIds.OrderBy(x => x.Key).ToDictionary(x => x.Key, y => y.Value); + this.BrotherIds = this.BrotherIds.OrderBy(x => x.Key).ToDictionary(x => x.Key, y => y.Value); + this.SuoshuIds = this.SuoshuIds.OrderBy(x => x.Key).ToDictionary(x => x.Key, y => y.Value); + this.CloseIds = this.CloseIds.OrderBy(x => x.Key).ToDictionary(x => x.Key, y => y.Value); + this.HatedIds = this.HatedIds.OrderBy(x => x.Key).ToDictionary(x => x.Key, y => y.Value); + this.PersonRelationIds = this.PersonRelationIds.OrderBy(x => x.PersonID1).ToList(); + } + if (!disposeMemory) { this.DisposeLotsOfMemory(); @@ -4944,26 +4949,23 @@ public bool SaveGameScenario(string LoadedFileName, bool saveMap, bool saveCommo person.preferredTroopPersonsString = person.preferredTroopPersons.SaveToString(); person.TrainPolicyIDString = person.TrainPolicy == null ? -1 : person.TrainPolicy.ID; - } - } - - captiveData = this.Captives; - PersonRelationIds.Clear(); - - foreach (Person p in this.Persons) - { - foreach (KeyValuePair pi in p.GetRelations()) - { - var personIDRelation = new PersonIDRelation() + foreach (KeyValuePair pi in person.GetRelations()) { - PersonID1 = p.ID, - PersonID2 = pi.Key.ID, - Relation = pi.Value - }; - PersonRelationIds.Add(personIDRelation); + var personIDRelation = new PersonIDRelation() + { + PersonID1 = person.ID, + PersonID2 = pi.Key.ID, + Relation = pi.Value + }; + PersonRelationIds.Add(personIDRelation); + } } } + if(!editing) + { + captiveData = this.Captives; + } if (saveMap) { @@ -5026,10 +5028,13 @@ public bool SaveGameScenario(string LoadedFileName, bool saveMap, bool saveCommo } this.CurrentPlayerID = ((this.CurrentPlayer != null) ? this.CurrentPlayer.ID : -1).ToString(); - this.PlayerList = this.PlayerFactions.GameObjects.Select(ob => ob.ID).NullToEmptyList(); + if(!editing) + { + this.PlayerList = this.PlayerFactions.GameObjects.Select(ob => ob.ID).NullToEmptyList(); + this.PlayerInfo = this.GetPlayerInfo(); + } this.Factions.FactionQueue = this.Factions.SaveQueueToString(); - this.PlayerInfo = this.GetPlayerInfo(); //row["JumpPosition"] = StaticMethods.SaveToString(new Point?(ScenarioMap.JumpPosition)); @@ -5107,8 +5112,16 @@ public bool SaveGameScenario(string LoadedFileName, bool saveMap, bool saveCommo Time = time.ToSeasonDate(), Title = scenarioClone.ScenarioTitle }; - - SaveScenarioSaves(saves); + if(!editing) + { + SaveScenarioSaves(saves); + } + else + { + string saveDir = @"Save\"; + string saveFile = saveDir + "Saves.json"; + SimpleSerializer.SerializeJsonFile(saves, saveFile); + } } } diff --git a/WorldOfTheThreeKingdoms/GameObjects/Person.cs b/WorldOfTheThreeKingdoms/GameObjects/Person.cs index 07358ecae..ba27f4abc 100644 --- a/WorldOfTheThreeKingdoms/GameObjects/Person.cs +++ b/WorldOfTheThreeKingdoms/GameObjects/Person.cs @@ -466,7 +466,7 @@ public int Karma private Captive belongedCaptive; - [DataMember] + //[DataMember] public Captive BelongedCaptive { get @@ -11097,17 +11097,6 @@ public void SetRelation(Person p, int val) } } - //public void RemoveRelation(Person p) - //{ - // foreach (KeyValuePair i in this.relations) - // { - // if (i.Key == p) - // { - // this.relations.Remove(p); - // } - // } - //} - public Dictionary GetAllRelations() { return new Dictionary(this.relations); diff --git a/WorldOfTheThreeKingdoms/GameObjects/Troop.cs b/WorldOfTheThreeKingdoms/GameObjects/Troop.cs index e85716f41..9349f8cec 100644 --- a/WorldOfTheThreeKingdoms/GameObjects/Troop.cs +++ b/WorldOfTheThreeKingdoms/GameObjects/Troop.cs @@ -461,7 +461,7 @@ public void Init() private TierPathFinder simplepathFinder = new TierPathFinder(); [DataMember] public bool Simulating; - [DataMember] + //[DataMember] public CombatMethod SimulatingCombatMethod; private string SoundFileLocation; @@ -501,7 +501,7 @@ public TroopStatus TroopStatus private int stuntDayLeft; public bool StuntMustSurround; public bool StuntRecoverFromChaos; - [DataMember] + //[DataMember] public StuntTable Stunts = new StuntTable(); private int stuntTileAnimationIndex; private int stuntTileStayIndex; @@ -12250,7 +12250,7 @@ public string DisplayName } } - [DataMember] + //[DataMember] public bool DrawAnimation { get @@ -13058,70 +13058,72 @@ public Point Position } else { + if(this.army!=null) + { + bool runAnimation = Session.Current.Scenario.IsKnownToAnyPlayer(this); - bool runAnimation = Session.Current.Scenario.IsKnownToAnyPlayer(this); + bool oldInWater = this.Army.bushiShuijunBingqieChuyuShuiyu(this.position); + bool newInWater = this.Army.bushiShuijunBingqieChuyuShuiyu(value); + bool changeArmyKind = oldInWater != newInWater; - bool oldInWater = this.Army.bushiShuijunBingqieChuyuShuiyu(this.position); - bool newInWater = this.Army.bushiShuijunBingqieChuyuShuiyu(value); - bool changeArmyKind = oldInWater != newInWater; + if (changeArmyKind) + { + this.preResetArmyKindData(); + } - if (changeArmyKind) - { - this.preResetArmyKindData(); - } + if (changeArmyKind) + { + this.postResetArmyKindData(); + } - if (changeArmyKind) - { - this.postResetArmyKindData(); - } + // position updatd + runAnimation = runAnimation || Session.Current.Scenario.IsKnownToAnyPlayer(this); - // position updatd - runAnimation = runAnimation || Session.Current.Scenario.IsKnownToAnyPlayer(this); + if (runAnimation) + { + if (this.position != this.PreviousPosition) + { + this.Action = TroopAction.Move; + } + if ((this.position == this.destination) && (this.OnEndPath != null)) + { + this.OnEndPath(this); + } + } - if (runAnimation) - { - if (this.position != this.PreviousPosition) + int num = this.position.X - this.PreviousPosition.X; + int num2 = this.position.Y - this.PreviousPosition.Y; + Session.Current.Scenario.SetMapTileTroop(this); + if ((Math.Abs(num) + Math.Abs(num2)) > 0) { - this.Action = TroopAction.Move; + if (runAnimation) + { + this.TryToPlaySound(this.Position, this.Army.Kind.Sounds.MovingSoundPath, false); + } + this.CheckCurrentPosition(); + if (this.Destroyed) + { + return; + } + this.ResetTerrainData(); + this.RefreshTerrainRelatedData(); + this.MoveContactArea(num, num2); + this.MoveOffenceArea(num, num2); + this.MoveStratagemArea(num, num2); + this.MoveViewArea(num, num2); } - if ((this.position == this.destination) && (this.OnEndPath != null)) + if (Session.Current.Scenario.GetTroopByPosition(this.position) == this) { - this.OnEndPath(this); + this.StepNotFinished = true; } - } - - int num = this.position.X - this.PreviousPosition.X; - int num2 = this.position.Y - this.PreviousPosition.Y; - Session.Current.Scenario.SetMapTileTroop(this); - if ((Math.Abs(num) + Math.Abs(num2)) > 0) - { - if (runAnimation) + else { - this.TryToPlaySound(this.Position, this.Army.Kind.Sounds.MovingSoundPath, false); + this.StepNotFinished = false; } - this.CheckCurrentPosition(); - if (this.Destroyed) + if (this.FirstTierPath != null && runAnimation) { - return; + this.UpdateAnimation(); } - this.ResetTerrainData(); - this.RefreshTerrainRelatedData(); - this.MoveContactArea(num, num2); - this.MoveOffenceArea(num, num2); - this.MoveStratagemArea(num, num2); - this.MoveViewArea(num, num2); - } - if (Session.Current.Scenario.GetTroopByPosition(this.position) == this) - { - this.StepNotFinished = true; - } - else - { - this.StepNotFinished = false; - } - if (this.FirstTierPath != null && runAnimation) - { - this.UpdateAnimation(); } } } diff --git a/WorldOfTheThreeKingdoms/GameObjects/TroopDetail/CombatMethod.cs b/WorldOfTheThreeKingdoms/GameObjects/TroopDetail/CombatMethod.cs index 36d3baca0..088a0c878 100644 --- a/WorldOfTheThreeKingdoms/GameObjects/TroopDetail/CombatMethod.cs +++ b/WorldOfTheThreeKingdoms/GameObjects/TroopDetail/CombatMethod.cs @@ -132,7 +132,7 @@ public bool ArchitectureTarget [DataMember] public int AttackTargetString { get; set; } - [DataMember] + //[DataMember] public AttackDefaultKind AttackDefault { get @@ -145,7 +145,7 @@ public AttackDefaultKind AttackDefault } } - [DataMember] + //[DataMember] public AttackTargetKind AttackTarget { get diff --git a/WorldOfTheThreeKingdoms/GameObjects/TroopDetail/MilitaryKind.cs b/WorldOfTheThreeKingdoms/GameObjects/TroopDetail/MilitaryKind.cs index 1a0ab2ba4..493d16c74 100644 --- a/WorldOfTheThreeKingdoms/GameObjects/TroopDetail/MilitaryKind.cs +++ b/WorldOfTheThreeKingdoms/GameObjects/TroopDetail/MilitaryKind.cs @@ -77,7 +77,7 @@ public string InfluencesString private int rationDays; private int ridgeAdaptability; private float ridgeRate; - [DataMember] + //[DataMember] public TroopSounds Sounds; private int speed; private int stratagemRadius; diff --git a/WorldOfTheThreeKingdoms/GameObjects/TroopEvent.cs b/WorldOfTheThreeKingdoms/GameObjects/TroopEvent.cs index 7001368dd..b9473393a 100644 --- a/WorldOfTheThreeKingdoms/GameObjects/TroopEvent.cs +++ b/WorldOfTheThreeKingdoms/GameObjects/TroopEvent.cs @@ -25,7 +25,7 @@ public class TroopEvent : GameObject public ConditionTable Conditions = new ConditionTable(); - [DataMember] + //[DataMember] public List Dialogs = new List(); [DataMember] diff --git a/WorldOfTheThreeKingdoms/GameObjects/zainanlei.cs b/WorldOfTheThreeKingdoms/GameObjects/zainanlei.cs index 4e97fe225..0b6115522 100644 --- a/WorldOfTheThreeKingdoms/GameObjects/zainanlei.cs +++ b/WorldOfTheThreeKingdoms/GameObjects/zainanlei.cs @@ -26,5 +26,12 @@ public int shengyutianshu get; set; } - } + + public string SavezainantoString() + { + string result = ""; + result = zainanleixing.ToString() + " " + shengyutianshu.ToString()+" "; + return result; + } + } } diff --git a/json and excel/Form1.cs b/json and excel/Form1.cs index 48eab6a57..532e16635 100644 --- a/json and excel/Form1.cs +++ b/json and excel/Form1.cs @@ -8802,7 +8802,6 @@ private void exceltojson(int k) } // a.PreferredTechniqueKinds a.ClosedRouteways = new Dictionary(); - a.SpyMessageCloseList = new Dictionary(); for (int ii = 1; ii <= worksheet.Dimension.End.Column; ii++) { if (worksheet.Cells[1, ii].Value.ToString() == "PreferredTechniqueKinds")