//public static void RemoveItemFromBoard(IPositionable item, Board board) //{ // board.FloorsPos.Add(item.Position); // board.PositionableObjects.Remove((Item)item); //} /// <summary> /// Main game logic goes here ? Am I doing this right ? :D WE NEED AN ENGINE ! /// </summary> public void Start() { //bool isDead = false; BoardFactory factory = new BoardFactory(new Position(0 + 10, 0 + 2), new Position(80 - 1, 25 - 1)); Board board = factory.GenerateBoard(); int boardLevel = 0; int boardLevelChange = 0; var playedBoards = new List <Board>(); var hero = Wizard.Instance; hero.Name = "Nathan Rahl"; hero.Health.Current = 50; hero.Mana.Current = 70; while (hero.IsAlive) { MonsterFactory mFactory = new MonsterFactory(boardLevel); mFactory.SpawnMonstersOnBoard(board); if (boardLevelChange >= 0) { hero.Position = new Position(board.EntryStairPos.X, board.EntryStairPos.Y); } else { hero.Position = new Position(board.ExitStairPos.X, board.ExitStairPos.Y); } ConsoleRenderer.RenderPlayingScreen(hero, board, boardLevel); boardLevelChange = PlayBoard(board, playedBoards, hero, boardLevel, mFactory.MonsterList); foreach (var monster in mFactory.MonsterList) { board.PositionableObjects.Remove(monster); } boardLevel += boardLevelChange; if (boardLevel == playedBoards.Count) { board = factory.GenerateBoard(); } else { board = playedBoards[boardLevel]; } } //Initialise charaters and items on console! // Just testing an array of items ... //var items = new List<Item>(); //items.Add(new HealthPotion(new Position(20, 20))); //items.Add(new ManaPotion(new Position(25, 23))); //items.Add(new Gold(new Position(30, 15), 91)); //items.Add(new Gold(new Position(33, 10), 200)); //items.Add(new Gold(new Position(40, 11), 150)); //items.Add(new Trinket("Ring", new Position(2,4), 200)); //items.Add(new Trinket("Horseshoe", new Position(2, 12), 500)); //items.Add(new Trinket("Crystal", new Position(50, 20), 200)); //items.Add(new Trinket("Pendant", new Position(40, 5), 200)); //items.Add(new Trinket("Charm", new Position(10, 20), 200)); //items.Add(new RogueArmor(new Position(20, 21), 2)); //items.Add(new WizardArmor(new Position(30, 13), 2)); //items.Add(new RogueWeapon(new Position(50, 21), 2)); //items.Add(new RogueWeapon(new Position(50, 22), 3)); //items.Add(new RogueWeapon(new Position(50, 23), 4)); //items.Add(new WizardWeapon(new Position(20, 22), 2)); //items.Add(new HealthPotion("small potion", 10, 0, new Point2D(20, 20), '♥', 100)); //foreach (var item in board.Items) //{ // ConsoleRenderer.RenderItem(item); //} //test the potion // var testX = potion.Position.X; }
public static void Start() { Console.CursorVisible = false; Console.SetWindowSize(130, 50); Console.SetBufferSize(130, 50); BoardFactory factory = new BoardFactory(new Position(0 + 10, 0 + 2), new Position(80 - 1, 25 - 1)); while (true) { Console.BackgroundColor = outsideColour; Console.Clear(); Board board = factory.GenerateBoard(); Console.CursorVisible = false; Console.OutputEncoding = System.Text.Encoding.Unicode; Console.Title = "░░░░ ROGUECLONE ░░░░"; //foreach (var wall in board.HorizontalWallsPos) //{ // Console.SetCursorPosition(wall.X, wall.Y); // Console.Write(' '); //} //foreach (var wall in board.VerticalWallsPos) //{ // Console.CursorTop = wall.Y; // Console.CursorLeft = wall.X; // Console.Write(' '); //} //foreach (var corner in board.CornersPos) //{ // Console.CursorTop = corner.Y; // Console.CursorLeft = corner.X; // Console.Write(' '); //} Console.BackgroundColor = GlobalConstants.RoomColor.ToConsoleColor(); var commonWalkableDungeon = board.FloorsPos.Concat(board.CorridorsPos).ToArray(); for (int i = 0; i < commonWalkableDungeon.Length; i++) { Console.SetCursorPosition(commonWalkableDungeon[i].X, commonWalkableDungeon[i].Y); Console.Write(' '); } //foreach (var door in board.DoorsPos) //{ // Console.CursorTop = door.Y; // Console.CursorLeft = door.X; // Console.Write(' '); //} //foreach (var floor in board.FloorsPos) //{ // Console.CursorTop = floor.Y; // Console.CursorLeft = floor.X; // Console.Write(' '); //} //foreach (var corridor in board.CorridorsPos) //{ // Console.CursorTop = corridor.Y; // Console.CursorLeft = corridor.X; // Console.Write(' '); //} Console.ForegroundColor = Color.Magenta.ToConsoleColor(); // constant? foreach (var item in board.PositionableObjects) ///////////////////////// fix remnant of an item at (0,0) { Console.CursorTop = item.Position.Y; Console.CursorLeft = item.Position.X; Console.Write('?'); } Console.ForegroundColor = Color.Green.ToConsoleColor(); // constant? foreach (var pile in board.GoldPositionsPos) { Console.CursorTop = pile.Y; Console.CursorLeft = pile.X; Console.Write('$'); } Console.BackgroundColor = Color.Black.ToConsoleColor(); Console.ForegroundColor = Color.Red.ToConsoleColor(); // constant? Console.SetCursorPosition(board.EntryStairPos.X, board.EntryStairPos.Y); Console.Write('≡'); Console.ForegroundColor = Color.Green.ToConsoleColor(); Console.SetCursorPosition(board.ExitStairPos.X, board.ExitStairPos.Y); Console.Write('≡'); Console.BackgroundColor = GlobalConstants.RoomColor.ToConsoleColor(); Console.ForegroundColor = Color.Yellow.ToConsoleColor(); // constant? Console.SetCursorPosition(board.ShopKeeperPos.X, board.ShopKeeperPos.Y); Console.Write('%'); Console.ReadKey(); } }