public Map(int width, int height, bool blockBorder, TileSpeed initialSpeed = TileSpeed.Normal, TileHeight initialHeight = TileHeight.Medium) { // Check Parameter if (width < MIN_WIDTH) { throw new ArgumentOutOfRangeException(string.Format("Map must have at least {0} Columns", MIN_WIDTH)); } if (width > MAX_WIDTH) { throw new ArgumentOutOfRangeException(string.Format("Map must have a max of {0} Columns", MAX_WIDTH)); } if (height < MIN_HEIGHT) { throw new ArgumentOutOfRangeException(string.Format("Map must have at least {0} Rows", MIN_HEIGHT)); } if (height > MAX_HEIGHT) { throw new ArgumentOutOfRangeException(string.Format("Map must have a max of {0} Rows", MAX_HEIGHT)); } BlockBorder = blockBorder; // Create Tiles Tiles = new MapTile[width, height]; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { Tiles[x, y] = new MapTile { Height = initialHeight, Shape = TileShape.Flat, Speed = initialSpeed }; } } // Create Players int dx = width / 6; int dy = height / 6; StartPoints = new Index2[8]; StartPoints[0] = new Index2(dx, dy); StartPoints[1] = new Index2(5 * dx, 5 * dy); StartPoints[2] = new Index2(5 * dx, dy); StartPoints[3] = new Index2(dx, 5 * dy); StartPoints[4] = new Index2(3 * dx, dy); StartPoints[5] = new Index2(3 * dx, 5 * dy); StartPoints[6] = new Index2(dx, 3 * dy); StartPoints[7] = new Index2(5 * dx, 3 * dy); }
private void InitFlat(bool blockBorder, TileSpeed speed) { Map = Map.CreateMap(MapPreset.Small, true); Index2 cells = Map.GetCellCount(); for (int x = 0; x < cells.X; x++) { for (int y = 0; y < cells.Y; y++) { Map.Tiles[x, y].Speed = speed; } } Engine.Init(Map); Engine.InsertItem(Item); }
/// <summary> /// Ermittelt den Geschwindigkeitsmultiplikator zum angegebenen Parameter. /// </summary> /// <param name="speed">Geschwindigkeit</param> /// <returns>Speedmultiplikator</returns> public static float GetSpeedMultiplicator(TileSpeed speed) { switch (speed) { case TileSpeed.Stop: return(SPEED_STOP); case TileSpeed.Slowest: return(SPEED_SLOWEST); case TileSpeed.Slower: return(SPEED_SLOWER); case TileSpeed.Normal: return(SPEED_NORMAL); case TileSpeed.Faster: return(SPEED_FASTER); default: throw new NotSupportedException("Unknown TileSpeed Type"); } }
private void InitFlat(bool blockBorder, TileSpeed speed) { Map = Map.CreateMap(MapPreset.Small, true); Index2 size = Map.GetCellCount(); for (int y = 0; y < size.Y; y++) for (int x = 0; x < size.X; x++) Map.Tiles[x, y].Speed = speed; Engine.Init(Map); Engine.InsertItem(Item); }
/// <summary> /// Ermittelt den Geschwindigkeitsmultiplikator zum angegebenen Parameter. /// </summary> /// <param name="speed">Geschwindigkeit</param> /// <returns>Speedmultiplikator</returns> public static float GetSpeedMultiplicator(TileSpeed speed) { switch (speed) { case TileSpeed.Stop: return SPEED_STOP; case TileSpeed.Slowest: return SPEED_SLOWEST; case TileSpeed.Slower: return SPEED_SLOWER; case TileSpeed.Normal: return SPEED_NORMAL; case TileSpeed.Faster: return SPEED_FASTER; default: throw new NotSupportedException("Unknown TileSpeed Type"); } }