コード例 #1
0
        private void Fighting()
        {
            if (enemys == null || enemys.Count <= 0 || player_1 == null || player_1.IsDea() ||
                (!ATTACT_1.Equals(inputKey.Key) && !ATTACT_2.Equals(inputKey.Key) &&
                 !RUN_1.Equals(inputKey.Key) && !RUN_2.Equals(inputKey.Key)))
            {
                return;
            }

            if (ATTACT_1.Equals(inputKey.Key) || ATTACT_2.Equals(inputKey.Key))
            {
                // 玩家攻击
                Fight(player_1, player_1.skills[0], enemys[0]);

                // 怪物攻击
                foreach (Charactar enemy in enemys)
                {
                    Fight(enemy, enemy.skills[0], player_1);
                }
            }
            else if (RUN_1.Equals(inputKey.Key) || RUN_2.Equals(inputKey.Key))
            {
                if (!IsRunAway())
                {
                    // 怪物攻击
                    foreach (Charactar enemy in enemys)
                    {
                        Fight(enemy, enemy.skills[0], player_1);
                    }
                }
            }
        }
コード例 #2
0
ファイル: HauptMenu.cs プロジェクト: ThomasKman/NP
        public override int Navigieren(ConsoleKey gedrückteTaste)
        {
            menuModifier = 0;

            if (gedrückteTaste.Equals(ConsoleKey.Enter))
            {
                gedrückteTaste = Ausführen();
            }

            if (gedrückteTaste.Equals(ConsoleKey.LeftArrow))
            {
                if (navIndex > 0)
                {
                    navIndex--;
                }
                else
                {
                    navIndex = Menupunkte.Count() - 1;
                }
            }
            if (gedrückteTaste.Equals(ConsoleKey.RightArrow))
            {
                if (navIndex < Menupunkte.Count() - 1)
                {
                    navIndex++;
                }
                else
                {
                    navIndex = 0;
                }
            }

            return(menuModifier);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Player player = new Player();

            Console.Clear();
            Console.CursorVisible = false;
            while (true)
            {
                Console.SetCursorPosition(player.x, Console.WindowHeight);
                Console.Write("P");
                System.Threading.Thread.Sleep(100);
                Console.SetCursorPosition(player.x, Console.WindowHeight);
                Console.Write(" ");
                if (Console.KeyAvailable)
                {
                    ConsoleKey key = Console.ReadKey(true).Key;
                    if (key.Equals(ConsoleKey.J))
                    {
                        player.left();
                    }
                    if (key.Equals(ConsoleKey.K))
                    {
                        player.right();
                    }
                }
            }
        }
コード例 #4
0
        public static void practiceWord(WordList wordList)
        {
            Word word;
            bool stop = false;

            while (!stop)
            {
                word = wordList.GetWordToPractice();
                Console.WriteLine("What is the translation of the word " + word.Translations[word.FromLanguage] +
                                  " from language \"" + wordList.Languages[word.FromLanguage] +
                                  "\" to the language \"" + wordList.Languages[word.ToLanguage] + "\"");
                string answer = Console.ReadLine();
                if (answer == word.Translations[word.ToLanguage])
                {
                    bool tryAgain = false;
                    Console.WriteLine("Correct! Well done.");
                    while (!tryAgain)
                    {
                        Console.WriteLine("Would u like to try one more? y/n");
                        ConsoleKey again = Console.ReadKey().Key;
                        if (again.Equals(ConsoleKey.Y))
                        {
                            tryAgain = true;
                        }
                        else if (again.Equals(ConsoleKey.N))
                        {
                            Console.WriteLine();
                            return;
                        }
                        Console.WriteLine();
                    }
                }
            }
        }
