private static void CreateCharacter(IGameDungeon dungeon) { var character = new Character(); var upstairs = dungeon.Single(c => c.Type == XType.StairsUp); character.Location = upstairs.Location; dungeon.Character = character; }
public void Fill(IGameDungeon dungeon) { ////TODO create all the stuff and place into dungeon CreateStairs(dungeon); CreateCharacter(dungeon); }
private static void CreateStairs(IGameDungeon dungeon) { var emptyCells = dungeon.Where(cell => cell.Type == XType.Empty).ToList(); var count = emptyCells.Count; var upstairsPosition = StaticRandom.Next(emptyCells.Count); var downstairsPosition = StaticRandom.NextNotEqualToOld( 0, emptyCells.Count, upstairsPosition); var upstairsCell = emptyCells[upstairsPosition]; var downstairsCell = emptyCells[downstairsPosition]; dungeon[upstairsCell].Type = XType.StairsUp; dungeon[downstairsCell].Type = XType.StairsDown; }
private static MapImage GetMapPicture(IGameDungeon dungeon) { var image = new MapImage(dungeon.Width, dungeon.Height); for (int x = 0; x < dungeon.Width; x++) for (int y = 0; y < dungeon.Height; y++) { var cell = dungeon[x, y]; image.SetTile(cell.Location, cell.Type); } image.SetTile(dungeon.Character.Location, dungeon.Character.Type); return image; }