private void SpawnSquad() { if (Map.ListPlayer.Count > SpawnPlayer) { //Don't spawn the unit if there's already on with this ID. for (int U = 0; U < Map.ListPlayer[SpawnPlayer].ListSquad.Count; U++) { if (Map.ListPlayer[SpawnPlayer].ListSquad[U].ID == LeaderToSpawnID) { return; } } } if (LeaderToSpawn != null) { int SpawnPositionX = SpawnPosition.X; int SpawnPositionY = SpawnPosition.Y; Microsoft.Xna.Framework.Vector3 FinalPosition; if (SpawnPositionX >= Map.MapSize.X || SpawnPositionX < 0 || SpawnPositionY >= Map.MapSize.Y || SpawnPositionY >= Map.MapSize.Y) { FinalPosition = new Microsoft.Xna.Framework.Vector3(SpawnPositionX, SpawnPositionY, 0); } else { Map.GetEmptyPosition(new Microsoft.Xna.Framework.Vector3(SpawnPositionX, SpawnPositionY, 0), out FinalPosition); } LeaderToSpawn.Init(); if (WingmanAToSpawn != null) { WingmanAToSpawn.Init(); } if (WingmanBToSpawn != null) { WingmanBToSpawn.Init(); } Squad NewSquad = new Squad("", LeaderToSpawn.SpawnUnit, WingmanAToSpawn == null ? null : WingmanAToSpawn.SpawnUnit, WingmanBToSpawn == null ? null : WingmanBToSpawn.SpawnUnit); NewSquad.IsEventSquad = IsEventSquad; NewSquad.IsPlayerControlled = IsPlayerControlled; NewSquad.SquadDefenseBattleBehavior = DefenseBattleBehavior; if (!string.IsNullOrEmpty(AIPath)) { NewSquad.SquadAI = new DeathmatchScripAIContainer(new DeathmatchAIInfo(Map, NewSquad)); NewSquad.SquadAI.Load(AIPath); } Map.SpawnSquad(SpawnPlayer, NewSquad, LeaderToSpawnID, FinalPosition, SpawnLayer); if (!string.IsNullOrEmpty(PartDropPath)) { NewSquad.ListParthDrop.Add(PartDropPath); } } }
private void SpawnSquad() { if (Map.ListPlayer.Count > SpawnPlayer) { //Don't spawn the unit if there's already on with this ID. for (int U = 0; U < Map.ListPlayer[SpawnPlayer].ListSquad.Count; U++) { if (Map.ListPlayer[SpawnPlayer].ListSquad[U].ID == LeaderToSpawnID) { return; } } } if (LeaderToSpawn != null) { int SpawnPositionX = SpawnPosition.X; int SpawnPositionY = SpawnPosition.Y; Microsoft.Xna.Framework.Vector3 FinalPosition; if (SpawnPositionX >= Map.MapSize.X || SpawnPositionX < 0 || SpawnPositionY >= Map.MapSize.Y || SpawnPositionY >= Map.MapSize.Y) { FinalPosition = new Microsoft.Xna.Framework.Vector3(SpawnPositionX, SpawnPositionY, 0); } else { Map.GetEmptyPosition(new Microsoft.Xna.Framework.Vector3(SpawnPositionX, SpawnPositionY, 0), out FinalPosition); } LeaderToSpawn.Init(); if (WingmanAToSpawn != null) { WingmanAToSpawn.Init(); } if (WingmanBToSpawn != null) { WingmanBToSpawn.Init(); } Squad NewSquad = new Squad("", LeaderToSpawn.SpawnUnit, WingmanAToSpawn == null ? null : WingmanAToSpawn.SpawnUnit, WingmanBToSpawn == null ? null : WingmanBToSpawn.SpawnUnit); NewSquad.IsEventSquad = IsEventSquad; NewSquad.IsPlayerControlled = IsPlayerControlled; NewSquad.SquadDefenseBattleBehavior = DefenseBattleBehavior; if (!string.IsNullOrEmpty(AIPath)) { NewSquad.SquadAI = new DeathmatchScripAIContainer(new DeathmatchAIInfo(Map, NewSquad)); NewSquad.SquadAI.Load(AIPath); } Map.SpawnSquad(SpawnPlayer, NewSquad, LeaderToSpawnID, FinalPosition); if (!string.IsNullOrEmpty(PartDropPath)) { string[] PartByType = PartDropPath.Split('/'); if (PartByType[0] == "Standard Parts") { SystemList.ListPart.Add(PartDropPath, new UnitStandardPart("Content/Units/" + PartDropPath + ".pep", Map.DicRequirement, Map.DicEffect)); } else if (PartByType[0] == "Consumable Parts") { SystemList.ListPart.Add(PartDropPath, new UnitConsumablePart("Content/Units/" + PartDropPath + ".pep", Map.DicRequirement, Map.DicEffect)); } } } }