private static void ReviewPotentiallyOccupiedTiles(ref Tile[,] tiles, ICollection<TileException> exceptions) { var cy = tiles.GetLength(1); var cx = tiles.GetLength(0); for (int y = 0; y < cy; y++) { for (int x = 0; x < cx; x++) { Tile t = tiles[x, y]; try { t.CheckIfIncorrectlyPotentiallyOccupied(); } catch (TileException te) { var nte = new TileException(te, string.Format("Tile at {0},{1}", x, y)); exceptions.Add(nte); } } } }
private static IEnumerable<TileException> SetTileOccupation(ref Tile[,] tiles, IEnumerable<StaticItem> gameObjects, bool isMoving) { Action<Tile> action; if (isMoving) action = t => t.SetOccupationByMovingMonster(); else action = t => t.SetOccupationByStaticItem(); var result = new List<TileException>(); foreach (var item in gameObjects) { TilePos tp = item.TilePosition; try { action(tiles[tp.X, tp.Y]); } catch (TileException te) { var nte = new TileException(te, string.Format("{0} at tile {1},{2} for {3} occupation", item.GetType().Name, tp.X, tp.Y, isMoving ? "moving" : "static")); result.Add(nte); } } return result; }
public TileException(TileException te, string message) : base(string.Format("{0}: {1}", message, te.Message)) { this.Type = te.Type; }