public void TestOneCharacter()
        {
            var builder = new ConsoleStringBuilder(8);

            builder.Append("1");
            Assert.AreEqual("1", builder.ToString());
        }
Example #2
0
 private static void WriteWallLine(int size, ConsoleStringBuilder builder)
 {
     for (var i = 0; i < size; i++)
     {
         builder.Append("#");
     }
     builder.AppendLine();
 }
        private void Awake()
        {
            StringBuilder stringBuilder = new StringBuilder(maxCapacity, maxCapacity);

            stringBuilder.Append(output.text);
            consoleStringBuilder = new ConsoleStringBuilder(stringBuilder, format);
            GameConsole.Subscribe(consoleStringBuilder);
            IsDisplayUnityDebugLog(displayUnityDebugLog);
        }
        public void TestWithTabsAndReturns()
        {
            var builder = new ConsoleStringBuilder(10);

            builder.Append("\tHello\n\tWorld!");

            Assert.AreEqual(@"    Hello
    World!", builder.ToString());
        }
        public void TestWordWrapWithMultipleSpaces()
        {
            var builder = new ConsoleStringBuilder(10);

            builder.Append("This is a super     long text on 2 lines.", 2);

            Assert.AreEqual(@"This is a
  super
  long
  text on
  2 lines.", builder.ToString());
        }
        public void TestWordWrap()
        {
            var builder = new ConsoleStringBuilder(8);

            builder.Append("This is a super long text on 2 lines.");

            Assert.AreEqual(@"This is
a super
long
text on
2 lines.", builder.ToString());
        }
        public void TestWithSuperLongStringThatCannotWrap()
        {
            var builder = new ConsoleStringBuilder(8);

            builder.Append("ThisIsTheSuperLongSentenceThatCannotBeSplitInMultiline.", 2);

            Assert.AreEqual(@"ThisIsTh
  eSuper
  LongSe
  ntence
  ThatCa
  nnotBe
  SplitI
  nMulti
  line.", builder.ToString());
        }
Example #8
0
        /// <summary>
        /// Draw only labirint level
        /// </summary>
        /// <param name="labirinth"></param>
        /// <param name="screenClear"></param>
        public static void DrawLabirinth(LabirinthLevel labirinth, bool screenClear = false, ConsoleStringBuilder builder = null)
        {
            if (builder == null)
            {
                builder = new ConsoleStringBuilder();
            }

            if (screenClear)
            {
                Console.Clear();
            }

            var hero = Hero.GetHero;

            WriteWallLine(labirinth.Width + 2, builder);

            for (int y = 0; y < labirinth.Height; y++)
            {
                builder.Append("#");
                var row = new List <BaseCellObject>();
                for (int x = 0; x < labirinth.Width; x++)
                {
                    var cell = labirinth[x, y];
                    if (!screenClear && !HeroCanSeeThis(cell))
                    {
                        builder.Append("~");
                        continue;
                    }

                    if (hero.X == x && hero.Y == y)
                    {
                        builder.Append(hero.Chapter, hero.Color);
                    }
                    else
                    {
                        builder.Append(cell.Chapter, cell.Color);
                    }
                }

                builder.Append("#");
                builder.AppendLine();
            }

            WriteWallLine(labirinth.Width + 2, builder);

            builder.WriteToConsole();
        }
Example #9
0
        /// <summary>
        /// Draw rule, hero info and labirinth level
        /// </summary>
        /// <param name="dungeon">Pass dungeon that you want to draw</param>
        public static void DrawDungeon(Dungeon dungeon)
        {
            var builder = new ConsoleStringBuilder();

            Console.Clear();
            var hero = Hero.GetHero;

            builder.AppendLine("Rule:");
            builder.AppendLine("1) Use arrow to move");
            builder.AppendLine("2) Press Esc to Exit");
            builder.Append($"Level: {dungeon.CurrentLevelNumber}");
            builder.Append($" Money: ");
            builder.AppendLine(hero.Money.ToString(), Coin.CoinColor);
            builder.AppendLine(dungeon.DescLastAction);
            builder.AppendLine();

            DrawLabirinth(dungeon.CurrentLevel, builder: builder);
        }
        public void TestEmpty()
        {
            var builder = new ConsoleStringBuilder(8);

            Assert.IsEmpty(builder.ToString());
        }