public static Military Create(GameScenario scenario, Architecture architecture, MilitaryKind kind) { Military military = new Military(); military.Scenario = scenario; military.KindID = kind.ID; military.ID = scenario.Militaries.GetFreeGameObjectID(); if (kind.RecruitLimit == 1) { military.Name = kind.Name; } else { military.Name = kind.Name + "队"; } architecture.AddMilitary(military); architecture.BelongedFaction.AddMilitary(military); scenario.Militaries.AddMilitary(military); architecture.DecreaseFund((int) (kind.CreateCost * kind.GetRateOfNewMilitary(architecture))); if (kind.IsTransport) { military.Quantity = kind.MaxScale; military.Morale = military.MoraleCeiling; military.Combativity = military.CombativityCeiling; } return military; }
public void AddBasicMilitaryKinds(GameScenario scen) { this.AddMilitaryKind(scen.GameCommonData.AllMilitaryKinds.GetMilitaryKindList().GetGameObject(0) as MilitaryKind); this.AddMilitaryKind(scen.GameCommonData.AllMilitaryKinds.GetMilitaryKindList().GetGameObject(1) as MilitaryKind); this.AddMilitaryKind(scen.GameCommonData.AllMilitaryKinds.GetMilitaryKindList().GetGameObject(2) as MilitaryKind); this.AddMilitaryKind(scen.GameCommonData.AllMilitaryKinds.GetMilitaryKindList().GetGameObject(30) as MilitaryKind); }
private static void CheckPoint(GameArea Area, List<Point> BlackAngles, Point point, GameScenario Scenario, Faction faction) { TerrainDetail terrainDetailByPosition = Scenario.GetTerrainDetailByPosition(point); if (terrainDetailByPosition != null) { if (terrainDetailByPosition.ViewThrough) { if (faction != null) { Architecture architectureByPosition = Scenario.GetArchitectureByPosition(point); if (!(architectureByPosition == null || architectureByPosition.Endurance <= 0 || faction.IsFriendlyWithoutTruce(architectureByPosition.BelongedFaction))) { BlackAngles.Add(point); return; } } if (!IsInBlackAngle(Area.Centre, BlackAngles, point)) { Area.AddPoint(point); } } else { BlackAngles.Add(point); } } }
public DiplomaticRelation(GameScenario scenario, int faction1ID, int faction2ID, int relation) { this.relationFaction1ID = -1; this.relationFaction2ID = -1; base.Scenario = scenario; this.RelationFaction1ID = faction1ID; this.RelationFaction2ID = faction2ID; this.Relation = relation; }
public void Initialize(formMapEditor form) { this.MainForm = form; this.Scenario = form.Scenario; this.mtbYear.Text = this.Scenario.Date.Year.ToString(); this.cbMonth.SelectedIndex = this.cbMonth.Items.IndexOf(this.Scenario.Date.Month.ToString()); this.cbDay.SelectedIndex = this.cbDay.Items.IndexOf(this.Scenario.Date.Day.ToString()); this.tbScenarioTitle.Text = this.Scenario.ScenarioTitle; this.rtbScenarioBrief.Text = this.Scenario.ScenarioDescription; }
public bool AddDiplomaticRelation(GameScenario scenario, int faction1ID, int faction2ID, int relation) { int hashCode = this.GetHashCode(faction1ID, faction2ID); int key = this.GetHashCode(faction2ID, faction1ID); if (this.DiplomaticRelations.ContainsKey(hashCode) || this.DiplomaticRelations.ContainsKey(key)) { return false; } this.DiplomaticRelations.Add(hashCode, new DiplomaticRelation(scenario, faction1ID, faction2ID, relation)); return true; }
public bool RemoveMilitaryKind(GameScenario scenario, int kind) { if (!this.MilitaryKinds.ContainsKey(kind)) { return false; } MilitaryKind militaryKind = scenario.GameCommonData.AllMilitaryKinds.GetMilitaryKind(kind); if (militaryKind != null) { this.MilitaryKinds.Remove(militaryKind.ID); } return true; }
public static GameArea GetAreaFromArea(GameArea area, int Radius, bool Oblique, GameScenario Scenario, Faction faction) { Dictionary<Point, object> closedList = new Dictionary<Point, object>(); GameArea area2 = new GameArea(); foreach (Point point in area.Area) { area2.CombineArea(GetViewArea(point, Radius, Oblique, Scenario, faction), closedList); } foreach (Point point in closedList.Keys) { area2.Area.Add(point); } return area2; }
public DiplomaticRelation GetDiplomaticRelation(GameScenario scenario, int faction1ID, int faction2ID) { int hashCode = this.GetHashCode(faction1ID, faction2ID); DiplomaticRelation relation = null; this.DiplomaticRelations.TryGetValue(hashCode, out relation); if (relation == null) { hashCode = this.GetHashCode(faction2ID, faction1ID); this.DiplomaticRelations.TryGetValue(hashCode, out relation); } if (relation == null) { relation = new DiplomaticRelation(scenario, faction1ID, faction2ID, 0); } return relation; }
public static Captive Create(GameScenario scenario, Person person, Faction capturingFaction) { if (person.BelongedFaction == null) { return null; } if (person.BelongedFaction == capturingFaction) { return null; } Captive captive = new Captive(); captive.Scenario = scenario; captive.ID = scenario.Captives.GetFreeGameObjectID(); captive.CaptivePerson = person; captive.CaptiveFaction = person.BelongedFaction; person.SetBelongedCaptive(captive, GameObjects.PersonDetail.PersonStatus.Captive); person.HeldCaptiveCount++; scenario.Captives.AddCaptiveWithEvent(captive); return captive; }
private bool ChallengeOftenShow = false; //暴击必然触发单挑,调试单挑程序用,默认为false internal void ChallgenEvent(Troop sourceTroop, Troop troop, TroopDamage damage, GameScenario gameScenario) { if ((!sourceTroop.IsFriendly(troop.BelongedFaction) && !sourceTroop.AirOffence) && (this.ChallengeOftenShow || GameObject.Chance(20))) { Person maxStrengthPerson = sourceTroop.Persons.GetMaxStrengthPerson(); Person destination = troop.Persons.GetMaxStrengthPerson(); if (((maxStrengthPerson != null) && (destination != null)) && (this.ChallengeOftenShow || (GameObject.Random(GameObject.Square(destination.Calmness)) < GameObject.Random(0x19)))) { if (maxStrengthPerson.IsCivil() || destination.IsCivil()) //文官不单挑 { return; } int chance = Person.ChanlengeWinningChance(maxStrengthPerson, destination); if (this.ChallengeOftenShow || (maxStrengthPerson.Character.ChallengeChance + chance) >= 60) { this.challengeHappen(damage, maxStrengthPerson, destination, chance, gameScenario); } } } }
public static Captive Create(GameScenario scenario, Person person, Faction faction) { if (person.BelongedFaction == null) { return null; } if (person.BelongedFaction == faction) { return null; } Captive captive = new Captive(); captive.Scenario = scenario; captive.ID = scenario.Captives.GetFreeGameObjectID(); captive.CaptivePerson = person; person.BelongedCaptive = captive; captive.CaptiveFaction = person.BelongedFaction; scenario.Captives.AddCaptiveWithEvent(captive); captive.CaptiveFaction.AddSelfCaptive(captive); faction.AddCaptive(captive); return captive; }
private void challengeHappen(TroopDamage damage, Person maxStrengthPerson, Person destination, int chance,GameScenario scenario) { int flag = 0; damage.ChallengeHappened = true; //单挑发生 if ((GlobalVariables.ShowChallengeAnimation) && (scenario.IsPlayer(maxStrengthPerson.BelongedFaction) || scenario.IsPlayer(destination.BelongedFaction) || GlobalVariables.SkyEye || this.ChallengeOftenShow)) //单挑双方有玩家的武将才演示 { try { int returnValue; returnValue = this.challengeShow(maxStrengthPerson, destination); //returnValue = 10; if (returnValue >= -4 && returnValue <= 10 && returnValue != 0) { flag = returnValue; } else //返回值出错时避免跳出 { flag = (GameObject.Chance(chance) ? 1 : 2); } } catch { flag = (GameObject.Chance(chance) ? 1 : 2); } } else { flag = (GameObject.Chance(chance) ? 1 : 2); } //flag = -4; damage.ChallengeResult = flag; damage.ChallengeSourcePerson = maxStrengthPerson; damage.ChallengeDestinationPerson = destination; }
public static Military SimCreate(GameScenario scenario, Architecture architecture, MilitaryKind kind) { Military military = new Military(); military.Scenario = scenario; military.KindID = kind.ID; military.ID = scenario.Militaries.GetFreeGameObjectID(); if (kind.RecruitLimit == 1) { military.Name = kind.Name; return military; } military.Name = kind.Name + "队"; return military; }
public void Initialize(GameScenario scenario) { this.gameScenario = scenario; }
internal void Initialize(Screen screen) { this.screen = screen; this.scenario = screen.Scenario; screen.OnMouseLeftDown += new Screen.MouseLeftDown(this.screen_OnMouseLeftDown); screen.OnMouseMove += new Screen.MouseMove(this.screen_OnMouseMove); }
public List<string> LoadPersonGeneratorSetting(OleDbConnection connection, GameScenario scen) { connection.Open(); OleDbDataReader reader = new OleDbCommand("Select * From PersonGenerator", connection).ExecuteReader(); while (reader.Read()) { this.PersonGeneratorSetting.bornLo = (int)reader["BornLo"]; this.PersonGeneratorSetting.bornHi = (int)reader["BornHi"]; this.PersonGeneratorSetting.debutLo = (int)reader["DebutLo"]; this.PersonGeneratorSetting.debutHi = (int)reader["DebutHi"]; this.PersonGeneratorSetting.dieLo = (int)reader["DieLo"]; this.PersonGeneratorSetting.dieHi = (int)reader["DieHi"]; this.PersonGeneratorSetting.femaleChance = (int)reader["FemaleChance"]; this.PersonGeneratorSetting.debutAtLeast = (int)reader["DebutAtLeast"]; } connection.Close(); return new List<string>(); }
public bool IsStart(GameScenario scenario) { Condition cstart = scenario.GameCommonData.AllConditions.GetCondition(9998); return this.architectureCond.Contains(cstart) || this.factionCond.Contains(cstart); }
public GameArea GetContactArea(bool oblique, GameScenario scen, bool waterOnly, bool landOnly) { GameArea area = new GameArea(); Dictionary<Point, object> dictionary = new Dictionary<Point, object>(); foreach (Point point2 in this.Area) { bool ok = true; if (waterOnly && scen.GetTerrainDetailByPositionNoCheck(point2).ID != 6) { ok = false; } if (landOnly && scen.GetTerrainDetailByPositionNoCheck(point2).ID == 6) { ok = false; } if (ok) { dictionary.Add(point2, null); } } foreach (Point point2 in this.Area) { Point key = new Point(point2.X - 1, point2.Y); if (!dictionary.ContainsKey(key) && (!waterOnly || scen.GetTerrainDetailByPositionNoCheck(point2).ID == 6)) { dictionary.Add(key, null); area.AddPoint(key); } key = new Point(point2.X + 1, point2.Y); if (!dictionary.ContainsKey(key) && (!waterOnly || scen.GetTerrainDetailByPositionNoCheck(point2).ID == 6)) { dictionary.Add(key, null); area.AddPoint(key); } key = new Point(point2.X, point2.Y - 1); if (!dictionary.ContainsKey(key) && (!waterOnly || scen.GetTerrainDetailByPositionNoCheck(point2).ID == 6)) { dictionary.Add(key, null); area.AddPoint(key); } key = new Point(point2.X, point2.Y + 1); if (!dictionary.ContainsKey(key) && (!waterOnly || scen.GetTerrainDetailByPositionNoCheck(point2).ID == 6)) { dictionary.Add(key, null); area.AddPoint(key); } if (oblique) { key = new Point(point2.X - 1, point2.Y - 1); if (!dictionary.ContainsKey(key) && (!waterOnly || scen.GetTerrainDetailByPositionNoCheck(point2).ID == 6)) { dictionary.Add(key, null); area.AddPoint(key); } key = new Point(point2.X + 1, point2.Y - 1); if (!dictionary.ContainsKey(key) && (!waterOnly || scen.GetTerrainDetailByPositionNoCheck(point2).ID == 6)) { dictionary.Add(key, null); area.AddPoint(key); } key = new Point(point2.X - 1, point2.Y + 1); if (!dictionary.ContainsKey(key) && (!waterOnly || scen.GetTerrainDetailByPositionNoCheck(point2).ID == 6)) { dictionary.Add(key, null); area.AddPoint(key); } key = new Point(point2.X + 1, point2.Y + 1); if (!dictionary.ContainsKey(key) && (!waterOnly || scen.GetTerrainDetailByPositionNoCheck(point2).ID == 6)) { dictionary.Add(key, null); area.AddPoint(key); } } } return area; }
public void Initialize(GameScenario scenario, MainGameScreen screen, GraphicsDevice device) { this.gameScenario = scenario; this.mainMap = scenario.ScenarioMap; this.screen = screen; this.device = device; this.TerrainList.Clear(); for (int i = 0; i < Enum.GetValues(typeof(TerrainKind)).Length; i++) { this.TerrainList.Add(0); } }
internal void HandleChallengeResult(TroopDamage damage, int result, Troop sourceTroop, Person sourcePerson, Troop destinationTroop, Person destinationPerson, GameScenario scenario) { scenario.GameScreen.TroopPersonChallenge(result, sourceTroop, sourcePerson, destinationTroop, destinationPerson); switch (result) { case 1: //P1武将胜利 sourcePerson.Scenario.YearTable.addChallengeEntry(sourcePerson.Scenario.Date, sourcePerson, destinationPerson, "被打下馬"); damage.SourceMoraleChange += 20; damage.DestinationMoraleChange -= 20; damage.SourceCombativityChange += 20; damage.DestinationCombativityChange -= 20; //第2只军队战意下降 break; case 2: //2:P2武将胜利 sourcePerson.Scenario.YearTable.addChallengeEntry(sourcePerson.Scenario.Date, destinationPerson, sourcePerson, "被打下馬"); damage.SourceMoraleChange -= 20; damage.DestinationMoraleChange += 20; damage.SourceCombativityChange -= 20; damage.DestinationCombativityChange += 20; break; case 3: //3:P1武将被杀 sourcePerson.Scenario.YearTable.addChallengeEntry(sourcePerson.Scenario.Date, destinationPerson, sourcePerson, "被擊殺"); this.challengePersonDie(sourcePerson,sourceTroop, destinationPerson); damage.SourceMoraleChange -= 30; damage.DestinationMoraleChange += 30; damage.SourceCombativityChange -= 30; damage.DestinationCombativityChange += 30; break; case 4: //4:P2武将被杀 sourcePerson.Scenario.YearTable.addChallengeEntry(sourcePerson.Scenario.Date, sourcePerson, destinationPerson, "被擊殺"); this.challengePersonDie(destinationPerson, destinationTroop, sourcePerson); damage.SourceMoraleChange += 30; damage.DestinationMoraleChange -= 30; damage.SourceCombativityChange += 30; damage.DestinationCombativityChange -= 30; break; case 5: //5:P1武将逃跑 sourcePerson.Scenario.YearTable.addChallengeEntry(sourcePerson.Scenario.Date, destinationPerson, sourcePerson, "逃跑"); damage.SourceMoraleChange -= 20; damage.DestinationMoraleChange += 20; break; case 6: //6:P2武将逃跑 sourcePerson.Scenario.YearTable.addChallengeEntry(sourcePerson.Scenario.Date, sourcePerson, destinationPerson, "逃跑"); damage.SourceMoraleChange += 20; damage.DestinationMoraleChange -= 20; break; case 7: //7、P1武将被俘虏 sourcePerson.Scenario.YearTable.addChallengeEntry(sourcePerson.Scenario.Date, destinationPerson, sourcePerson, "被俘虜"); destinationTroop.CatchCaptiveFromTroop(sourcePerson); sourceTroop.RefreshAfterLosePerson(); damage.SourceMoraleChange -= 20; damage.DestinationMoraleChange += 20; damage.SourceCombativityChange -= 20; damage.DestinationCombativityChange += 20; break; case 8: //8、P2武将被俘虏 sourcePerson.Scenario.YearTable.addChallengeEntry(sourcePerson.Scenario.Date, sourcePerson, destinationPerson, "被俘虜"); sourceTroop.CatchCaptiveFromTroop(destinationPerson); destinationTroop.RefreshAfterLosePerson(); damage.SourceMoraleChange += 20; damage.DestinationMoraleChange -= 20; damage.SourceCombativityChange += 20; damage.DestinationCombativityChange -= 20; break; case 9: //9、P1武将被说服 sourcePerson.Scenario.YearTable.addChallengeEntry(sourcePerson.Scenario.Date, destinationPerson, sourcePerson, "被說服"); destinationPerson.ConvincePersonSuccess(sourcePerson); damage.SourceCombativityChange -= 30; damage.DestinationCombativityChange += 30; break; case 10: //10、P2武将被说服 sourcePerson.Scenario.YearTable.addChallengeEntry(sourcePerson.Scenario.Date, sourcePerson, destinationPerson, "被說服"); sourcePerson.ConvincePersonSuccess(destinationPerson); damage.SourceCombativityChange += 30; damage.DestinationCombativityChange -= 30; break; case -1: //-1:平局 sourcePerson.Scenario.YearTable.addChallengeDrawEntry(sourcePerson.Scenario.Date, sourcePerson, destinationPerson); break; case -2: //-2:平局:P1武将被杀 sourcePerson.Scenario.YearTable.addChallengeDrawKilledEntry(sourcePerson.Scenario.Date, destinationPerson, sourcePerson); this.challengePersonDie(sourcePerson, sourceTroop, destinationPerson); break; case -3: //-3:平局:P2武将被杀 sourcePerson.Scenario.YearTable.addChallengeDrawKilledEntry(sourcePerson.Scenario.Date, sourcePerson, destinationPerson); this.challengePersonDie(destinationPerson, destinationTroop, sourcePerson); break; case -4: //-4:平局:双方武将被杀 sourcePerson.Scenario.YearTable.addChallengeDrawBothKilledEntry(sourcePerson.Scenario.Date, sourcePerson, destinationPerson); this.challengePersonDie(sourcePerson, sourceTroop, destinationPerson); this.challengePersonDie(destinationPerson, destinationTroop, sourcePerson); break; } }
public List<string> LoadPersonGeneratorTypes(OleDbConnection connection, GameScenario scen) { connection.Open(); OleDbDataReader reader = new OleDbCommand("Select * From PersonGeneratorType", connection).ExecuteReader(); bool hasZero = false; while (reader.Read()) { PersonGeneratorType type = new PersonGeneratorType(); type.ID = (int)reader["ID"]; if (type.ID == 0) { hasZero = true; } type.Name = reader["TypeName"].ToString(); type.generationChance = (int)reader["GenerationChance"]; type.commandLo = (int)reader["CommandLo"]; type.commandHi = (int)reader["CommandHi"]; type.strengthLo = (int)reader["StrengthLo"]; type.strengthHi = (int)reader["StrengthHi"]; type.intelligenceLo = (int)reader["IntelligenceLo"]; type.intelligenceHi = (int)reader["IntelligenceHi"]; type.politicsLo = (int)reader["PoliticsLo"]; type.politicsHi = (int)reader["PoliticsHi"]; type.glamourLo = (int)reader["GlamourLo"]; type.glamourHi = (int)reader["GlamourHi"]; type.braveLo = (int)reader["BraveLo"]; type.braveHi = (int)reader["BraveHi"]; type.calmnessLo = (int)reader["CalmnessLo"]; type.calmnessHi = (int)reader["CalmnessHi"]; type.personalLoyaltyLo = (int)reader["PersonalLoyaltyLo"]; type.personalLoyaltyHi = (int)reader["PersonalLoyaltyHi"]; type.ambitionLo = (int)reader["AmbitionLo"]; type.ambitionHi = (int)reader["AmbitionHi"]; type.titleChance = (int)reader["TitleChance"]; type.affectedByRateParameter = (bool)reader["AffectedByRateParameter"]; this.AllPersonGeneratorTypes.Add(type); } connection.Close(); // for backward compatibility if (!hasZero) { foreach (PersonGeneratorType type in this.AllPersonGeneratorTypes) { type.ID--; } } return new List<string>(); }
}//结束DRAW函数 public void Initialize(MainMapLayer mainMapLayer, GameScenario scenario) { this.mainMapLayer = mainMapLayer; this.scenario = scenario; }
public static GameArea GetViewArea(Point Centre, int Radius, bool Oblique, GameScenario Scenario, Faction faction) { GameArea area = new GameArea(); List<Point> blackAngles = new List<Point>(); area.Centre = Centre; if (Radius < 0) return area; if (Radius == 0) { area.AddPoint(Centre); return area; } for (int i = 0; i <= Radius; i++) { int num2; if (i == 0) { num2 = 0; while (num2 <= Radius) { if (num2 != 0) { CheckPoint(area, blackAngles, new Point(Centre.X, Centre.Y + num2), Scenario, faction); CheckPoint(area, blackAngles, new Point(Centre.X, Centre.Y - num2), Scenario, faction); } else { area.AddPoint(Centre); } num2++; } } else { int num3 = i; if (Oblique) { num3 = 0; } num2 = 0; while (num2 <= (Radius - num3)) { CheckPoint(area, blackAngles, new Point(Centre.X + i, Centre.Y + num2), Scenario, faction); if (num2 != 0) { CheckPoint(area, blackAngles, new Point(Centre.X + i, Centre.Y - num2), Scenario, faction); } num2++; } for (num2 = 0; num2 <= (Radius - num3); num2++) { CheckPoint(area, blackAngles, new Point(Centre.X - i, Centre.Y + num2), Scenario, faction); if (num2 != 0) { CheckPoint(area, blackAngles, new Point(Centre.X - i, Centre.Y - num2), Scenario, faction); } } } } return area; }
public void LoadTextures(GraphicsDevice device, GameScenario scenario) { Exception exception; string str; //this.BackgroundMap = Texture2D.FromFile(device, "Resources/bg.jpg"); try { this.MouseArrowTextures = new Texture2D[Enum.GetValues(typeof(MouseArrowKind)).Length]; this.MouseArrowTextures[0] = Texture2D.FromFile(device, "Resources/MouseArrow/Normal.png"); this.MouseArrowTextures[1] = Texture2D.FromFile(device, "Resources/MouseArrow/Left.png"); this.MouseArrowTextures[2] = Texture2D.FromFile(device, "Resources/MouseArrow/Right.png"); this.MouseArrowTextures[3] = Texture2D.FromFile(device, "Resources/MouseArrow/Top.png"); this.MouseArrowTextures[4] = Texture2D.FromFile(device, "Resources/MouseArrow/Bottom.png"); this.MouseArrowTextures[5] = Texture2D.FromFile(device, "Resources/MouseArrow/TopLeft.png"); this.MouseArrowTextures[6] = Texture2D.FromFile(device, "Resources/MouseArrow/TopRight.png"); this.MouseArrowTextures[7] = Texture2D.FromFile(device, "Resources/MouseArrow/BottomLeft.png"); this.MouseArrowTextures[8] = Texture2D.FromFile(device, "Resources/MouseArrow/BottomRight.png"); this.MouseArrowTextures[9] = Texture2D.FromFile(device, "Resources/MouseArrow/Selecting.png"); } catch (Exception exception1) { exception = exception1; throw new Exception("The MouseArrow Textures are not completely loaded.\n" + exception.ToString()); } try { foreach (TerrainDetail detail in scenario.GameCommonData.AllTerrainDetails.TerrainDetails.Values) { str = "Resources/Terrain/" + detail.ID.ToString() + "/"; detail.Textures.BasicTextures.Clear(); if (Directory.Exists(str)) { foreach (string str2 in Directory.GetFiles(str)) { FileInfo info = new FileInfo(str2); if (info.Extension.Equals(".bmp") && info.Name.Contains("Basic")) { detail.Textures.BasicTextures.Add(Texture2D.FromFile(device, str2)); } /* else if (info.Extension.Equals(".png") && info.Name.Contains("TopLeftCorner")) { detail.Textures.TopLeftCornerTextures.Add(Texture2D.FromFile(device, str2)); } else if (info.Extension.Equals(".png") && info.Name.Contains("TopRightCorner")) { detail.Textures.TopRightCornerTextures.Add(Texture2D.FromFile(device, str2)); } else if (info.Extension.Equals(".png") && info.Name.Contains("BottomLeftCorner")) { detail.Textures.BottomLeftCornerTextures.Add(Texture2D.FromFile(device, str2)); } else if (info.Extension.Equals(".png") && info.Name.Contains("BottomRightCorner")) { detail.Textures.BottomRightCornerTextures.Add(Texture2D.FromFile(device, str2)); } else if (info.Extension.Equals(".png") && info.Name.Contains("Centre")) { detail.Textures.CentreTextures.Add(Texture2D.FromFile(device, str2)); } else if (info.Extension.Equals(".png") && info.Name.Contains("LeftEdge")) { detail.Textures.LeftEdgeTextures.Add(Texture2D.FromFile(device, str2)); } else if (info.Extension.Equals(".png") && info.Name.Contains("TopEdge")) { detail.Textures.TopEdgeTextures.Add(Texture2D.FromFile(device, str2)); } else if (info.Extension.Equals(".png") && info.Name.Contains("RightEdge")) { detail.Textures.RightEdgeTextures.Add(Texture2D.FromFile(device, str2)); } else if (info.Extension.Equals(".png") && info.Name.Contains("BottomEdge")) { detail.Textures.BottomEdgeTextures.Add(Texture2D.FromFile(device, str2)); } else if (info.Extension.Equals(".png") && info.Name.Contains("Left")) { detail.Textures.LeftTextures.Add(Texture2D.FromFile(device, str2)); } else if (info.Extension.Equals(".png") && info.Name.Contains("Top")) { detail.Textures.TopTextures.Add(Texture2D.FromFile(device, str2)); } else if (info.Extension.Equals(".png") && info.Name.Contains("Right")) { detail.Textures.RightTextures.Add(Texture2D.FromFile(device, str2)); } else if (info.Extension.Equals(".png") && info.Name.Contains("Bottom")) { detail.Textures.BottomTextures.Add(Texture2D.FromFile(device, str2)); } */ } } } } catch (Exception exception2) { exception = exception2; throw new Exception("The Terrain Textures are not completely loaded.\n" + exception.ToString()); } try //加载建筑 { foreach (ArchitectureKind kind in scenario.GameCommonData.AllArchitectureKinds.ArchitectureKinds.Values ) { kind.Device = device; } } catch (Exception exception3) { exception = exception3; throw new Exception("The Architecture Textures are not completely loaded.\n" + exception.ToString()); } try { foreach (MilitaryKind kind2 in scenario.GameCommonData.AllMilitaryKinds.MilitaryKinds.Values) { str = "Resources/Troop/" + kind2.ID.ToString() + "/"; if (Directory.Exists(str)) { TroopTextures textures = new TroopTextures { Device = device, MoveTextureFileName = str + "Move.png", AttackTextureFileName = str + "Attack.png", BeAttackedTextureFileName = str + "BeAttacked.png", CastTextureFileName = str + "Cast.png" }; if (!File.Exists(textures.CastTextureFileName)) { textures.CastTextureFileName = textures.AttackTextureFileName; } textures.BeCastedTextureFileName = str + "BeCasted.png"; if (!File.Exists(textures.BeCastedTextureFileName)) { textures.BeCastedTextureFileName = textures.BeAttackedTextureFileName; } kind2.Textures = textures; TroopSounds sounds = new TroopSounds { MovingSoundPath = str + "Moving.wav", NormalAttackSoundPath = str + "NormalAttack.wav", CriticalAttackSoundPath = str + "CriticalAttack.wav" }; kind2.Sounds = sounds; } } } catch (Exception exception4) { exception = exception4; throw new Exception("The Troop Textures are not completely loaded.\n" + exception.ToString()); } try { this.MapVeilTextures = new Texture2D[Enum.GetValues(typeof(MapVeilKind)).Length]; this.MapVeilTextures[0] = Texture2D.FromFile(device, "Resources/MapVeil/Gray.bmp"); } catch (Exception exception5) { exception = exception5; throw new Exception("The MapVeil Textures are not completely loaded.\n" + exception.ToString()); } try { this.TileFrameTextures = new Texture2D[Enum.GetValues(typeof(TileFrameKind)).Length]; this.TileFrameTextures[0] = Texture2D.FromFile(device, "Resources/TileFrame/White.png"); this.TileFrameTextures[1] = Texture2D.FromFile(device, "Resources/TileFrame/Black.png"); this.TileFrameTextures[2] = Texture2D.FromFile(device, "Resources/TileFrame/Red.png"); this.TileFrameTextures[3] = Texture2D.FromFile(device, "Resources/TileFrame/Blue.png"); this.TileFrameTextures[4] = Texture2D.FromFile(device, "Resources/TileFrame/Green.png"); this.TileFrameTextures[5] = Texture2D.FromFile(device, "Resources/TileFrame/Purple.png"); this.TileFrameTextures[6] = Texture2D.FromFile(device, "Resources/TileFrame/Yellow.png"); } catch (Exception exception6) { exception = exception6; throw new Exception("The TileFrame Textures are not completely loaded.\n" + exception.ToString()); } try { this.RoutewayTextures = new Texture2D[Enum.GetValues(typeof(RoutewayState)).Length]; this.RoutewayTextures[0] = Texture2D.FromFile(device, "Resources/Routeway/Planning.png"); this.RoutewayTextures[1] = Texture2D.FromFile(device, "Resources/Routeway/Active.png"); this.RoutewayTextures[2] = Texture2D.FromFile(device, "Resources/Routeway/Inefficiency.png"); this.RoutewayTextures[3] = Texture2D.FromFile(device, "Resources/Routeway/Building.png"); this.RoutewayTextures[4] = Texture2D.FromFile(device, "Resources/Routeway/NoFood.png"); this.RoutewayTextures[5] = Texture2D.FromFile(device, "Resources/Routeway/Hostile.png"); this.RoutewayDirectionArrowTextures = new Texture2D[Enum.GetValues(typeof(SimpleDirection)).Length]; this.RoutewayDirectionArrowTextures[0] = Texture2D.FromFile(device, "Resources/Routeway/DirectionArrowNone.png"); this.RoutewayDirectionArrowTextures[1] = Texture2D.FromFile(device, "Resources/Routeway/DirectionArrowLeft.png"); this.RoutewayDirectionArrowTextures[2] = Texture2D.FromFile(device, "Resources/Routeway/DirectionArrowUp.png"); this.RoutewayDirectionArrowTextures[3] = Texture2D.FromFile(device, "Resources/Routeway/DirectionArrowRight.png"); this.RoutewayDirectionArrowTextures[4] = Texture2D.FromFile(device, "Resources/Routeway/DirectionArrowDown.png"); this.RoutewayDirectionTailTextures = new Texture2D[Enum.GetValues(typeof(SimpleDirection)).Length]; this.RoutewayDirectionTailTextures[1] = Texture2D.FromFile(device, "Resources/Routeway/DirectionTailLeft.png"); this.RoutewayDirectionTailTextures[2] = Texture2D.FromFile(device, "Resources/Routeway/DirectionTailUp.png"); this.RoutewayDirectionTailTextures[3] = Texture2D.FromFile(device, "Resources/Routeway/DirectionTailRight.png"); this.RoutewayDirectionTailTextures[4] = Texture2D.FromFile(device, "Resources/Routeway/DirectionTailDown.png"); } catch (Exception exception7) { exception = exception7; throw new Exception("The Routeway Textures are not completely loaded.\n" + exception.ToString()); } try { foreach (Animation animation in scenario.GameCommonData.AllTileAnimations.Animations.Values) { animation.Device = device; animation.TextureFileName = "Resources/Effects/TileEffect/" + animation.Name + ".png"; animation.MaleSoundPath = "GameSound/Animation/Male/" + animation.Name + ".wav"; if (!File.Exists(animation.MaleSoundPath)) { animation.MaleSoundPath = "GameSound/Animation/" + animation.Name + ".wav"; } animation.FemaleSoundPath = "GameSound/Animation/Female/" + animation.Name + ".wav"; if (!File.Exists(animation.FemaleSoundPath)) { animation.FemaleSoundPath = "GameSound/Animation/" + animation.Name + ".wav"; } } } catch (Exception exception8) { exception = exception8; throw new Exception("The TileAnimation Textures are not completely loaded.\n" + exception.ToString()); } try { scenario.GameCommonData.NumberGenerator.Device = device; scenario.GameCommonData.NumberGenerator.TextureFileName = "Resources/Effects/CombatNumber/CombatNumber.png"; } catch (Exception exception9) { exception = exception9; throw new Exception("The NumberGenerator Textures are not completely loaded.\n" + exception.ToString()); } try { this.SelectorTexture = Texture2D.FromFile(device, "Resources/Effects/Selector/Selector.png"); } catch (Exception exception10) { exception = exception10; throw new Exception("The NumberGenerator Textures are not completely loaded.\n" + exception.ToString()); } try { this.qizitupian = Texture2D.FromFile(device, "Resources/Architecture/qizi.png"); } catch (Exception exception11) { exception = exception11; throw new Exception("The qizi Textures are not completely loaded.\n" + exception.ToString()); } try { this.huangditupian = Texture2D.FromFile(device, "Resources/Architecture/huangdi.png"); } catch (Exception exception11) { exception = exception11; throw new Exception("The huangdi Textures are not completely loaded.\n" + exception.ToString()); } try { this.LandConnect = Texture2D.FromFile(device, "Resources/Architecture/LandConnect.png"); this.WaterConnect = Texture2D.FromFile(device, "Resources/Architecture/WaterConnect.png"); this.SingleConnect = Texture2D.FromFile(device, "Resources/Architecture/SingleConnect.png"); } catch (Exception exception12) { exception = exception12; throw new Exception("The ArchitectureConnect Textures are not completely loaded.\n" + exception.ToString()); } //this.jianzhubiaotibeijing = Texture2D.FromFile(device, "Resources/Architecture/jianzhubiaotibeijing.png"); mediumCityImg.Clear(); largeCityImg.Clear(); string[] filePaths = Directory.GetFiles("Resources/Architecture/", "*.png"); foreach (String s in filePaths) { string fileName = s.Substring(s.LastIndexOf('/') + 1, s.LastIndexOf('.') - s.LastIndexOf('/') - 1); if (fileName.IndexOf('-') < 0) { continue; } string archIdStr = fileName.Substring(0, fileName.IndexOf('-')); string size = fileName.Substring(fileName.IndexOf('-') + 1); int archId; if (int.TryParse(archIdStr, out archId) && (size.Equals("5") || size.Equals("13"))) { if (size.Equals("5")) { mediumCityImg.Add(archId, Texture2D.FromFile(device, s)); } else { largeCityImg.Add(archId, Texture2D.FromFile(device, s)); } } } this.guandetupian[0] = Texture2D.FromFile(device, "Resources/Architecture/hengguan3.png"); this.guandetupian[1] = Texture2D.FromFile(device, "Resources/Architecture/shuguan3.png"); this.guandetupian[2] = Texture2D.FromFile(device, "Resources/Architecture/shuguan5.png"); this.wanggetupian = Texture2D.FromFile(device, "Resources/TileFrame/wangge.png"); this.EditModeGrid = Texture2D.FromFile(device, "Resources/TileFrame/Blue.png"); this.zidongcundangtupian = Texture2D.FromFile(device, "Resources/Effects/zidongcundang.png"); }
public void Initialize(MainMapLayer mainMapLayer, GameScenario scenario,MainGameScreen mainGameScreen) { this.screen = mainGameScreen; this.mainMapLayer = mainMapLayer; this.Architectures = scenario.Architectures; this.gameScenario = scenario; }
private void Scenario_OnAfterLoadScenario(GameScenario scenario) { this.Textures.LoadTextures(base.spriteBatch.GraphicsDevice, base.Scenario); base.DefaultMouseArrowTexture = this.Textures.MouseArrowTextures[0]; if (this.mainMapLayer.mainMap != null) { this.mainMapLayer.PrepareMap(); this.UpdateViewport(); this.ResetScreenEdge(); this.mainMapLayer.ReCalculateTileDestination(base.spriteBatch.GraphicsDevice); this.JumpTo(this.mainMapLayer.mainMap.JumpPosition); } if (this.Plugins.GameRecordPlugin.IsRecordShowing) { this.Plugins.GameRecordPlugin.AddDisableRects(); } this.Plugins.AirViewPlugin.ResetMapPosition(); this.Plugins.AirViewPlugin.ResetFramePosition(base.viewportSize, this.mainMapLayer.LeftEdge, this.mainMapLayer.TopEdge, this.mainMapLayer.TotalMapSize); if (base.Scenario.ScenarioMap.MapName != null) { this.Plugins.AirViewPlugin.ReloadAirView(base.Scenario.ScenarioMap.MapName + ".jpg"); } else { this.Plugins.AirViewPlugin.ReloadAirView(); } if (this.Plugins.AirViewPlugin.IsMapShowing) { this.Plugins.AirViewPlugin.AddDisableRects(); } }
public bool IsEnd(GameScenario scenario) { Condition cend = scenario.GameCommonData.AllConditions.GetCondition(9999); return this.architectureCond.Contains(cend) || this.factionCond.Contains(cend); }
public static Dictionary<TitleKind, List<Title>> GetKindTitleDictionary(GameScenario scen) { GameObjectList rawTitles = scen.GameCommonData.AllTitles.GetTitleList().GetRandomList(); Dictionary<TitleKind, List<Title>> titles = new Dictionary<TitleKind, List<Title>>(); foreach (Title t in rawTitles) { if (!titles.ContainsKey(t.Kind)) { titles[t.Kind] = new List<Title>(); } titles[t.Kind].Add(t); } return titles; }
public static GameArea GetAreaFromArea(GameArea area, int radius, bool oblique, GameScenario Scenario, Faction faction) { /*int longRadius; if (area.Count <= 1) longRadius = radius; else if (area.Count <= 5) longRadius = radius + 1; else longRadius = radius + 2; GameArea candidateArea = GetArea(area.Centre, longRadius, oblique); if (longRadius >= (radius + 1)) { candidateArea.Area.Remove(new Point(area.Centre.X - longRadius, area.Centre.Y - longRadius)); candidateArea.Area.Remove(new Point(area.Centre.X - longRadius, area.Centre.Y + longRadius)); candidateArea.Area.Remove(new Point(area.Centre.X + longRadius, area.Centre.Y - longRadius)); candidateArea.Area.Remove(new Point(area.Centre.X + longRadius, area.Centre.Y + longRadius)); } if (longRadius >= (radius + 2)) { candidateArea.Area.Remove(new Point(area.Centre.X - longRadius + 1, area.Centre.Y - longRadius)); candidateArea.Area.Remove(new Point(area.Centre.X - longRadius, area.Centre.Y - longRadius + 1)); candidateArea.Area.Remove(new Point(area.Centre.X - longRadius + 1, area.Centre.Y + longRadius)); candidateArea.Area.Remove(new Point(area.Centre.X - longRadius, area.Centre.Y + longRadius - 1)); candidateArea.Area.Remove(new Point(area.Centre.X + longRadius - 1, area.Centre.Y - longRadius)); candidateArea.Area.Remove(new Point(area.Centre.X + longRadius, area.Centre.Y - longRadius + 1)); candidateArea.Area.Remove(new Point(area.Centre.X + longRadius - 1, area.Centre.Y + longRadius)); candidateArea.Area.Remove(new Point(area.Centre.X + longRadius, area.Centre.Y + longRadius - 1)); } return candidateArea;*/ Dictionary<Point, object> closedList = new Dictionary<Point, object>(); GameArea area2 = new GameArea(); foreach (Point point in area.Area) { area2.CombineArea(GetViewArea(point, radius, oblique, Scenario, faction), closedList); } foreach (Point point in closedList.Keys) { area2.Area.Add(point); } return area2; }