Exemplo n.º 1
0
        public static void MoveHero()
        {
            MovementHero   hero = new MovementHero();
            Border         bord = new Border();
            GameArea       area = new GameArea();
            ConsoleKeyInfo key  = Console.ReadKey();
            var            step = key.ToString();

            if (step == "a" && hero.HeroX > 0 && hero.HeroX != bord.BorderX) // movemet left
            {
                hero.HeroX--;
            }
            else if (step == "d" && hero.HeroX < area.Width && hero.HeroX != bord.BorderX) // movemet right
            {
                hero.HeroX--;
            }
            else if (step == "s" && hero.HeroY < area.Height && hero.HeroY != bord.BorderY) // movemet down
            {
                hero.HeroY++;
            }
            else if (step == "up" && hero.HeroY > 0 && hero.HeroY != bord.BorderY) // movemet up
            {
                hero.HeroY--;
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.Write("Floor Adventure");
            Console.WriteLine("By SimpleDeveloping");
            Console.WriteLine("Press [P] to play, press [X] to quit.");
            ConsoleKeyInfo
                cki = Console.ReadKey();

            do
            {
                cki = Console.ReadKey();
                if (cki.ToString() ==)
                {
                    Console.WriteLine(cki.Key.ToString());
                }
            } while (cki.Key != ConsoleKey.Escape);
        }
Exemplo n.º 3
0
        //
        public static void PrintMatchInfo(ChessMatch chessMatch)
        {
            Console.WriteLine("Captured Pieces:");
            //
            ConsoleColor aux = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.Blue;
            Console.Write("Black:");
            Console.WriteLine(PrintHashSet(chessMatch.GetCapturedPieces(Color.Black)));
            Console.ForegroundColor = aux;
            //
            Console.Write("White:");
            Console.WriteLine(PrintHashSet(chessMatch.GetCapturedPieces(Color.White)));

            Console.WriteLine();

            if (!chessMatch.MatchEnded)
            {
                Console.WriteLine("Turn: " + chessMatch.turn);
                //  Set a string with the name of the current player (White or Black)
                string currentPlayer = (chessMatch.currentPlayer == Color.White) ? "White" : "Black";
                Console.WriteLine("It's the player's turn: " + currentPlayer);
                Console.WriteLine();

                if (chessMatch.Check)
                {
                    Console.WriteLine();
                    Console.WriteLine(chessMatch.currentPlayer.ToString() + " king is in check!");
                }
            }
            else
            {
                //Match is ended!
                Console.WriteLine("Check mate! " + chessMatch.currentPlayer.ToString() + " wins!");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Press enter to play again.");
                Console.ForegroundColor = aux;

                ConsoleKeyInfo key = Console.ReadKey(true);
                if (key.ToString() == "enter")
                {
                    chessMatch.ResetMatch();
                }
            }
        }
Exemplo n.º 4
0
        void ChooseTamagotchi()
        {
            Console.WriteLine("Which tamagotchi do you want to play with?");
            Tamagotchi.ViewList();
            ConsoleKeyInfo uInput = Console.ReadKey();

            int  uInputInt;
            bool parse = int.TryParse(uInput.ToString(), out uInputInt);

            if (parse == true && uInputInt - 1 <= Tamagotchi.list.Count)
            {
                Console.WriteLine($"You chose {uInputInt - 1}: {Tamagotchi.list[uInputInt - 1].name}");
                ContinueButton();

                PlayingWithTamaGotchi(Tamagotchi.list[uInputInt - 1]);
            }
            else
            {
                Console.WriteLine("No tamagotchi found");
                ContinueButton();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// prompt the user to select a data source and return the choice
        /// </summary>
        /// <returns>int</returns>
        public int DisplayGetDataTypeChoice()
        {
            Console.WriteLine("Choose a data source");

            int  result    = 2;
            bool usingMenu = true;

            while (usingMenu)
            {
                Console.CursorVisible = false;

                //
                // display the menu
                //
                Console.WriteLine("\n\n" + "Please type the number of your menu choice.");

                Console.Write(
                    "\t" + "1. CSV" + Environment.NewLine +
                    "\t" + "2. XML" + Environment.NewLine +
                    "\t" + "3. JSON" + Environment.NewLine +
                    "\t" + "E. Exit" + Environment.NewLine);


                //
                // get and process the user's response
                // note: ReadKey argument set to "true" disables the echoing of the key press
                //
                ConsoleKeyInfo userResponse = Console.ReadKey(true);
                switch (userResponse.KeyChar)
                {
                case '1':
                    result    = int.Parse(userResponse.ToString());
                    usingMenu = false;
                    break;

                case '2':
                    result    = int.Parse(userResponse.ToString());
                    usingMenu = false;
                    break;

                case '3':
                    result    = int.Parse(userResponse.ToString());
                    usingMenu = false;
                    break;

                case 'E':
                case 'e':
                    DisplayClosingScreen();
                    usingMenu = false;
                    break;

                default:
                    Console.Clear();
                    Console.WriteLine(
                        "It appears you have selected an incorrect choice." + Environment.NewLine +
                        "XML has been automatically selected as the data type." + Environment.NewLine +
                        "Press any key to continue.");

                    userResponse = Console.ReadKey(true);
                    if (userResponse.Key == ConsoleKey.Escape)
                    {
                        usingMenu = false;
                    }
                    break;
                }
            }
            Console.CursorVisible = true;

            return(result);
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            Host       host = new ZNet.Host();
            RemotePeer remotepeer;
            //List<RemotePeer> remotePeerlist = new List<RemotePeer>();
            //for (int i = 0; i < 10; i++)
            //{
            RUDPPeer tmp = host.CreateRUDPPeer();

            tmp.OnConnectionStatusChange += (ZNet.ConnectonStaus status, ZNet.RemotePeer RemotePeer) =>
            {
                Console.WriteLine("Main: Connection status change to: " + status);
                remotepeer = RemotePeer;
            };

            tmp.OnMessageReceive += (string data, ZNet.RemotePeer RemotePeer) =>
            {
                //Console.WriteLine("Main: Message received: " + data);
            };

            remotepeer = tmp.Connect("127.0.0.1", 42);

            //    remotePeerlist.Add(remotepeer);
            //}



            int send  = 0;
            int index = 0;

            while (0 == 0)
            {
                host.ServiceAllPeers();
                //if (send >= 0)
                //{
                //    string tmpstr = send.ToString();
                //    remotepeer.Send(ref tmpstr);
                //    send--;
                //}
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey(true);
                    switch (key.Key)
                    {
                    case ConsoleKey.S:
                        Console.WriteLine("Read key and send message.");
                        string tmpk = key.ToString();
                        while (index < 1000)
                        {
                            string tmpstr = send.ToString();
                            tmpstr = "Data" + tmpstr;
                            remotepeer.Send(ref tmpstr);
                            send++;
                            index++;
                        }
                        index = 0;

                        /*var rpeer = remotePeerlist.GetEnumerator();
                         * while (rpeer.MoveNext())
                         * {
                         *  rpeer.Current.Send(ref tmp);
                         * }*/
                        //remotepeer.Send(ref tmpk);
                        break;

                    default:
                        break;
                    }
                }
            }
            host.Destroy();
        }