Beispiel #1
0
        public static void Perform()
        {
            Levels.Load();
            Console.Clear();
            Renderer.Enemies.Clear();
            Renderer.Labels.Clear();
            Renderer.Player.Clear();
            DiffDraw.Clear(21, 1);
            Label status = new Label(new Point(0, 0), "Snakity Bench running");

            Renderer.Labels.Add(status);
            Renderer.Render(false);
            Tuple <bool, bool, bool, TimeSpan>[] result = new[] { false, true }.SelectMany(b1 => new[] { false, true }, (b1, b2) => new { b1, b2 })
            .SelectMany(t => new[] { false, true }, (t, b3) => new { t, b3 })
            .Select(t => new Tuple <bool, bool, bool, TimeSpan>(t.t.b1, t.t.b2, t.b3, Perform(t.t.b1, t.t.b2, t.b3)))
            .OrderBy(s => s.Item4).ToArray();
            Console.Clear();
            Console.WriteLine("╔═Smooth1═╤═Smooth2═╤═Color═╤═Time═╗");
            bool color2 = false;

            foreach ((bool smooth1, bool smooth2, bool color, TimeSpan time) in result)
            {
                color2 = !color2;
                Console.BackgroundColor = color2 ? ConsoleColor.Black : ConsoleColor.White;
                Console.ForegroundColor = color2 ? ConsoleColor.White : ConsoleColor.Black;
                string tmp = time.TotalSeconds.ToString(CultureInfo.InvariantCulture);
                if (tmp.Length > 5)
                {
                    tmp = tmp.Remove(5);
                }
                else if (tmp.Length < 5)
                {
                    tmp += new string(' ', 6 - tmp.Length);
                }
                Console.WriteLine(
                    $"║    {(smooth1 ? "X" : " ")}    │    {(smooth2 ? "X" : " ")}    │   {(color ? "X" : " ")}   │{tmp}s║");
            }
            Console.ResetColor();
            Console.WriteLine("╚═Smooth1═╧═Smooth2═╧═Color═╧═Time═╝");
            Console.WriteLine();
            Console.WriteLine("Impact:");
            Console.WriteLine($"- Smooth1: {GetImpact(result, tuple => tuple.Item1)}s");
            Console.WriteLine($"- Smooth2: {GetImpact(result, tuple => tuple.Item2)}s");
            Console.WriteLine($"- Color:   {GetImpact(result, tuple => tuple.Item3)}s");
            Console.WriteLine();
            Console.WriteLine("Press any key to return");
            Console.ReadKey();
        }
Beispiel #2
0
        private static void PlayRound()
        {
            Console.Clear();
            bool playing = true;

            Pixel[,] init = new Pixel[1, 2];
            init.Populate(new Pixel());
            DiffDraw.Clear(init);
            DiffDraw.Draw(false);
            Label scoreLabel = new Label(new Point(0, 0), "");

            Renderer.Labels.Clear();
            Renderer.Labels.Add(scoreLabel);
            Levels.Load();
            (char[,] level, bool[,] spawnable) =
                CharArrayLoader.LoadLevel(Levels.levels[Rnd.Next(Levels.levels.Length)], SettingsMan.SmoothTerrain);
            bool hasIncreased = false;

            Renderer.Player.Clear();
            Renderer.Player.Add(new Tuple <Point, Point>(new Point(1, 1), new Point(0, 1)));
            Renderer.Enemies.Clear();
            DiffDraw.Clear(ColorSelector.Get(level));
            DiffDraw.Draw(SettingsMan.Color);
            Input.Reset();
            while (playing)
            {
                DiffDraw.Clear(ColorSelector.Get(level));
                scoreLabel.Text = $"Score: {_score}";
                Renderer.Render(SettingsMan.SmoothPlayer);
                Input.Get();
                if (Input.Move(hasIncreased) || Input.Esc)
                {
                    Renderer.Player.Clear();
                    Input.Reset();
                    playing   = false;
                    Input.Esc = false;
                    continue;
                }

                if (Input.R)
                {
                    _score = 0;
                    init.Populate(new Pixel());
                    DiffDraw.Clear(init);
                    DiffDraw.Draw(SettingsMan.Color);
                    Console.Clear();
                    (level, spawnable) = CharArrayLoader.LoadLevel(Levels.levels[Rnd.Next(Levels.levels.Length)], SettingsMan.SmoothTerrain);
                    DiffDraw.Clear(ColorSelector.Get(level));
                    Renderer.Player.Clear();
                    Renderer.Player.Add(new Tuple <Point, Point>(new Point(2, 2), new Point(0, 1)));
                    Renderer.Enemies.Clear();
                    Input.Reset();
                    Input.R = false;
                }

                Renderer.Render(SettingsMan.SmoothPlayer);
                hasIncreased = Enemy.Compute(spawnable);
                if (hasIncreased)
                {
                    _score++;
                }
                DiffDraw.Draw(SettingsMan.Color);
            }
            Console.ResetColor();
        }