private int DrawPrimaryStatistics(BufferContainer buffer, int currentLine) { var currentStageHero = Game.Hero; WriteAt(buffer, 0, currentLine++, "Hero Statistics: Primary", ConsoleColor.White, ConsoleColor.Black); currentLine++; WriteAt(buffer, 0, currentLine, "Name".PadLeft(18, ' ')); WriteAt(buffer, 20, currentLine++, Game.Hero.Name, ConsoleColor.Yellow); WriteAt(buffer, 0, currentLine, "Level".PadLeft(18, ' ')); WriteAt(buffer, 20, currentLine++, currentStageHero.Level.ToString(), ConsoleColor.Yellow); WriteAt(buffer, 0, currentLine, "Experience".PadLeft(18, ' ')); WriteAt(buffer, 20, currentLine++, currentStageHero.ExperienceCents.ToString(), ConsoleColor.Yellow); WriteAt(buffer, 0, currentLine, "Health".PadLeft(18, ' ')); WriteAt(buffer, 20, currentLine++, currentStageHero.Health.Current + "/" + currentStageHero.Health.Max, ConsoleColor.Yellow); WriteAt(buffer, 0, currentLine, "Charge".PadLeft(18, ' ')); WriteAt(buffer, 20, currentLine++, currentStageHero.Charge.Current + "/" + currentStageHero.Charge.Max, ConsoleColor.Yellow); WriteAt(buffer, 0, currentLine, "Armour".PadLeft(18, ' ')); WriteAt(buffer, 20, currentLine++, currentStageHero.Armor.ToString(), ConsoleColor.Yellow); WriteAt(buffer, 0, currentLine, "Gold".PadLeft(18, ' ')); WriteAt(buffer, 20, currentLine++, currentStageHero.Gold.ToString(), ConsoleColor.Yellow); WriteAt(buffer, 0, currentLine, "Food".PadLeft(18, ' ')); var tmpFood = Math.Floor(currentStageHero.Food); WriteAt(buffer, 20, currentLine++, tmpFood.ToString(), ConsoleColor.Yellow); return(currentLine); }
///------------------------------------------------------------- public LineSetup(MeshContainer.Bound bounds, int index, BufferContainer positions, BufferContainer colors) { this.bounds = bounds; this.index = index; this.positions = positions; this.colors = colors; }
public override void Draw(BufferContainer buffer) { var currentLine = 0; switch (statisticTab) { case HeroStatisticTab.Primary: { currentLine = DrawPrimaryStatistics(buffer, currentLine); break; } case HeroStatisticTab.Secondard: { currentLine = DrawSecondaryStatistics(buffer, currentLine); break; } } // Options for Item Dialog String helpText = "[Tab] Switch view"; WriteAt(buffer, 0, currentLine + 3, $"{helpText}", ConsoleColor.Gray); }
public void DrawVisibleItems(BufferContainer buffer, Appearence[,] source, VectorBase heroPosition) { var viewPortMatrix = GetMatrixViewPort(source, heroPosition); var matrixWidth = viewPortMatrix.GetUpperBound(0) + 1; var matrixHeight = viewPortMatrix.GetUpperBound(1) + 1; for (var rowIndex = 0; rowIndex < matrixHeight; rowIndex++) { for (var columnIndex = 0; columnIndex < matrixWidth; columnIndex++) { var currentTile = viewPortMatrix[columnIndex, rowIndex].Clone(); if (!currentTile.IsExplored || currentTile.IsInShadow || currentTile.IsHidden) { buffer.Write($" ", columnIndex, rowIndex, ConsoleColor.DarkRed); } else { var foreGroundColour = currentTile.ForeGroundColor == null ? ConsoleColor.White : ColourUtilities.ConvertToConsoleColor(currentTile.ForeGroundColor); var backGroundColour = currentTile.BackGroundColor == null ? ConsoleColor.Black : ColourUtilities.ConvertToConsoleColor(currentTile.BackGroundColor); buffer.Write(currentTile.Glyph, columnIndex, rowIndex, foreGroundColour, backGroundColour); } } } }
/// <summary> /// This is to handle the writing of a message to the buffer. /// Need to remember to add padding /// </summary> /// <param name="buffer"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="message"></param> /// <param name="foregroundColor"></param> /// <param name="backgroundColor"></param> public void WriteAt(BufferContainer buffer, int x, int y, string message, ConsoleColor foregroundColor = ConsoleColor.White, ConsoleColor backgroundColor = ConsoleColor.Black, bool ignorePadding = false) { if (message == null) { return; } // Drawing Logic // 1. Add padding to position // 2. Truncate the message. (AUTO) var transformedX = x; var transformedY = y; if (!ignorePadding) { transformedX = x + Padding_Left; transformedY = y + Padding_Top; if (message.Length > MaxWidth) { message = message.Substring(0, MaxWidth - 3) + "..."; } } else { if (message.Length > Width) { message = message.Substring(0, Width - 3) + "..."; } } buffer.Write($"{message}", transformedX, transformedY, foregroundColor, backgroundColor); }
private void DrawStat(BufferContainer buffer, int x, int y, string symbol, object stat, ConsoleColor light, ConsoleColor dark, bool enabled) { var statString = stat.ToString(); WriteAt(buffer, x + 47 - statString.Length, y, symbol, enabled ? dark : ConsoleColor.DarkGray); WriteAt(buffer, x + 49 - statString.Length, y, statString, enabled ? light : ConsoleColor.DarkGray); }
private int DrawSecondaryStatistics(BufferContainer buffer, int currentLine) { var currentStageHero = Game.Hero; WriteAt(buffer, 0, currentLine++, "Hero Statistics: Secondary", ConsoleColor.White, ConsoleColor.Black); currentLine++; var currentWarrior = currentStageHero.HeroClass as Warrior; // Combat, Toughness, Fighting WriteAt(buffer, 0, currentLine, "Toughness"); WriteAt(buffer, 20, currentLine++, currentWarrior.Toughness.Level + " [" + currentWarrior.Toughness.percentUntilNext + "%]", ConsoleColor.Yellow); WriteAt(buffer, 0, currentLine, "Fighting"); WriteAt(buffer, 20, currentLine++, currentWarrior.Fighting.Level + " [" + currentWarrior.Fighting.percentUntilNext + "%]", ConsoleColor.Yellow); WriteAt(buffer, 0, currentLine, "Combat"); WriteAt(buffer, 20, currentLine++, currentWarrior.Combat.Level + " [" + currentWarrior.Combat.percentUntilNext + "%]", ConsoleColor.Yellow); currentLine++; WriteAt(buffer, 0, currentLine++, "Masteries:", ConsoleColor.White, ConsoleColor.Black); foreach (var mastery in currentWarrior.Masteries.OrderBy(x => x.Key)) { WriteAt(buffer, 0, currentLine, mastery.Key); WriteAt(buffer, 20, currentLine++, mastery.Value.Level + " [" + mastery.Value.percentUntilNext + "%]", ConsoleColor.Yellow); } return(currentLine); }
public override void Draw(BufferContainer buffer) { buffer.Clear(); FrameArea(buffer); DrawLeftPane(buffer); DrawRightPane(buffer); var gold = PriceString(Game.Hero.Gold); WriteAt(buffer, 1, MaxHeight - 3, "Gold:"); WriteAt(buffer, 7, MaxHeight - 3, gold, ConsoleColor.DarkYellow); // Options for Item Dialog var helpText = ""; if (currentAction == StorageLocationAction.None) { var transferVerb = "Transfer"; helpText = $"[↔] Select column, [↕] Select source, [{transferVerb[0]}] {transferVerb}, [Esc] Exit"; } if (currentAction != StorageLocationAction.None) { helpText = $"[A-Z] Select item, [Esc/T] Cancel tansfer"; } WriteAt(buffer, 1, MaxHeight - 2, $"{helpText}", ConsoleColor.DarkGray); }
public override void Draw() { LoadLayoutData(); var buffer = new BufferContainer(0, 0, (short)ScreenHeight, (short)ScreenWidth); Layout.Draw(buffer); }
private void DrawRightPane(BufferContainer buffer) { int xOffset = ((Right - Left) / 2); WriteAt(buffer, xOffset, 0, $"{RightPane.ToString()}"); DrawItems(buffer, xOffset, 2, GetItems(RightPane), RightPane, LeftPane, RightHasFocus); }
public override void Draw(BufferContainer buffer) { ClearArea(buffer); var appearenaces = Game.CurrentStage.Appearances; var heroPosition = Game.CurrentStage.LastHeroPosition; DrawVisibleItems(buffer, appearenaces, heroPosition); }
private void RequestDraw(int frame) { BufferContainer buffer = avcodec_manager_.GetFrame(frame); if (buffer != null) { drawing_thread_.Draw(buffer.Buffer); } }
public void Draw(BufferContainer buffer) { foreach (var segment in LayoutSections.Select(x => x.Value).Where(x => x.Enabled).OrderBy(x => x.RenderOrder)) { segment.Draw(buffer); } var bufferRender = new BufferRender(); bufferRender.Render(buffer); }
///----------------------------------------------------------------- public LineData(int capacity, GameObject gameObject, MeshRenderer renderer, Material material, int borderThickness) { this.gameObject = gameObject; this.material = material; forceDirtyPass = false; index = 0; mesh = new MeshContainer(capacity, renderer, borderThickness); positions = new BufferContainer(capacity); colors = new BufferContainer(capacity); }
public override void Commit() { BufferContainer buffer; while ((buffer = new BufferContainer(GetBuffer())).IsValuable) { _buffers.Add(buffer); var binder = new EmitterBinder(buffer, buffer.GetEmitter()); Array.ForEach(_targets, target => binder.Emitter.BeginSend(binder.Buffer.Buffer, buffer.Size, target, Committed, binder)); } }
public override void Draw(BufferContainer buffer) { int linePostion = 0; WriteAt(buffer, 0, linePostion++, $"Which direction?"); WriteAt(buffer, 0, linePostion++, $" nw n ne"); WriteAt(buffer, 0, linePostion++, $" \\ | /"); WriteAt(buffer, 0, linePostion++, $"w - * - e"); WriteAt(buffer, 0, linePostion++, $" / | \\"); WriteAt(buffer, 0, linePostion++, $" sw s se"); }
public override void Draw(BufferContainer buffer) { var hero = Game.Hero; var foreGroundColour = hero.Appearance.ForeGroundColor == null ? ConsoleColor.White : ColourUtilities.ConvertToConsoleColor(hero.Appearance.ForeGroundColor); var backGroundColour = hero.Appearance.BackGroundColor == null ? ConsoleColor.Black : ColourUtilities.ConvertToConsoleColor(hero.Appearance.BackGroundColor); var line = $"Lv: {Game.Hero.Level}[{Game.Hero.LevelPercentage}%] HP: {Game.Hero.Health.Current}/{Game.Hero.Health.Max} Charge:{Game.Hero.Charge.Current}/{Game.Hero.Charge.Max} "; WriteAt(buffer, 0, 0, line, foreGroundColour, backGroundColour); var secondLine = $"Armour: {Game.Hero.Armor} Weapon: {Game.Hero.GetAttack(null).BaseDamage} Food: {Math.Floor(Game.Hero.Food)}"; WriteAt(buffer, 0, 1, secondLine, foreGroundColour, backGroundColour); }
public override void Draw(BufferContainer buffer) { int linePostion = 0; WriteAt(buffer, 0, linePostion++, "There are open door(s) to the:"); foreach (var direction in Direction.All) { var position = Game.Hero.Position + direction; if (Game.CurrentStage[position].Type.ClosesTo != null) { WriteAt(buffer, 0, linePostion++, $" {direction}"); } } linePostion++; WriteAt(buffer, 0, linePostion, "Close which door?"); }
public override void Draw(BufferContainer buffer) { WriteAt(buffer, 0, 0, "Perform which command?"); var lineCounter = 0; for (var i = 0; i < HeroCommands.Count; i++) { var y = i + 1; lineCounter++; var command = HeroCommands[i]; WriteAt(buffer, 0, y, "( ) ", ConsoleColor.Gray); WriteAt(buffer, 1, y, "abcdefghijklmnopqrstuvwxyz"[i].ToString(), ConsoleColor.Yellow); WriteAt(buffer, 4, y, command.Name); } WriteAt(buffer, 0, lineCounter + 2, "[A-Z] Select command, [1-9] Bind quick key, [Esc] Exit", ConsoleColor.Gray); }
public override void Draw(BufferContainer buffer) { for (var y = 0; y < chars.Count; y++) { for (var x = 0; x < chars[y].Length; x++) { var charColor = charColors[y][x]; var color = colors[charColor.ToString()]; buffer.Write(chars[y][x].ToString(), Left + x + 4, Top + y + 1, color); } } NumberOfHeroes = Storage.Heroes.Count; buffer.Write("Which hero shall you play?", Left + 0, Top + 18); buffer.Write("[L] Select a hero, [↕] Change selection, [N] Create a new hero, [D] Delete hero", Left + 0, Top + 18 + NumberOfHeroes + 3, ConsoleColor.Gray); if (NumberOfHeroes == 0) { buffer.Write("(No heroes. Please create a new one.)", Left + 0, Top + 20, ConsoleColor.Gray); } for (var i = 0; i < Storage.Heroes.Count; i++) { var hero = Storage.Heroes[i]; var fore = ConsoleColor.White; var secondaryFore = ConsoleColor.Gray; var back = ConsoleColor.Black; if (i == SelectedHeroIndex) { fore = ConsoleColor.Black; secondaryFore = ConsoleColor.White; back = ConsoleColor.Yellow; } buffer.Write(hero.Name, Left + 6, Top + 20 + i, fore, back); buffer.Write($"Level {hero.Level}", Left + 25, Top + 20 + i, secondaryFore); buffer.Write(hero.HeroClass.Name, Left + 35, Top + 20 + i, secondaryFore); } }
public void FrameArea(BufferContainer buffer) { var ascii = new ASCII(); for (var lineLooper = 0; lineLooper < Height; lineLooper++) { var text = ascii[AsciiKeys.WallNS] + string.Empty.PadLeft(Width - 2, ' ') + ascii[AsciiKeys.WallNS]; if (lineLooper == 0) { text = ascii[AsciiKeys.WallCornerSE] + string.Empty.PadLeft(Width - 2, ascii[AsciiKeys.WallEW][0]) + ascii[AsciiKeys.WallCornerSW]; } if (lineLooper == Height - 1) { text = ascii[AsciiKeys.WallCornerNE] + string.Empty.PadLeft(Width - 2, ascii[AsciiKeys.WallEW][0]) + ascii[AsciiKeys.WallCornerNW]; } WriteAt(buffer, 0, lineLooper, text, ConsoleColor.Yellow, ConsoleColor.Black, true); } }
public override void Draw(BufferContainer buffer) { buffer.Clear(); FrameArea(buffer); // Header for Item Dialog var lineCounter = 0; WriteAt(buffer, 0, lineCounter++, Command.Query(Location)); // Options for Item Dialog var selectItem = "[A-Z] Select item"; var helpText = CanSwitchLocations ? ", [Tab] Switch view" : ""; WriteAt(buffer, 0, lineCounter++, $"{selectItem}{helpText}", ConsoleColor.Gray); // List of Items DrawItems(buffer, 0, lineCounter + 2, GetItems(Game), item => Command.CanSelect(item)); }
public void Process() { var buffer = new BufferContainer((short)Top, (short)Left, (short)Bottom, (short)Right); var bufferRender = new BufferRender(); var exitLoop = false; do { if (NoFrame == false) { FrameArea(buffer); } Draw(buffer); bufferRender.Render(buffer); exitLoop = HandleInput(); } while (exitLoop == false); ClearArea(buffer); }
public override void Draw(BufferContainer buffer) { buffer.Write("What name shall the bards use to sing of", Left + 0, Top + 1); buffer.Write("your hero's adventures?", 0, Top + 2); if (string.IsNullOrWhiteSpace(PlayerName)) { buffer.Write(DefaultName, Left + 0, Top + 4, ConsoleColor.Black, ConsoleColor.Yellow); buffer.Write(string.Empty.PadRight(Right - Left - 2 - DefaultName.Length, ' '), Left + 0, Top + 4 + DefaultName.Length, ConsoleColor.White, ConsoleColor.Black); } else { buffer.Write(string.Empty.PadRight(Right - Left - 2, ' '), Left + 0, Top + 4); buffer.Write(PlayerName, Left + 0, Top + 4); buffer.Write(" ", Left + 0 + PlayerName.Length, Top + 4, ConsoleColor.Black, ConsoleColor.Yellow); } buffer.Write("[A-Z] Enter name, [Del] Delete letter", Left + 0, Top + 6, ConsoleColor.Gray); buffer.Write("[Tab] Generate Random Name", Left + 0, Top + 7, ConsoleColor.Gray); buffer.Write("[Enter] Create hero, [Esc] Cancel", Left + 0, Top + 8, ConsoleColor.Gray); }
private void DrawItems(BufferContainer buffer, int x, int y, List <Item> items, StorageLocation current, StorageLocation target, bool isActive = false) { var i = 0; foreach (var item in items) { var alphabet = "abcdefghijklmnopqrstuvwxyz"; var itemY = i + y; var borderColor = ConsoleColor.DarkGray; var letterColor = ConsoleColor.DarkGray; var textColor = ConsoleColor.DarkGray; var priceColor = ConsoleColor.DarkGray; var glyphColor = ConsoleColor.DarkGray; var attackColor = ConsoleColor.DarkGray; var armourColor = ConsoleColor.DarkGray; var enabled = true; if (isActive) { switch (target) { case StorageLocation.Equipment: { var command = new EquipItemCommand(); var canUse = command.CanSelect(item); if (canUse) { borderColor = ConsoleColor.Gray; letterColor = ConsoleColor.Yellow; textColor = item == null ? ConsoleColor.Gray : ConsoleColor.White; priceColor = ConsoleColor.DarkYellow; glyphColor = item == null ? ConsoleColor.Gray : ColourUtilities.ConvertToConsoleColor(item.Appearance.ForeGroundColor); attackColor = ConsoleColor.Yellow; armourColor = ConsoleColor.Green; } break; } case StorageLocation.Crucible: { var canUse = false; if (item != null) { canUse = CanUseItemInRecipe(item); } if (canUse) { borderColor = ConsoleColor.Gray; letterColor = ConsoleColor.Yellow; textColor = item == null ? ConsoleColor.Gray : ConsoleColor.White; priceColor = ConsoleColor.DarkYellow; glyphColor = item == null ? ConsoleColor.Gray : ColourUtilities.ConvertToConsoleColor(item.Appearance.ForeGroundColor); attackColor = ConsoleColor.Yellow; armourColor = ConsoleColor.Green; } break; } default: { borderColor = ConsoleColor.Gray; letterColor = ConsoleColor.Yellow; textColor = item == null ? ConsoleColor.Gray : ConsoleColor.White; priceColor = ConsoleColor.DarkYellow; glyphColor = item == null ? ConsoleColor.Gray : ColourUtilities.ConvertToConsoleColor(item.Appearance.ForeGroundColor); attackColor = ConsoleColor.Yellow; armourColor = ConsoleColor.Green; break; } } } WriteAt(buffer, x, itemY, " ) ", borderColor); WriteAt(buffer, x, itemY, alphabet[i].ToString(), letterColor); if (item == null) { // what is the location? if (current == StorageLocation.Equipment) { var text = ((EquipementSlot)i) + " slot is empty"; WriteAt(buffer, x + 3, itemY, text, textColor); } } else { if (enabled) { WriteAt(buffer, x + 3, itemY, item.Appearance.Glyph, glyphColor); } var text = item.NounText; if (text.Length > 32) { text = text.Substring(0, 29) + "..."; } WriteAt(buffer, x + 5, itemY, text, textColor); // TODO: Eventually need to handle equipment that gives both an armor and attack bonus. if (item.attack != null) { DrawStat(buffer, x, itemY, "»", item.attack.AverageDamage, attackColor, attackColor, enabled); } else if (item.armor != 0) { DrawStat(buffer, x, itemY, "•", item.armor, armourColor, armourColor, enabled); } if (item.price != 0) { var price = PriceString(item.price); WriteAt(buffer, x + 49 - price.Length, itemY, price, priceColor); } } // Increment the item counter i++; } // If this is the crucible then maybe a recipe has been completed. if (current == StorageLocation.Crucible) { if (completeRecipe != null) { i++; i++; var textColour = ConsoleColor.Yellow; if (isActive) { textColour = ConsoleColor.DarkGray; } var csv = string.Join(", ", completeRecipe.Produces.ToArray()); WriteAt(buffer, 0, y + i++, $"This recipe {csv}!", textColour); WriteAt(buffer, 0, y + i++, "Press[Space] to forge item!", textColour); } } }
private void DrawLeftPane(BufferContainer buffer) { WriteAt(buffer, 0, 0, $"{LeftPane.ToString()}"); DrawItems(buffer, 0, 2, GetItems(LeftPane), LeftPane, RightPane, !RightHasFocus); }
public override void Draw(BufferContainer buffer) { buffer.Write("Oh well, death comes to all of us!", Left + 0, Top + 1); }
internal CollectionAdderEnumerator(BufferContainer container, CollectionAdder <T> adder) { this.container = container; this.adder = adder; }
public CollectionAdder(BufferContainer container) { this.container = container; }
public override void Draw(BufferContainer buffer) { WriteAt(buffer, 0, 0, $"{Message} [Y]/[N]"); }