void RecrerArme() { SoldatDeArmée[,] temp = new SoldatDeArmée[Positions.GetLength(0), Positions.GetLength(1)]; int soldatsAjoute = 0; int tempI = 0; int tempJ = 0; for (int i = 0; i < Armés.GetLength(0); i++) { for (int j = 0; j < Armés.GetLength(1); j++) { if (soldatsAjoute < NbVivants) { if (Armés[i, j] != null && Armés[i, j].EstVivant) { temp[tempI, tempJ] = Armés[i, j]; tempJ++; if (tempJ == Positions.GetLength(1)) { tempJ = 0; tempI++; } soldatsAjoute++; } } } } Armés = temp; }
void ToutDetruire() { for (int i = 0; i < Armés.GetLength(0); i++) { for (int j = 0; j < Armés.GetLength(1); j++) { Game.Components.Remove(Armés[i, j]); } } Armés = new SoldatDeArmée[(int)Math.Ceiling(Math.Sqrt(NombreSoldat)), (int)Math.Ceiling(Math.Sqrt(NombreSoldat))]; NbVivants = NombreSoldat; }
private bool EstDansLimiteTerrain(SoldatDeArmée soldatDeArmée) { bool estDansLimite = false; Vector3 limite = TerrainDeBase.TAILLE_HITBOX_STANDARD * 10; if (soldatDeArmée.VarPosition.Y < 25 && soldatDeArmée.VarPosition.Y > -7) { if (Math.Abs(-soldatDeArmée.Position.X) < 10) { estDansLimite = true; } } return(estDansLimite); }
void CréerSoldats() { int nbSoldatsCreés = 0; for (int i = 0; i < Positions.GetLength(0); i++) { for (int j = 0; j < Positions.GetLength(1); j++) { if (nbSoldatsCreés < NombreSoldat) { Armés[i, j] = new SoldatDeArmée(Game, 0.5F, Vector3.Zero, PosFlag + Positions[i, j], new Vector2(2, 3), "Soldat", string.Empty, new Vector2(20, 1), new Vector2(20, 1), 1f / 60, ObjetCollisionné, ListeSections); Game.Components.Add(Armés[i, j]); nbSoldatsCreés++; } } } }
public Armée(Game game, int nombreSoldats, Vector3 posFlag, float intervalleMAJ, List <PrimitiveDeBase>[] objetCollisionné, List <SectionDeNiveau> listeSections) : base(game) { EstFormationLigne = false; EstFormationStandard = true; ListeSections = listeSections; IntervalleMAJ = intervalleMAJ; NombreSoldat = nombreSoldats; NbVivants = NombreSoldat; PosFlag = posFlag; PosFlagInitial = PosFlag; CalculerFormation(); Armés = new SoldatDeArmée[Positions.GetLength(0), Positions.GetLength(1)]; test = true; Caméra = Game.Services.GetService(typeof(Caméra)) as CaméraAutomate; ObjetCollisionné = objetCollisionné; TempsEcouleVerification = 0; }