示例#1
0
        public void Tick(int damageValue)
        {
            int damage = damageValue;

            if (zombies.Count == 0)  //no more zombies (or initial empty list)
            {
                Console.WriteLine(" All zombies killed.");
                Stop();
            }
            Console.Write("\n  Press any key to shoot a zombie.");
            var inp = Console.ReadLine();

            if (inp == "q")
            {
                Stop();
            }

            Console.Write($"  [!] - { zombies[0].Type} shot.");
            zombies[0].TakeDamage(damage);

            Console.WriteLine();
            printing.PrintArray(ref zombies);

            if (!zombies[0].IsAlive)
            {
                Console.WriteLine($"  [!] - {zombies[0].Type} died.");
                zombies.Remove(zombies[0]);
            }
        }
        public void Tick()
        {
            Console.Write("\n  Input Zombie type integer:  ");
            var accessoryType = Console.ReadLine();

            if (accessoryType == "q")
            {
                Stop();
                return;
            }

            if (accessoryType != "1" && accessoryType != "2" && accessoryType != "3" && accessoryType != "4")
            {
                Console.WriteLine(" [!] - INVALID INPUT. Input an integer between 1-4 or 'q' to stop adding zombies.");
                return;
            }
            zombies.Add(new Zombie(accessoryType));

            printing.PrintArray(ref zombies);
        }
        public void Run()
        {
            while (isRunning)
            {
                if (state == State.OPTIONS)
                {
                    Console.WriteLine("\n- - - - - Main Menu - - - - -  ");
                    Console.WriteLine("\n (1): Create Zombies  ");
                    Console.WriteLine(" (2): Demo gameplay ");

                    var mode = Console.ReadLine();


                    if (mode == "1")
                    {
                        create.isRunning = true;
                        Console.WriteLine(" (1) - Zombie creation selected.  \n");
                        Console.WriteLine(" [NOTE] - Press 'q' at any point to stop creating zombies.  \n");
                        Console.WriteLine("  Available Zombie types:  ");
                        Console.WriteLine("   (1): Regular  ");
                        Console.WriteLine("   (2): Cone  ");
                        Console.WriteLine("   (3): Bucket  ");
                        Console.WriteLine("   (4): ScreenDoor  ");
                        state = State.CREATE;
                    }
                    else if (mode == "2")
                    {
                        Console.WriteLine(" (2) - Demo selected.  \n");
                        Console.WriteLine(" [NOTE] - Press 'q' at any time to exit.\n");

                        string inp;
                        bool   success = false;
                        while (!success)
                        {
                            Console.Write("  Input a damage value:  ");
                            inp = Console.ReadLine();

                            int i;
                            success = int.TryParse(inp, out i);
                            if (!success)
                            {
                                Console.WriteLine(" [!] - INVALID INPUT. Input an integer.\n");
                            }
                            else
                            {
                                damageValue = Int32.Parse(inp);

                                Console.WriteLine();

                                printing.PrintArray(ref zombies);

                                demo.isRunning = true;
                                state          = State.DEMO;
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine(" [!] - INVALID INPUT. Input an integer between 1-2.");
                    }
                }
                if (state == State.CREATE)
                {
                    create.Update();
                    if (create.IsRunning == false)
                    {
                        state = State.OPTIONS;
                    }
                }
                if (state == State.DEMO)
                {
                    demo.Update(damageValue);
                    if (!demo.IsRunning)
                    {
                        state = State.OPTIONS;
                    }
                }
            }
        }