public TileMap(string name, int w, int h, string[] objects, int initialHeight) { Tag = "#map"; Name = name; int[,] map = NoiseMap.GetNotSmoothedNoise(w, h, initialHeight + 1); map = map.MeanBlur(5); map = map.ChangeVariance(objects.Length - 1); array = new DirectionalCollisionObject[h, w]; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { array[y, x] = new DirectionalCollisionObject($"#|{map[y,x]}|WALLtile@{y}-{x}", new Position(x * TileSize, y * TileSize), objects[map[y, x]]); array[y, x].AutoFitCollider = true; array[y, x].WrapInCollider(true); } } }
public override void Update(TimeSpan dt) { for (int y = 0; y < array.GetLength(0); y++) { for (int x = 0; x < array.GetLength(1); x++) { var cur = array[y, x]; if (!cur.Enabled) { DirectionalCollisionObject d = new DirectionalCollisionObject($"DeadTile", new Position(x * TileSize, y * TileSize), @"C\Tiles\empty"); d.Tag = "empty"; array[y, x] = d; } if (Scale != 1) { cur.Position = new Position((int)(x * TileSize * Scale), (int)(y * TileSize * Scale)); cur.Scale = Scale; } } } }