Exemplo n.º 1
0
        public void initialisePlayer()
        {
            string name = "";
            while (string.IsNullOrEmpty(name))
            {
                Console.WriteLine("What's your name ?");
                Console.Write(">");
                name = Console.ReadLine();
            }

            Player player = new Player(name, 0, 1200, 1200, 1);

            player.playerInfo(player);
            Console.WriteLine("");
            Console.WriteLine("");
            Console.WriteLine("");
        }
Exemplo n.º 2
0
        public void movePlayer(Player player)
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Choose your direction");
            Console.WriteLine();
            Console.ResetColor();
            Console.WriteLine("North");
            Console.WriteLine("South");
            Console.WriteLine("East");
            Console.WriteLine("West");
            Console.WriteLine("Info");
            Console.WriteLine("Quit");

            Console.Write(">");

            directionPlayer = Console.ReadLine();
            switch (directionPlayer)
            {
                case "North":
                case "north":
                    try
                    {
                        positionY++;
                        positionPlayer = card[positionX, positionY];

                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine(positionStart);
                        Console.ResetColor();

                        monsterRate = random.Next(0, 2);

                        if (monsterRate == 1)
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("Be careful you are attacked !");
                            Console.ResetColor();

                            Battle battle = new Battle(player);

                        }
                        else
                        {
                            movePlayer(player);
                        }
                    }
                    catch (Exception)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("There are nothing, change direction");
                        Console.ResetColor();

                        movePlayer(player);

                    }

                    break;

                case "South":
                case "south":

                    try
                    {
                        positionX++;
                        positionStart = card[positionX, positionY];
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine(positionStart);
                        Console.ResetColor();

                        monsterRate = random.Next(0, 2);

                        if (monsterRate == 1)
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("Attention ! Vous vous faîtes attaqué !");
                            Console.ResetColor();
                            Battle battle = new Battle(player);

                        }
                        else
                        {
                            movePlayer(player);
                        }
                    }
                    catch (Exception)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Il n'y a que l'océan par là ,vous ne pouvez aller dans cette direction");
                        Console.ResetColor();

                        movePlayer(player);
                    }

                    break;

                case "West":
                case "west":

                    try
                    {
                        positionX--;
                        positionStart = card[positionX, positionY];
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine(positionStart);
                        Console.ResetColor();

                        monsterRate = random.Next(0, 2);

                        if (monsterRate == 1)
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("Attention ! Vous vous faîtes attaqué !");
                            Console.ResetColor();

                            Battle battle = new Battle(player);

                        }
                        else
                        {
                            movePlayer(player);
                        }
                    }
                    catch (Exception)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Il n'y a que l'océan par là ,vous ne pouvez aller dans cette direction");
                        Console.ResetColor();

                        movePlayer(player);
                    }

                    break;

                case "Info":
                case "info":

                    player.playerInfo(player);
                    movePlayer(player);

                    break;

            }
        }