示例#1
0
 private void WriteRoute(MatrixNode a)
 {
     if (a != null)
     {
         DisplayMatix.Write('*', a.x, a.y, ConsoleColor.Green);
         WriteRoute(a.parent);
     }
 }
示例#2
0
        private object SolvePart1(char[,] map)
        {
            int turnNumber = 0;
            var units      = GetUnits(map);

            while (units.Any(x => x.IsAlive && x.Type == UnitType.Elf) && units.Any(x => x.IsAlive && x.Type == UnitType.Goblin))
            {
                foreach (var item in units.Where(x => x.IsAlive).OrderBy(x => x.Point.Y).ThenBy(x => x.Point.X))
                {
                    item.Turn(map, units);
                }


                Thread.Sleep(10);

                //var key = Console.ReadKey();
                //if (key.Key == ConsoleKey.Escape)
                //{
                //    return 0;
                //}

                DisplayMatix.Write(map);

                turnNumber++;

                //Console.SetCursorPosition(0, 18);
                //Console.WriteLine(string.Format("{0} {1}", units.Count(x => x.IsAlive && x.Type == UnitType.Elf), units.Count(x => x.IsAlive && x.Type == UnitType.Goblin)).PadLeft(8));

                //Console.SetCursorPosition(0, 20);
                //units.Where(x => /*x.IsAlive && */x.Type == UnitType.Elf).ToList().ForEach(x => Console.WriteLine(string.Format("{0}", x.Hp).PadLeft(8)));

                //Console.SetCursorPosition(0, 30);
                //units.Where(x => /*x.IsAlive && */ x.Type == UnitType.Goblin).ToList().ForEach(x => Console.WriteLine(string.Format("{0}", x.Hp).PadLeft(8)));

                //Console.SetCursorPosition(0, 16);
                //Console.WriteLine(turnNumber);
            }

            Console.SetCursorPosition(0, 38);
            Console.WriteLine(turnNumber * units.Where(x => x.IsAlive).Sum(x => x.Hp));
            return(0);
        }