public void loadDefaultMapTest() { IMapTile[][] expected = new IMapTile[5][]; expected[0] = new IMapTile[6]; expected[1] = new IMapTile[6]; expected[2] = new IMapTile[6]; expected[3] = new IMapTile[6]; expected[4] = new IMapTile[6]; expected[0][0] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[0][1] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[0][2] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[0][3] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[0][4] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[0][5] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[1][0] = new RoadTile(RoadTile.RoadType.Horizontal); expected[1][1] = new RoadTile(RoadTile.RoadType.Horizontal); expected[1][2] = new RoadTile(RoadTile.RoadType.TopRight); expected[1][3] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[1][4] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[1][5] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[2][0] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[2][1] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[2][2] = new RoadTile(RoadTile.RoadType.Vertical); expected[2][3] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[2][4] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[2][5] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[3][0] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[3][1] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[3][2] = new RoadTile(RoadTile.RoadType.BottomLeft); expected[3][3] = new RoadTile(RoadTile.RoadType.Horizontal); expected[3][4] = new RoadTile(RoadTile.RoadType.Horizontal); expected[3][5] = new RoadTile(RoadTile.RoadType.Horizontal); expected[4][0] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[4][1] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[4][2] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[4][3] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[4][4] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[4][5] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); IMapTile[][] actual = MapLoader.loadDefaultMap(); Assert.IsTrue(actual.Length > 0 && actual[0].Length > 0, "Map has not a valid dimension"); Assert.AreEqual(expected.Length, actual.Length, "Constructed map has a different height"); Assert.AreEqual(expected[0].Length, actual[0].Length, "Constructed map has a different width"); for (int i = actual.Length; i-- > 0; ) { for (int j = actual[0].Length; j-- > 0; ) { int hashA = expected[i][j].GetHashCode(); int hashB = actual[i][j].GetHashCode(); Assert.AreEqual(expected[i][j], actual[i][j], "Constructed map got a different tile at (" + i + "," + j + ")"); } } }
public Game( IMapTile[][] cityMap ) { City = new City(cityMap); _currentDate = Trash2012Begin; Company = new Company(); var newTruck1 = new Truck(TrashType.Paper, 25, 1f); var newTruck2 = new Truck(TrashType.Paper, 25, 1f); Company.Trucks.Add(newTruck1); Company.Trucks.Add(newTruck2); GameRandomness = new Random(); }
public Game( IMapTile[][] cityMap, int initialMoneyAmount ) { City = new City(cityMap); _currentDate = Trash2012Begin; Company = new Company(initialMoneyAmount); var newTruck1 = new Truck(TrashType.Paper, 50, 1f); //var newTruck2 = new Truck(TrashType.Paper, 55, 1f); Company.Trucks.Add(newTruck1); //Company.Trucks.Add(newTruck2); GameRandomness = new Random(); }
public City(IMapTile[][] cityMap, int width, int height) { Map = cityMap; Width = width; Height = height; var plpNum = 0; for (var i = Height; i-- > 0; ) { for (var j = Width; j-- > 0; ) { if (Map[i][j] is IHouseTile) //People is equivalent to a HouseTile plpNum++; } } PeopleNumber = plpNum; }
/// <summary> /// Initializes a new instance of the <see cref="MapTile"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="x">The x.</param> /// <param name="y">The y.</param> private MapTile(IMapTile parent, int x, int y) { _parent = parent; if (parent != null) { _x = 2 * parent.X + x; _y = 2 * parent.Y + y; _zoomLevel = parent.ZoomLevel + 1; } InitializeComponent(); Loaded += (_, __) => { var designUnitSize = this.GetDesignUnitSize(); _subLevelTreshold = (Size)(1.5 * TileSize * (Vector)designUnitSize); Invalidate(); }; }
public Image([NotNull] MapSource owner, [NotNull] IMapTile mapTile) { _owner = owner; _mapTile = mapTile; }
public IImage GetImage(IMapTile tile) { return(_imageCache[tile]); }
private static int GetTileHashCode([NotNull] IMapTile arg) { return(arg.X + 0x1000 * arg.Y + 0x1000000 * arg.ZoomLevel); }
private static bool TileEquals([NotNull] IMapTile left, [NotNull] IMapTile right) { return((left.X == right.X) && (left.Y == right.Y) && (left.ZoomLevel == right.ZoomLevel)); }
public void loadMapFromFileTest() { IMapTile[][] expected = new IMapTile[6][]; expected[0] = new IMapTile[6]; expected[1] = new IMapTile[6]; expected[2] = new IMapTile[6]; expected[3] = new IMapTile[6]; expected[4] = new IMapTile[6]; expected[5] = new IMapTile[6]; expected[0][0] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[0][1] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[0][2] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[0][3] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[0][4] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[0][5] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[1][0] = new RoadTile(RoadTile.RoadType.Horizontal); expected[1][1] = new RoadTile(RoadTile.RoadType.Horizontal); expected[1][2] = new RoadTile(RoadTile.RoadType.TopRight); expected[1][3] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[1][4] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[1][5] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[2][0] = new RoadTile(RoadTile.RoadType.TopLeft); expected[2][1] = new RoadTile(RoadTile.RoadType.Horizontal); expected[2][2] = new RoadTile(RoadTile.RoadType.BottomRight); expected[2][3] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[2][4] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[2][5] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[3][0] = new RoadTile(RoadTile.RoadType.BottomLeft); expected[3][1] = new RoadTile(RoadTile.RoadType.Horizontal); expected[3][2] = new RoadTile(RoadTile.RoadType.Horizontal); expected[3][3] = new RoadTile(RoadTile.RoadType.TopRight); expected[3][4] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[3][5] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[4][0] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[4][1] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[4][2] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[4][3] = new RoadTile(RoadTile.RoadType.Vertical); expected[4][4] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[4][5] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[5][0] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[5][1] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[5][2] = new BackgroundTile(BackgroundTile.BackgroundType.Plain); expected[5][3] = new RoadTile(RoadTile.RoadType.BottomLeft); expected[5][4] = new RoadTile(RoadTile.RoadType.Horizontal); expected[5][5] = new RoadTile(RoadTile.RoadType.Horizontal); string filepath = @"..\..\..\Trash2012\Resources\custom.trash-map"; IMapTile[][] actual = MapLoader.loadMapFromFile(filepath); Assert.IsTrue(actual.Length > 0 && actual[0].Length > 0, "Map has not a valid dimension"); Assert.AreEqual(expected.Length, actual.Length, "Constructed map has a different height"); Assert.AreEqual(expected[0].Length, actual[0].Length, "Constructed map has a different width"); for (int i = actual.Length; i-- > 0;) { for (int j = actual[0].Length; j-- > 0;) { int hashA = expected[i][j].GetHashCode(); int hashB = actual[i][j].GetHashCode(); Assert.AreEqual(expected[i][j], actual[i][j], "Constructed map got a different tile at (" + i + "," + j + ")"); } } }
public abstract IAgent GetBestTargetMob(IMapTile tile);
public City(IMapTile[][] map) : this(map, map[0].Length, map.Length) { }
public void DragDropTile(IMapTile tile, int x, int y) { this.model.Map.IfSome(map => map.DragDropTile(tile, x, y)); }
private static int GetTileHashCode(IMapTile arg) { return arg.X + 0x1000 * arg.Y + 0x1000000 * arg.ZoomLevel; }
private Uri GetImageUri(IMapTile tile) { var pattern = TileUrl[_tileUrlIndex++ % TileUrl.Length]; var str = pattern .Replace("%x", tile.X.ToString(CultureInfo.InvariantCulture)) .Replace("%y", tile.Y.ToString(CultureInfo.InvariantCulture)) .Replace("%z", tile.ZoomLevel.ToString(CultureInfo.InvariantCulture)); return new Uri(str); }
public IImage GetImage(IMapTile tile) { return _imageCache[tile]; }
public Image(MapSource owner, IMapTile mapTile) { _owner = owner; _mapTile = mapTile; }
private static bool TileEquals(IMapTile left, IMapTile right) { return (left.X == right.X) && (left.Y == right.Y) && (left.ZoomLevel == right.ZoomLevel); }
public MapBlockData(uint header, IMapTile[] tiles) { _LandHeader = header; _Lands = new LandMapTile[64]; _Items = new ItemMapTile[64][]; for (int t = 0; t < 64; ++t) { _Lands[t] = tiles[t].Land as LandMapTile; _Items[t] = new ItemMapTile[tiles[t].Count]; for (int i = 0; i < tiles[t].Count; ++i) _Items[t][i] = tiles[t][i] as ItemMapTile; } }
void ChangeTileTo(IMapTile tile) => active = tile;
private void NoTile_Click(object sender, EventArgs e) => active = Pokus1.NoTile.Tile;
public static TruckAnimation FindNextFrom( IMapTile ModelTile, Travel.Extremity from) { if (ModelTile is IRoadTile) { IRoadTile Road = (IRoadTile)ModelTile; switch (Road.Type) { case RoadTile.RoadType.BottomLeft: if (from == Travel.Extremity.Left) { return TruckAnimation.Left2Bottom; } else { return TruckAnimation.Bottom2Left; } case RoadTile.RoadType.BottomRight: if (from == Travel.Extremity.Right) { return TruckAnimation.Right2Bottom; } else { return TruckAnimation.Bottom2Right; } case RoadTile.RoadType.Horizontal: if (from == Travel.Extremity.Right) { return TruckAnimation.Right2Left; } else { return TruckAnimation.Left2Right; } case RoadTile.RoadType.TopLeft: if (from == Travel.Extremity.Top) { return TruckAnimation.Top2Left; } else { return TruckAnimation.Left2Top; } case RoadTile.RoadType.TopRight: if (from == Travel.Extremity.Top) { return TruckAnimation.Top2Right; } else { return TruckAnimation.Right2Top; } case RoadTile.RoadType.Vertical: if (from == Travel.Extremity.Top) { return TruckAnimation.Top2Bottom; } else { return TruckAnimation.Bottom2Top; } case RoadTile.RoadType.TopBottomLeft: if (from == Travel.Extremity.Left) { return TruckAnimation.Left2Bottom; } else if (from == Travel.Extremity.Top) { return TruckAnimation.Top2Bottom; } else { return TruckAnimation.Bottom2Top; } case RoadTile.RoadType.TopBottomRight: if (from == Travel.Extremity.Right) { return TruckAnimation.Right2Bottom; } else if (from == Travel.Extremity.Top) { return TruckAnimation.Top2Bottom; } else { return TruckAnimation.Bottom2Top; } case RoadTile.RoadType.TopBottomLeftRight: if (from == Travel.Extremity.Left) { return TruckAnimation.Left2Right; } else if (from == Travel.Extremity.Right) { return TruckAnimation.Right2Left; } else if (from == Travel.Extremity.Top) { return TruckAnimation.Top2Bottom; } else { return TruckAnimation.Bottom2Top; } default: return TruckAnimation.Missing; } } else { throw new ArgumentException("Can't animate the truck somewhere else than on a road"); } }