Exemple #1
0
        void ReadCommand()
        {
            while (true)
            {
                Console.WriteLine("Was möchtest Du jetzt tun? > ");
                //string cmd = Convert.ToString(Console.ReadLine());

                //Bullet b = theShip?.bullets[0] ?? new Bullet("", new Space(""));


                ConsoleKeyInfo cmd = Console.ReadKey();

                /*
                 * switch( cki.Key )
                 * {
                 *  case ConsoleKey.LeftArrow:
                 *      break;
                 *
                 * }
                 */


                switch (cmd.Key)
                {
                case ConsoleKey.A:
                    theShip.Move("west");
                    RenderSpace();
                    break;

                case ConsoleKey.D:
                    theShip.Move("east");
                    RenderSpace();
                    break;

                case ConsoleKey.F:
                    theShip.Fire();
                    RenderSpace();
                    break;

                case ConsoleKey.Q:
                    return;

                default:
                    Console.WriteLine("Ich habe Dich nicht verstanden");
                    break;
                }
            }
        }
        public static void BotBehaviour(Spaceship ship)
        {
            Console.WriteLine("Bot Started");
            while (true)
            {
                System.Threading.Thread.Sleep(2000);
                if (ship.Energy >= 50)
                {
                    ship.Move(GenRand(0, 10), 10);

                    double x = GenRand(0, 360);
                    double y = GenRand(0, 45);
                    ship.Shoot(x, y, 20, "abcdefghijklmnop");
                }
            }
        }