public int SetCell(FightCell Cell) { if (this.myCell != null) { this.myCell.RemoveObject(this); // On vire le fighter de la cell: } this.myCell = Cell; if (this.myCell != null) { var AddResult = this.myCell.AddObject(this); if (AddResult == -3 || AddResult == -2) { return(AddResult); } var BuffResult = this.Buffs.EndMove(); if (BuffResult == -3 || BuffResult == -2) { return(BuffResult); } } return(this.TryDie(this.ActorId)); }
public static Couple <List <FightCell>, List <FightCell> > GenRandomFightPlaces(Fight fight) { List <FightCell> team1 = new List <FightCell>(); List <FightCell> team2 = new List <FightCell>(); /* * BaseCells */ Couple <int, int> baseCells = GetRandomBaseCellPlaces(fight.Map); team1.Add(fight.GetCell(baseCells.first)); team2.Add(fight.GetCell(baseCells.second)); /* * Remplissage */ int boucles = 0; while (team1.Count < 8) { if (boucles > 500) { break; } if (boucles > 25) { int randomCellId = fight.Map.getRandomCell(); FightCell cell = fight.GetCell(randomCellId); if (cell != null && cell.IsWalkable()) { if (!team1.Contains(cell)) { team1.Add(cell); } } boucles++; continue; } boucles++; FightCell toDir = team1[Random(0, team1.Count - 1)]; if (toDir == null) { continue; } FightCell randomCell = fight.GetCell(Pathfinder.DirToCellID(toDir.Id, RandomDirection(), fight.Map, false)); if (randomCell != null) { if (!team1.Contains(randomCell) && randomCell.IsWalkable()) { team1.Add(randomCell); } } } boucles = 0; while (team2.Count < 8) { if (boucles > 500) { break; } if (boucles > 25) { int randomCellId = fight.Map.getRandomCell(); FightCell cell = fight.GetCell(randomCellId); if (cell != null && cell.IsWalkable()) { if (!team1.Contains(cell) && !team2.Contains(cell)) { team2.Add(cell); } } boucles++; continue; } boucles++; FightCell toDir = team2[Random(0, team2.Count - 1)]; if (toDir == null) { continue; } FightCell randomCell = fight.GetCell(Pathfinder.DirToCellID(toDir.Id, RandomDirection(), fight.Map, false)); if (randomCell != null) { if (!team1.Contains(randomCell) && !team2.Contains(randomCell) && randomCell.IsWalkable()) { team2.Add(randomCell); } } } return(new Couple <List <FightCell>, List <FightCell> >(team1, team2)); }