public static int NumberOfNeighborsTo(this IEnumerable<Tile> tiles, Tile other) { return tiles.Count(tile => tile | other); }
public void SetTile(Tile tile) { throw new NotImplementedException(); }
/// <summary> /// Visszaad egy felsorolást azokból a "tiles"-ban szereplő mezőkből, melyek szomszédosak az "other" mezővel. /// </summary> /// <param name="tiles">Mezők kollekciója.</param> /// <param name="other">A vizsgált mező.</param> /// <returns></returns> public static IEnumerable<Tile> GetNeighboringTiles(this ICollection<Tile> tiles, Tile other) { return from Tile tile in tiles where tile | other select tile; }
/// <summary> /// Kiértékeli, hogy a kapott mező emellé rakható-e. /// </summary> /// <param name="other">A másik játékmező.</param> /// <returns>A másik játékmező lerkaható-e emellé.</returns> public bool IsValidAdjacent(Tile other) { return this | other && IsSideTypeCompatible(other); }
/// <summary> /// Kiértékeli, hogy a másik mező ezzel szemben lévő oldalán a terület típusok egyeznek. /// </summary> /// <param name="other">A másik játékmező.</param> /// <returns>Terület típusok szerint lerakható-e a mező emellé.</returns> private bool IsSideTypeCompatible(Tile other) { foreach (Direction facingMinorDirection in DirectionTo(other).MinorDirections()) if (this[facingMinorDirection].AreaType != other[facingMinorDirection.Opposite()].AreaType) return false; return true; }
private Tile ReadTestIndexerData(DataRow row) { var subAreas = ReadSubAreas(row[string.Format(areaDescriptionKeyTemplate, "")].ToString().Split(';')); Tile t = new Tile(subAreas, new Position(0, 0)); t.Rotation = ReadEnum<TileRotation>(row, "Rotation"); return t; }
private Tile ReadTestRotateData(DataRow row) { TileRotation rotation = ReadEnum<TileRotation>(row, "Rotation"); Tile t = new Tile(); t.Rotation = rotation; return t; }