コード例 #5
0
        static void createCharacterClass()
        {
            writeLine("What will be your character's class? Choose one from the options below.");
            dividerLine();
            writeLine("1: Hunter");
            writeLine("2: Titan");
            writeLine("3: Warlock");
            dividerLine();
            string     playerClass;
            ConsoleKey keyPressed = Console.ReadKey(true).Key;

            if (keyPressed.Equals(D1))
            {
                playerClass = "Hunter";
            }
            else if (keyPressed.Equals(D2))
            {
                playerClass = "Titan";
            }
            else if (keyPressed.Equals(D3))
            {
                playerClass = "Warlock";
            }
            else
            {
                playerClass = "";
                writeLine("Unrecognized input.");
                createCharacterClass();
            }
            player.mainClass = playerClass;
            writeLine("Your class was chosen as: " + playerClass);
            saveCharacter();
            gameStart();
        }
コード例 #6
0
        private void NotFighting()
        {
            if (!GO_ON_1.Equals(inputKey.Key) && !GO_ON_2.Equals(inputKey.Key) && !STOP_1.Equals(inputKey.Key) && !STOP_2.Equals(inputKey.Key))
            {
                return;
            }
            if (GO_ON_1.Equals(inputKey.Key) || GO_ON_2.Equals(inputKey.Key))
            {
                progress++;
            }
            //else if (STOP_1.Equals(inputKey.Key) || STOP_2.Equals(inputKey.Key))
            //{
            //}
            bool isAddProg        = progress > completedProg;
            bool isEncounterEnemy = IsEncounterEnemy(isAddProg);

            if (isEncounterEnemy)
            {
                EncounterEnemy();
            }
            else if (!isAddProg)
            {
                player_1.RecoverHP();
                player_1.RecoverMP();
            }
        }
コード例 #7
0
        public override ConsoleKey Ausführen()
        {
            if (navIndex == 0)
            {
                NavigiereKlassenAuswahl(-1);
            }


            if (navIndex == 1)
            {
                neueKlasse();
            }

            if (navIndex == 2)
            {
                menuModifier--;
            }

            if (navIndex == 3)
            {
                ConsoleKey key = Grafiken.zeichneDialog("wirklich beenden? [Y/n]", ConsoleColor.DarkRed, ConsoleColor.Red);
                if (key.Equals(ConsoleKey.Enter) || key.Equals(ConsoleKey.Y))
                {
                    menuModifier = -2;
                }
                else
                {
                    return(key);
                }
            }
            return(ConsoleKey.Enter);
        }
