private void DrawItem(IItem item, Console inventoryConsole, int position) { int xPosition = 55; int yPosition = 3 + (position * 2); string place = (position + 1).ToString(); inventoryConsole.CellData.Print(xPosition, yPosition, $"{place} - {item.Name}", item is NoItem ? Swatch.DbOldStone : Swatch.DbLight); }
public void DrawStats(Console statConsole) { statConsole.CellData.Print(1, 1, $"Name: {Name}", Color.White); statConsole.CellData.Print(1, 3, $"Health: {Health}/{MaxHealth}", Color.White); statConsole.CellData.Print(1, 5, $"Attack: {Attack} ({AttackChance}%)", Color.White); statConsole.CellData.Print(1, 7, $"Defense: {Defense} ({DefenseChance}%)", Color.White); statConsole.CellData.Print(1, 9, $"Gold: {Gold}", Color.Yellow); }
public RogueGame() { string consoleTitle = "RougeSharp SadConsole Example Game - Level 1"; int seed = (int)DateTime.UtcNow.Ticks; Random = new DotNetRandom(seed); MessageLog = new MessageLog(); MessageLog.Add("The rogue arrives on level 1"); MessageLog.Add($"Level created with seed '{seed}'"); Player = new Player(); SchedulingSystem = new SchedulingSystem(); MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 20, 13, 7, _mapLevel); DungeonMap = mapGenerator.CreateMap(); CommandSystem = new CommandSystem(); TargetingSystem = new TargetingSystem(); Player.Item1 = new RevealMapScroll(); Player.Item2 = new RevealMapScroll(); _inputState = new InputState(); _graphics = new GraphicsDeviceManager(this); this.Window.Title = consoleTitle; Content.RootDirectory = "Content"; var sadConsoleComponent = new SadConsole.EngineGameComponent(this, () => { using (var stream = System.IO.File.OpenRead("Fonts/Cheepicus12.font")) SadConsole.Engine.DefaultFont = SadConsole.Serializer.Deserialize <SadConsole.Font>(stream); SadConsole.Engine.DefaultFont.ResizeGraphicsDeviceManager(_graphics, _screenWidth, _screenHeight, 0, 0); SadConsole.Engine.UseMouse = true; SadConsole.Engine.UseKeyboard = true; _mapConsole = new Console(_mapWidth, _mapHeight); _messageConsole = new Console(_messageWidth, _messageHeight); _statConsole = new Console(_statWidth, _statHeight); _inventoryConsole = new Console(_inventoryWidth, _inventoryHeight); _mapConsole.Position = new Point(0, _inventoryHeight); _messageConsole.Position = new Point(0, _screenHeight - _messageHeight); _statConsole.Position = new Point(_mapWidth, 0); _inventoryConsole.Position = new Point(0, 0); SadConsole.Engine.ConsoleRenderStack.Add(_mapConsole); SadConsole.Engine.ConsoleRenderStack.Add(_messageConsole); SadConsole.Engine.ConsoleRenderStack.Add(_statConsole); SadConsole.Engine.ConsoleRenderStack.Add(_inventoryConsole); SadConsole.Engine.ActiveConsole = _mapConsole; }); Components.Add(sadConsoleComponent); }
public void DrawStats(Console statConsole, int position) { int yPosition = 13 + (position * 2); statConsole.CellData.Print(1, yPosition, Symbol.ToString(), Color); int width = Convert.ToInt32(((double)Health / (double)MaxHealth) * 16.0); int remainingWidth = 16 - width; statConsole.CellData.SetBackground(3, yPosition, width, Swatch.Primary); statConsole.CellData.SetBackground(3 + width, yPosition, remainingWidth, Swatch.PrimaryDarkest); statConsole.CellData.Print(2, yPosition, $": {Name}", Color.White); }
private void DrawAbility(IAbility ability, Console inventoryConsole, int position) { char letter = 'Q'; if (position == 0) { letter = 'Q'; } else if (position == 1) { letter = 'W'; } else if (position == 2) { letter = 'E'; } else if (position == 3) { letter = 'R'; } Color highlightTextColor = Swatch.DbOldStone; if (!(ability is DoNothing)) { if (ability.TurnsUntilRefreshed == 0) { highlightTextColor = Swatch.DbLight; } else { highlightTextColor = Swatch.DbSkin; } } int xPosition = 28; int xHighlightPosition = 28 + 4; int yPosition = 3 + (position * 2); inventoryConsole.CellData.Print(xPosition, yPosition, $"{letter} - {ability.Name}", highlightTextColor); if (ability.TurnsToRefresh > 0) { int width = Convert.ToInt32(((double)ability.TurnsUntilRefreshed / (double)ability.TurnsToRefresh) * 16.0); int remainingWidth = 20 - width; inventoryConsole.CellData.SetBackground(xHighlightPosition, yPosition, width, Swatch.DbOldBlood); inventoryConsole.CellData.SetBackground(xHighlightPosition + width, yPosition, remainingWidth, Color.Black); } }
public void DrawInventory(Console inventoryConsole) { inventoryConsole.CellData.Print(1, 1, "Equipment", Colors.InventoryHeading); inventoryConsole.CellData.Print(1, 3, $"Head: {Head.Name}", Head == HeadEquipment.None() ? Swatch.DbOldStone : Swatch.DbLight); inventoryConsole.CellData.Print(1, 5, $"Body: {Body.Name}", Body == BodyEquipment.None() ? Swatch.DbOldStone : Swatch.DbLight); inventoryConsole.CellData.Print(1, 7, $"Hand: {Hand.Name}", Hand == HandEquipment.None() ? Swatch.DbOldStone : Swatch.DbLight); inventoryConsole.CellData.Print(1, 9, $"Feet: {Feet.Name}", Feet == FeetEquipment.None() ? Swatch.DbOldStone : Swatch.DbLight); inventoryConsole.CellData.Print(28, 1, "Abilities", Colors.InventoryHeading); DrawAbility(QAbility, inventoryConsole, 0); DrawAbility(WAbility, inventoryConsole, 1); DrawAbility(EAbility, inventoryConsole, 2); DrawAbility(RAbility, inventoryConsole, 3); inventoryConsole.CellData.Print(55, 1, "Items", Colors.InventoryHeading); DrawItem(Item1, inventoryConsole, 0); DrawItem(Item2, inventoryConsole, 1); DrawItem(Item3, inventoryConsole, 2); DrawItem(Item4, inventoryConsole, 3); }
public RenderingSystem(Console canvas) { this.canvas = canvas; }
public RogueGame() { int seed = (int)DateTime.UtcNow.Ticks; Random = new DotNetRandom(seed); string consoleTitle = "Sean's Roguelike Engine v0.02 - Level 1 - seed " + seed; MessageLog = new MessageLog(); MapMessageLog = new MessageLog(); MessageLog.Add("The rogue arrives on level 1"); MessageLog.Add($"Level created with seed '{seed}'"); MapMessageLog.Add("Welcome to Cult of Draconis"); MapMessageLog.Add("Deep in the Caverns of Mar, an evil cult has succeeded"); MapMessageLog.Add("in summoning the ancient dragonlord Draconis."); MapMessageLog.Add("It is up to you to fight your way through the caverns,"); MapMessageLog.Add("Destroy the 4 power stones and kill Draconis"); MapMessageLog.Add("The power stones and Draconis reside on level 5."); MapMessageLog.Add("To descend stairs ' > ' press the period key ' . '"); Player = new Player(); SchedulingSystem = new SchedulingSystem(); MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 20, 13, 7, _mapLevel); DungeonMap = mapGenerator.CreateMap(); CommandSystem = new CommandSystem(); TargetingSystem = new TargetingSystem(); Player.Item1 = new RevealMapScroll(); Player.Item2 = new RevealMapScroll(); _inputState = new InputState(); _graphics = new GraphicsDeviceManager(this); this.Window.Title = consoleTitle; Content.RootDirectory = "Content"; var sadConsoleComponent = new SadConsole.EngineGameComponent(this, () => { using (var stream = System.IO.File.OpenRead("Fonts/Cheepicus12.font")) SadConsole.Engine.DefaultFont = SadConsole.Serializer.Deserialize <SadConsole.Font>(stream); SadConsole.Engine.DefaultFont.ResizeGraphicsDeviceManager(_graphics, _screenWidth, _screenHeight, 0, 0); SadConsole.Engine.UseMouse = true; SadConsole.Engine.UseKeyboard = true; _mapConsole = new Console(_mapWidth, _mapHeight); _messageConsole = new Console(_messageWidth, _messageHeight); _statConsole = new Console(_statWidth, _statHeight); _inventoryConsole = new Console(_inventoryWidth, _inventoryHeight); _mapConsole.Position = new Point(0, _inventoryHeight); _messageConsole.Position = new Point(0, _screenHeight - _messageHeight); _statConsole.Position = new Point(_mapWidth, 0); _inventoryConsole.Position = new Point(0, 0); SadConsole.Engine.ConsoleRenderStack.Add(_mapConsole); SadConsole.Engine.ConsoleRenderStack.Add(_messageConsole); SadConsole.Engine.ConsoleRenderStack.Add(_statConsole); SadConsole.Engine.ConsoleRenderStack.Add(_inventoryConsole); SadConsole.Engine.ActiveConsole = _mapConsole; }); Components.Add(sadConsoleComponent); }