private string CreateTextInputPopup(string title, string prompt)
        {
            var area = new ConsoleArea(70, 3);

            area.SetBorderStyle(ConsoleArea.BorderStyle.Single);
            area.SetBorderBackground(ConsoleColor.Black);
            area.SetBorderForeground(ConsoleColor.White);
            area.SetDefaultBackground(ConsoleColor.Black);
            area.SetDefaultForeground(ConsoleColor.White);
            area.SetTitle(title);

            area.Write(prompt, 1, 0);
            area.SetOffset(0, 0);

            var xPos = (short)(_console2.Width / 2 - (area.Width / 2));
            var yPos = (short)(_console2.Height / 2 - (area.Height / 2));

            _console2.DrawArea(area, xPos, yPos);

            Console.SetCursorPosition(xPos + prompt.Length + 3, yPos + 1);
            Console.CursorVisible = true;
            var result = Console.ReadLine();

            Console.CursorVisible = false;

            return(result);
        }
        private ConsoleArea CreateDebugArea()
        {
            var area = new ConsoleArea(100 + 20, 1);

            area.SetDefaultBackground(ConsoleColor.Black);
            area.SetDefaultForeground(ConsoleColor.White);
            return(area);
        }
 private void FillArea(Map map, ConsoleArea area, IEnumerable <Position> positions)
 {
     foreach (var position in positions)
     {
         var tile = GetTile(map.GetPositionValue(position));
         area.Write(tile.Character, position.X, position.Y, tile.ForeColor, tile.BackColor);
     }
 }
 private void DrawEntity(Item item, ConsoleArea area)
 {
     if (item.Type == "monster")
     {
         area.Write(item.Name[0], item.XPos, item.YPos, ConsoleColor.Red);
     }
     else if (item.Type == "character")
     {
         DrawPlayer(item.Id, item.XPos, item.YPos, area);
     }
 }
        private void UpdateMessageArea(ConsoleArea messageArea)
        {
            messageArea.Clear();
            var messages = _context.Messages.Take(5).Select((m, i) => new { Text = m, Index = i });

            foreach (var message in messages)
            {
                messageArea.Write(message.Text, 0, message.Index);
            }
            messageArea.SetOffset(0, 0);
        }
		private ConsoleArea CreateMapArea(Map map)
		{
			var area = new ConsoleArea(60+10, 30+3);
			area.SetBorderStyle(ConsoleArea.BorderStyle.Double);
			area.SetBorderBackground(ConsoleColor.Black);
			area.SetBorderForeground(ConsoleColor.White);
			area.SetTitle(map.Name);

			FillArea(map, area, map.AllPositions);

			return area;
		}
        private ConsoleArea CreatePlayerArea(Character player)
        {
            var area = new ConsoleArea(40 + 10, 30 + 3);

            area.SetBorderStyle(ConsoleArea.BorderStyle.Single);
            area.SetBorderBackground(ConsoleColor.DarkRed);
            area.SetBorderForeground(ConsoleColor.Red);
            area.SetDefaultBackground(ConsoleColor.Black);
            area.SetDefaultForeground(ConsoleColor.Green);
            area.SetTitle(player.Name);

            var row = 0;

            area.Write(string.Format("STR: {0}", player.Strength), 1, ++row);
            area.Write(string.Format("DEX: {0}", player.Dexterity), 1, ++row);
            area.Write(string.Format("CON: {0}", player.Constitution), 1, ++row);
            area.Write(string.Format("INT: {0}", player.Intelligence), 1, ++row);
            area.Write(string.Format("WIS: {0}", player.Wisdom), 1, ++row);

            row++;
            area.Write(string.Format("XP: {0}", player.Experience), 1, ++row);
            area.Write(string.Format("Lvl: {0}", player.Level), 1, ++row);


            var hpCol = ConsoleColor.Green;

            if (player.HitPoints < player.MaxHitPoints)
            {
                hpCol = player.HitPoints < player.MaxHitPoints / 2 ? ConsoleColor.Red : ConsoleColor.Yellow;
            }

            row++;
            area.Write(string.Format("HP: {0}/{1}", player.HitPoints, player.MaxHitPoints), 1, ++row, hpCol);
            area.Write(string.Format("AC: {0}", player.ArmorClass), 1, ++row);
            area.Write("Weapon: " + player.WieldedWeaponName, 1, ++row);
            area.Write("Armor: " + player.EquippedArmorName, 1, ++row);
            area.Write("Light: " + player.Light, 1, ++row);
            area.Write("Speed: " + player.Speed, 1, ++row);
            area.Write("Avail. pts: " + player.PointsToAllocate, 1, ++row);

            row++;
            area.Write("Inventory", 1, ++row);
            area.Write("=========", 1, ++row);

            for (int i = 0; i < player.Inventory.Length; i++)
            {
                area.Write(string.Format("{0}: {1}", i, _context.GetInfoFor(player.Inventory[i]).Name), 1, ++row);
            }

            area.SetOffset(0, 0);

            return(area);
        }
        private ConsoleArea CreateMessageArea()
        {
            var area = new ConsoleArea(100 + 20, 5 + 2);

            area.SetBorderStyle(ConsoleArea.BorderStyle.Single);
            area.SetBorderBackground(ConsoleColor.DarkYellow);
            area.SetBorderForeground(ConsoleColor.Yellow);
            area.SetDefaultBackground(ConsoleColor.DarkYellow);
            area.SetDefaultForeground(ConsoleColor.White);
            area.SetTitle(" Messages ");
            return(area);
        }
        private ConsoleArea CreateMapArea(Map map)
        {
            var area = new ConsoleArea(60 + 10, 30 + 3);

            area.SetBorderStyle(ConsoleArea.BorderStyle.Double);
            area.SetBorderBackground(ConsoleColor.Black);
            area.SetBorderForeground(ConsoleColor.White);
            area.SetTitle(map.Name);

            FillArea(map, area, map.AllPositions);

            return(area);
        }
		private ConsoleArea CreatePlayerArea(Character player)
		{
			var area = new ConsoleArea(40+10, 30+3);
			area.SetBorderStyle(ConsoleArea.BorderStyle.Single);
			area.SetBorderBackground(ConsoleColor.DarkRed);
			area.SetBorderForeground(ConsoleColor.Red);
			area.SetDefaultBackground(ConsoleColor.Black);
			area.SetDefaultForeground(ConsoleColor.Green);
			area.SetTitle(player.Name);

			var row = 0;

			area.Write(string.Format("STR: {0}", player.Strength), 1, ++row);
			area.Write(string.Format("DEX: {0}", player.Dexterity), 1, ++row);
			area.Write(string.Format("CON: {0}", player.Constitution), 1, ++row);
			area.Write(string.Format("INT: {0}", player.Intelligence), 1, ++row);
			area.Write(string.Format("WIS: {0}", player.Wisdom), 1, ++row);

			row++;
			area.Write(string.Format("XP: {0}", player.Experience), 1, ++row);
			area.Write(string.Format("Lvl: {0}", player.Level), 1, ++row);


			var hpCol = ConsoleColor.Green;
			if (player.HitPoints < player.MaxHitPoints)
			{
				hpCol = player.HitPoints < player.MaxHitPoints / 2 ? ConsoleColor.Red : ConsoleColor.Yellow;
			}

			row++;
			area.Write(string.Format("HP: {0}/{1}", player.HitPoints, player.MaxHitPoints), 1, ++row, hpCol);
			area.Write(string.Format("AC: {0}", player.ArmorClass), 1, ++row);
			area.Write("Weapon: " + player.WieldedWeaponName, 1, ++row);
			area.Write("Armor: " + player.EquippedArmorName, 1, ++row);
			area.Write("Light: " + player.Light, 1, ++row);
			area.Write("Speed: " + player.Speed, 1, ++row);
			area.Write("Avail. pts: " + player.PointsToAllocate, 1, ++row);

			row++;
			area.Write("Inventory", 1, ++row);
			area.Write("=========", 1, ++row);

			for (int i = 0; i < player.Inventory.Length; i++)
			{
				area.Write(string.Format("{0}: {1}", i, _context.GetInfoFor(player.Inventory[i]).Name), 1, ++row);
			}

			area.SetOffset(0, 0);

			return area;
		}
        private ConsoleKeyInfo CreateMessagePopup(string title, string[] messages)
        {
            var max  = Math.Max(messages.Max(x => x.Length), title.Length);
            var area = new ConsoleArea((short)(max + 4), (short)(messages.Count() + 2));

            area.SetBorderStyle(ConsoleArea.BorderStyle.Single);
            area.SetBorderBackground(ConsoleColor.DarkBlue);
            area.SetBorderForeground(ConsoleColor.Cyan);
            area.SetDefaultBackground(ConsoleColor.DarkBlue);
            area.SetDefaultForeground(ConsoleColor.Cyan);
            area.SetTitle(title);

            for (int i = 0; i < messages.Length; i++)
            {
                area.Write(messages[i], 2, i + 1);
            }

            _console2.DrawArea(area,
                               (short)(_console2.Width / 2 - (area.Width / 2)),
                               (short)(_console2.Height / 2 - (area.Height / 2)));

            return(Console.ReadKey(true));
        }
		private void DrawEntity(Item item, ConsoleArea area)
		{
			if (item.Type == "monster")
			{
				area.Write(item.Name[0], item.XPos, item.YPos, ConsoleColor.Red);
			}
			else if (item.Type == "character")
			{
				DrawPlayer(item.Id, item.XPos, item.YPos, area);
			}
		}
		private ConsoleKeyInfo CreateMessagePopup(string title, string[] messages)
		{
			var max = Math.Max(messages.Max(x => x.Length), title.Length);
			var area = new ConsoleArea((short) (max + 4), (short) (messages.Count() + 2));
			area.SetBorderStyle(ConsoleArea.BorderStyle.Single);
			area.SetBorderBackground(ConsoleColor.DarkBlue);
			area.SetBorderForeground(ConsoleColor.Cyan);
			area.SetDefaultBackground(ConsoleColor.DarkBlue);
			area.SetDefaultForeground(ConsoleColor.Cyan);
			area.SetTitle(title);

			for (int i = 0; i < messages.Length; i++)
			{
				area.Write(messages[i], 2, i + 1);
			}

			_console2.DrawArea(area, 
				(short) (_console2.Width / 2 - (area.Width / 2)),
				(short) (_console2.Height / 2 - (area.Height / 2)));

			return Console.ReadKey(true);
		}
 private void UpdateDebugArea(ConsoleArea debugArea, Character player, Map map)
 {
     debugArea.Clear();
     debugArea.Write(GetDebugInfo(player, map), 0, 0);
 }
		private string CreateTextInputPopup(string title, string prompt)
		{
			var area = new ConsoleArea(70, 3);
			area.SetBorderStyle(ConsoleArea.BorderStyle.Single);
			area.SetBorderBackground(ConsoleColor.Black);
			area.SetBorderForeground(ConsoleColor.White);
			area.SetDefaultBackground(ConsoleColor.Black);
			area.SetDefaultForeground(ConsoleColor.White);
			area.SetTitle(title);

			area.Write(prompt, 1, 0);
			area.SetOffset(0, 0);

			var xPos = (short) (_console2.Width/2 - (area.Width/2));
			var yPos = (short) (_console2.Height/2 - (area.Height/2));

			_console2.DrawArea(area, xPos, yPos);
			
			Console.SetCursorPosition(xPos + prompt.Length + 3, yPos + 1);
			Console.CursorVisible = true;
			var result = Console.ReadLine();
			Console.CursorVisible = false;

			return result;
		}
		private void FillArea(Map map, ConsoleArea area, IEnumerable<Position> positions)
		{
			foreach (var position in positions)
			{
				var tile = GetTile(map.GetPositionValue(position));
				area.Write(tile.Character, position.X, position.Y, tile.ForeColor, tile.BackColor);
			}
		}
		private void UpdateDebugArea(ConsoleArea debugArea, Character player, Map map)
		{
			debugArea.Clear();
			debugArea.Write(GetDebugInfo(player, map), 0, 0);
		}
		private ConsoleArea CreateDebugArea()
		{
			var area = new ConsoleArea(100+20, 1);
			area.SetDefaultBackground(ConsoleColor.Black);
			area.SetDefaultForeground(ConsoleColor.White);
			return area;
		}
		private void UpdateMessageArea(ConsoleArea messageArea)
		{
			messageArea.Clear();
			var messages = _context.Messages.Take(5).Select((m, i) => new {Text = m, Index = i});
			foreach (var message in messages)
			{
				messageArea.Write(message.Text, 0, message.Index);
			}
			messageArea.SetOffset(0, 0);
		}
 private void DrawPlayer(string playerId, int xPos, int yPos, ConsoleArea area)
 {
     area.Write('@', xPos, yPos, GetPlayerColor(playerId));
 }
		private void DrawItem(Item item, ConsoleArea area)
		{
			area.Write(item.Name[0], item.XPos, item.YPos, GetItemColor(item));
		}
		private void DrawPlayer(string playerId, int xPos, int yPos, ConsoleArea area)
		{
			area.Write('@', xPos, yPos, GetPlayerColor(playerId));
		}
 private void DrawItem(Item item, ConsoleArea area)
 {
     area.Write(item.Name[0], item.XPos, item.YPos, GetItemColor(item));
 }
 public void DrawArea(ConsoleArea area, short x, short y)
 {
     DrawBuffer(area.GetBuffer(), x, y, area.Width, area.Height);
 }
		public void DrawArea(ConsoleArea area, short x, short y)
		{ 
			DrawBuffer(area.GetBuffer(), x, y, area.Width, area.Height);
		}
		private ConsoleArea CreateMessageArea()
		{
			var area = new ConsoleArea(100+20, 5+2);
			area.SetBorderStyle(ConsoleArea.BorderStyle.Single);
			area.SetBorderBackground(ConsoleColor.DarkYellow);
			area.SetBorderForeground(ConsoleColor.Yellow);
			area.SetDefaultBackground(ConsoleColor.DarkYellow);
			area.SetDefaultForeground(ConsoleColor.White);
			area.SetTitle(" Messages ");
			return area;
		}