コード例 #8
0
        public void StartGame(ConsoleKey input)
        {
            if (input.Equals(ConsoleKey.Escape))
            {
                Environment.Exit(0);
            }

            if (input.Equals(ConsoleKey.S))
            {
                StartPlaying();
            }
            _output.StartMenuListener();
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: atsn/TcpChat
        static void Main(string[] args)
        {
            Console.WriteLine("Please enter name");
            string name = Console.ReadLine();

            Console.WriteLine("press 1 for client and 2 for server");
            ConsoleKey pressedkey = Console.ReadKey(true).Key;


            if (pressedkey.Equals(ConsoleKey.D1) || pressedkey.Equals(ConsoleKey.NumPad1))
            {
                try
                {
                    Console.WriteLine("please enter ip");
                    string ip           = Console.ReadLine();
                    string testtesttest = "messege";

                    TcpClient         client        = new TcpClient(ip, 6789);
                    var               clientStream  = client.GetStream();
                    ConnectionHandler handler       = new ConnectionHandler(clientStream, name);
                    Thread            Reshivethread = new Thread(handler.Reshive);
                    Thread            Sendthread    = new Thread(handler.Sendmessege);
                    Reshivethread.Start();
                    Sendthread.Start();
                    Console.WriteLine("Du kan nu skrive");
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }

            else if (pressedkey.Equals(ConsoleKey.D2) || pressedkey.Equals(ConsoleKey.NumPad2))
            {
                TcpListener server = new TcpListener(IPAddress.Any, 6789);
                server.Start();
                TcpClient serverclient = server.AcceptTcpClient();
                Console.WriteLine("client forbundet");
                ConnectionHandler handler       = new ConnectionHandler(serverclient.GetStream(), name);
                Thread            Reshivethread = new Thread(handler.Reshive);
                Thread            Sendthread    = new Thread(handler.Sendmessege);
                Reshivethread.Start();
                Sendthread.Start();
                Console.WriteLine("Du kan nu skrive");
            }
            else
            {
                Console.WriteLine("button not regconiced");
            }
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: Jordy-Ramlal/Test
 public void move()
 {
     if (Console.KeyAvailable)
     {
         ConsoleKey key = Console.ReadKey(true).Key;
         if (key.Equals(ConsoleKey.A))
         {
             left();
         }
         if (key.Equals(ConsoleKey.D))
         {
             right();
         }
     }
 }
コード例 #11
0
        public void Entertainement()
        {
            Console.Clear();
            Console.BackgroundColor = Color.SteelBlue;
            Console.Clear();

            Message.TitleBox(" E N T E R T A I N M E N T ", 3, 40, ConsoleColor.Red, ConsoleColor.White);
            Message.BoxColor = Color.White;

            Message.CreateBox("", 16, 30, "");



            Console.CursorTop = 7;
            Message.menuBox(3, 32, " [A]. S N A K E ", ConsoleColor.Blue, ConsoleColor.White, 1);
            Message.menuBox(3, 32, " [B]. C O L O R  G A M E ", ConsoleColor.Blue, ConsoleColor.White, 1);

            Console.WriteLine();
            Console.WriteLine();
            Message.menuBox(1, 32, " E N T E R  L E T T E R ", ConsoleColor.Red, ConsoleColor.White);
            Message.menuBox(1, 32, " O F  Y O U R  C H O I C E ", ConsoleColor.Red, ConsoleColor.White);
            Message.menuBox(1, 32, " [BACK SPACE] M E N U ", ConsoleColor.Red, ConsoleColor.White);
            select = Console.ReadKey().Key;
            if (select.Equals(ConsoleKey.A))
            {
                Snake snake = new Snake(USERNAME);
                snake.Initialize();
            }
            else if (select.Equals(ConsoleKey.B))
            {
                Console.BackgroundColor = Color.Black;
                Console.Clear();
                ColorGame cg = new ColorGame();
                cg.gameStart();
            }
            else if (select.Equals(ConsoleKey.Backspace))
            {
                SystemMenu();
            }
            else
            {
                Message.TitleBox("Invalid Choice Try Again", 5, 40, ConsoleColor.Red, ConsoleColor.White);
                Console.ReadKey();
                Entertainement();
            }

            Console.ReadKey(true);
        }
コード例 #12
0
ファイル: MenuInformations.cs プロジェクト: DrPsykoz/Pokedex
 public override void ApplyKey(ConsoleKey key)
 {
     if (key.Equals(ConsoleKey.Spacebar))
     {
         Pokedex.CURRENT_MENU = lastMenu;
     }
 }
コード例 #13
0
        static void Main(string[] args)
        {
            ConsoleKey imput = ConsoleKey.Enter;


            while (imput.Equals(ConsoleKey.Enter))
            {
                WriteLine("Ingrese apuesta 1-6 \n");

                int apuesta = int.Parse(Console.ReadLine());

                int resul = play(apuesta, new Program().dado);


                if (resul == apuesta)
                {
                    WriteLine($"Ganador:   { apuesta  } \n");
                }
                else
                {
                    WriteLine($"Perdedor:   { apuesta  } \n");
                }

                WriteLine("\n Enter para Continuar::\n");
                imput = ReadKey().Key;
            }
        }
コード例 #14
0
        private void seleccionOpcion(ConsoleKey ck)
        {
            if (!ck.Equals(ConsoleKey.Escape))
            {
                switch (ck)
                {
                case ConsoleKey.D1:
                case ConsoleKey.NumPad1:
                    leerTiempoLimite();
                    break;

                case ConsoleKey.D2:
                case ConsoleKey.NumPad2:
                    leerNumeroPreguntas();
                    break;

                case ConsoleKey.D3:
                case ConsoleKey.NumPad3:
                    jugar();
                    break;

                default:
                    //imprimirError("\n\nERROR. Opción no válida.\n");
                    imprimirError("\n\nERROR. Non-existent option.\n");
                    esperaCorta();
                    break;
                }
            }
            else
            {
                Environment.Exit(0);
            }
        }
コード例 #15
0
 private static void CheckBreak(ConsoleKey breakKey)
 {
     if (breakKey.Equals(ConsoleKey.B))
     {
         throw new BreakException();
     }
 }
コード例 #16
0
        internal static void RecursiveFibonacci()
        {
            bool open   = true;
            int  number = 0;

            while (open)
            {
                Console.Clear();
                Console.WriteLine("I will find the nth number in the Fibonacci Sequence using Recursion."
                                  + "\nWhich number in the sequence would you like me to find:");
                try { int.TryParse(Console.ReadLine(), out number); }
                catch (Exception)
                {
                    Console.Clear();
                    Console.WriteLine("Please make a valid selection.");
                }

                int result = RecursiveFibonacci(number);
                Console.WriteLine($"The {number.ToString()}th number in the Fibonacci Sequence is: {result.ToString()}");

                Console.WriteLine("Would you like to try again? Press 'Q' to quit");

                ConsoleKey key = GetKey();
                if (key.Equals(ConsoleKey.Q))
                {
                    open = false;
                }
            }
        }
コード例 #17
0
        public void Run()
        {
            ConsoleKey key         = ConsoleKey.A;
            int        opcao       = -1;
            bool       opcaoValida = false;

            do
            {
                ApresentarOpcoes();
                if (!int.TryParse(Console.ReadLine(), out opcao))
                {
                    Utilitario.EscreverMensagem("A opção informada deve ser um número!");
                    continue;
                }

                if ((opcaoValida = ExecutarOpcao(opcao)) == false)
                {
                    Utilitario.EscreverMensagem("A opção informada não é válida!");
                    continue;
                }

                Console.Write("Precione Enter para sair...");
                key = Console.ReadKey().Key;
            } while(!key.Equals(ConsoleKey.Enter));
        }
コード例 #18
0
        public void Run()
        {
            ConsoleKey key            = ConsoleKey.A;
            int        opcao          = -1;
            Opcoes     opcaoEscolhida = Opcoes.Sair;

            do
            {
                ApresentarOpcoes();
                if (!int.TryParse(Console.ReadLine(), out opcao))
                {
                    Utilitario.EscreverMensagem("A opção informada deve ser um número!");
                    continue;
                }

                if ((opcaoEscolhida = ExecutarOpcao(opcao)).Equals(Opcoes.Sair))
                {
                    Utilitario.EscreverMensagem("Volte Sempre!", 2);
                    break;
                }

                if (opcaoEscolhida.Equals(Opcoes.Invalida))
                {
                    continue;
                }

                Console.Write("Precione Esc para sair...");
                key = Console.ReadKey().Key;
            } while(!key.Equals(ConsoleKey.Escape));
        }
コード例 #19
0
 public void GameOver(ConsoleKey input)
 {
     if (input.Equals(ConsoleKey.Escape))
     {
         Environment.Exit(0);
     }
     _output.GameOver();
 }
コード例 #20
0
 private static void CheckHelp(ConsoleKey helpKey)
 {
     if (helpKey.Equals(ConsoleKey.H))
     {
         Help();
         throw new BreakException();
     }
 }
コード例 #21
0
        static void createCharacterRace()
        {
            writeLine("What race would you like for your character?");
            dividerLine(true);
            dividerLine();
            writeLine("1: Human");
            writeLine("2: Kree");
            writeLine("3: Inhuman");
            writeLine("4: Awoken");
            writeLine("5: Exo");
            dividerLine();
            string     playerRace;
            ConsoleKey keyPressed = Console.ReadKey(true).Key;

            if (keyPressed.Equals(D1))
            {
                playerRace = "Human";
            }
            else if (keyPressed.Equals(D2))
            {
                playerRace = "Kree";
            }
            else if (keyPressed.Equals(D3))
            {
                playerRace = "Inhuman";
            }
            else if (keyPressed.Equals(D4))
            {
                playerRace = "Awoken";
            }
            else if (keyPressed.Equals(D5))
            {
                playerRace = "Exo";
            }
            else
            {
                playerRace = "";
                writeLine("Unrecognized input.");
                dividerLine(true);
                createCharacterRace();
            }
            player.race = playerRace;
            writeLine("Your character's race has been chosen as: " + playerRace);
            createCharacterClass();
        }
コード例 #22
0
        private void KlasseLöschen()
        {
            ConsoleKey key = Grafiken.zeichneDialog("wirklich Löschen? [Y/n]", ConsoleColor.DarkRed, ConsoleColor.Red);

            if (key.Equals(ConsoleKey.Enter) || key.Equals(ConsoleKey.Y))
            {
                Program.klassenListe.Remove(UI.AktuelleSchulklasse);
                UI.menuIndex--;
                navIndex = 0;


                key = Grafiken.zeichneDialog("Gelöscht. Speichern? [Y/n]", ConsoleColor.DarkGreen, ConsoleColor.Green);
                if (key.Equals(ConsoleKey.Enter) || key.Equals(ConsoleKey.Y))
                {
                    FileWriter.saveFile(Program.klassenListe);
                }
            }
        }
コード例 #23
0
 private static void CheckExit(ConsoleKey exitKey)
 {
     if (exitKey.Equals(ConsoleKey.Q))
     {
         Console.WriteLine("Push any key to exit...");
         Console.ReadKey();
         Environment.Exit(0);
     }
 }
コード例 #24
0
        private void HandleShoot()
        {
            while (true)
            {
                ConsoleKey key = Console.ReadKey().Key;
                Console.Clear();

                Console.WriteLine(key.ToString());

                if (key.Equals(ConsoleKey.Escape))
                {
                    return;
                }

                if (((int)key > 48 && (int)key <= 52))
                {
                    string name  = key.ToString().Substring(1);
                    int    value = int.Parse(name) - 1;

                    currentWeapon = weapons[value];

                    Console.WriteLine("Switched weapon to: " + currentWeapon);
                }

                if (key.Equals(ConsoleKey.Spacebar))
                {
                    Console.WriteLine("Current weapon: " + currentWeapon);

                    int ammo = dictionary[currentWeapon]--;

                    if (ammo <= 0)
                    {
                        ammo = 0;
                        dictionary[currentWeapon] = ammo;
                        Console.WriteLine("Empty clip!");
                    }
                    else
                    {
                        Console.WriteLine("Ammo: " + dictionary[currentWeapon]);
                    }
                }
            }
        }
コード例 #25
0
ファイル: Utils.cs プロジェクト: notPlancha/cmd-Utils
 public static bool ValidKey(ConsoleKey key, ConsoleKey[] options)
 {
     foreach (ConsoleKey option in options)
     {
         if (key.Equals(option))
         {
             return(true);                    //maybe doesnt work
         }
     }
     return(false);
 }
コード例 #26
0
        private static bool IsManuallyGenerationType()
        {
            bool       requested = false;
            ConsoleKey key       = ConsoleKey.Escape;

            Console.WriteLine("Do you want to enter array values manually? Please press Y or N.");
            while (!requested)
            {
                Console.SetCursorPosition(0, 2);
                key = Console.ReadKey().Key;
                if (key.Equals(ConsoleKey.Y) || key.Equals(ConsoleKey.N))
                {
                    requested = true;
                }

                Console.Write(" - Wrong key pressed. Please enter Y or N.", key.ToString(), requested);
            }
            Console.Clear();
            return(key.Equals(ConsoleKey.Y));
        }
コード例 #27
0
        static void Main(string[] args)
        {
            Console.WriteLine("Please enter name");
            string name = Console.ReadLine();

            Console.WriteLine("press 1 for client and 2 for server");
            ConsoleKey pressedkey = Console.ReadKey(true).Key;

            if (pressedkey.Equals(ConsoleKey.D1) || pressedkey.Equals(ConsoleKey.NumPad1))
            {
                try
                {
                    Console.WriteLine("please enter ip");
                    string            ip            = Console.ReadLine();
                    ConnectionHandler handler       = new ConnectionHandler(name, true, ip);
                    Thread            Reshivethread = new Thread(handler.Reshive);
                    Thread            Sendthread    = new Thread(handler.Sendmessege);
                    Reshivethread.Start();
                    Sendthread.Start();
                    Console.WriteLine("Du kan nu skrive");
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }

            else if (pressedkey.Equals(ConsoleKey.D2) || pressedkey.Equals(ConsoleKey.NumPad2))
            {
                ConnectionHandler handler       = new ConnectionHandler(name, false);
                Thread            Reshivethread = new Thread(handler.Reshive);
                Thread            Sendthread    = new Thread(handler.Sendmessege);
                Reshivethread.Start();
                Sendthread.Start();
                Console.WriteLine("Du kan nu skrive");
            }
            else
            {
                Console.WriteLine("button not regconiced");
            }
        }
コード例 #28
0
        private void neuesSchulfach()
        {
            List <string> fachName = Grafiken.zeichneEingabeMenü(new List <string>()
            {
                "string", "Name  : "
            });

            UI.AktuelleSchulklasse.AddSchulfach(fachName.First());
            ConsoleKey Key = Grafiken.Bestätigen("Speichern? [Y/n]");

            if (Key.Equals(ConsoleKey.Enter) || Key.Equals(ConsoleKey.Y))
            {
                FileWriter.saveFile(Program.klassenListe);
                FileReader.readFiles();
            }



            generiereKlassenInfo();
            Grafiken.zeichneObjektInfo(KlassenInfo, 3, false);
        }
コード例 #29
0
 public static bool beingPressed(ConsoleKey tecla)
 {
     if (Console.KeyAvailable)
     {
         teclaActual = Console.ReadKey(true).Key;
         return(teclaActual.Equals(tecla));
     }
     else
     {
         return(false);
     }
 }
コード例 #30
0
        /// <summary>
        /// Handles the user's input and calls the right callback when an option is selected.
        /// </summary>
        private void HandleUserInput()
        {
            while (MenuActive)
            {
                ConsoleKeyInfo keyInfo = Console.ReadKey();
                ConsoleKey     key     = keyInfo.Key;
                char           keyChar = keyInfo.KeyChar;

                if (key.Equals(ConsoleKey.UpArrow))
                {
                    SelectionIndex -= 1;
                    if (SelectionIndex < 0)
                    {
                        SelectionIndex = MenuOptions.Count - 1;
                    }
                }
                else if (key.Equals(ConsoleKey.DownArrow))
                {
                    SelectionIndex += 1;
                    if (SelectionIndex > MenuOptions.Count - 1)
                    {
                        SelectionIndex = 0;
                    }
                }
                else if (key.Equals(ConsoleKey.Enter))
                {
                    MenuActive = false;
                    MenuItem selectedOption = MenuOptions[SelectionIndex];

                    selectedOption.callback(selectedOption.cbValue);
                }

                if (MenuActive)
                {
                    RenderMenu();
                }
            }
        }