Пример #1
0
        public void Describe(Room room)
        {
            CenterText centerText = new CenterText();

            centerText.WriteTextAndCenter($"Current room: {room.Name}\n");
            centerText.WriteTextAndCenter(room.Bio);
        }
Пример #2
0
        public void WriteitemsList(Player player)
        {
            CenterText centerText = new CenterText();

            for (int i = 0; i < player.itemList.Count; i++)
            {
                centerText.WriteTextAndCenter($"{i + 1}) {player.itemList[i].Name}");
            }
        }
Пример #3
0
        public void Inspect(Items items)
        {
            CenterText centerText = new CenterText();

            centerText.WriteTextAndCenter(items.Bio);
        }
Пример #4
0
        //Metod som tar in första position (Home) och ändrar värdet för varje exit-commando
        public void Position(ref Room room, Player player,
                             bool controlKeys, bool controlBusCard, bool controlSmartPhone,
                             bool controlCoffe, ref bool alive)
        {
            CenterText centerText = new CenterText();

            if (room.isLocked == true)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                centerText.WriteTextAndCenter($"To be able to enter " +
                                              $"you need to unlock the exit with an item.\n\n");
                Console.ForegroundColor = ConsoleColor.Cyan;
            }
            else
            {
                if (room.Name == new Home(player.Character).Name)
                {
                    room = new ToBus(player.Character);
                }
                else if (room.Name == new ToBus(player.Character).Name&& controlBusCard)
                {
                    room = new Bus();
                }
                else if (room.Name == new Bus().Name)
                {
                    room = new ToSchool();
                }
                else if (room.Name == new ToBus(player.Character).Name&& controlSmartPhone)
                {
                    room = new Cab();
                }
                else if (room.Name == new Cab().Name)
                {
                    room = new ToSchool();
                }
                else if (room.Name == new ToSchool().Name&& controlKeys)
                {
                    room = new School();
                }
                else if (room.Name == new School().Name)
                {
                    if (controlCoffe)
                    {
                        Console.ForegroundColor = ConsoleColor.Green;
                        centerText.WriteTextAndCenter("You made it in time for Fredriks lecture " +
                                                      "and you have brought the most important item. COFFE! \n\n");
                        centerText.WriteTextAndCenter("YOU WIN!");
                        Console.ForegroundColor = ConsoleColor.Cyan;

                        // Sätt endpoint på rummet så att spelet avslutas
                        room.endpoint = true;
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        centerText.WriteTextAndCenter("Did you forget to bring COFFE?? " +
                                                      "You will die a slowly death...");
                        Console.ForegroundColor = ConsoleColor.Cyan;
                        alive = false;
                    }
                }
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            bool gameOver = false;

            while (gameOver == false)
            {
                //Declaration
                var        charMimmi       = new CharMimmi();
                var        charMarkus      = new CharMarkus();
                var        charAhmad       = new CharAhmad();
                Player     chosenCharacter = null;
                Play       game            = new Play();
                CenterText centerText      = new CenterText();


                //Title Screen
                Console.WriteLine("\n\n\n\n");
                Console.ForegroundColor = ConsoleColor.Cyan;
                centerText.WriteTextAndCenter("Welcome to Travel Adventure\n");
                Console.ForegroundColor = ConsoleColor.Green;
                centerText.WriteTextAndCenter("Your mission is to get to school!\n");
                Console.ForegroundColor = ConsoleColor.Cyan;
                centerText.WriteTextAndCenter("But first, choose your character bio\n\n");
                centerText.WriteTextAndCenter("Character (1)");
                centerText.WriteTextAndCenter(charMimmi.Bio + "\n");
                centerText.WriteTextAndCenter("Character (2)");
                centerText.WriteTextAndCenter(charMarkus.Bio + "\n");
                centerText.WriteTextAndCenter("Character (3)");
                centerText.WriteTextAndCenter(charAhmad.Bio + "\n");


                //Väljer story att gå efter
                int charChoice;
                while (true)
                {
                    if (int.TryParse(centerText.ReadTextAndCenter(), out charChoice))
                    {
                        if (charChoice == 1)
                        {
                            chosenCharacter = charMimmi;
                        }
                        if (charChoice == 2)
                        {
                            chosenCharacter = charMarkus;
                        }
                        if (charChoice == 3)
                        {
                            chosenCharacter = charAhmad;
                        }
                        if (charChoice != 1 && charChoice != 2 && charChoice != 3)
                        {
                            centerText.WriteTextAndCenter("Try a number between 1-3!");
                            continue;
                        }
                        break;
                    }
                    else
                    {
                        centerText.WriteTextAndCenter("Try with numbers instead");
                    }
                }

                Console.Clear();
                Console.WriteLine("\n\n\n");
                centerText.WriteTextAndCenter("Name your character");
                string name = centerText.ReadTextAndCenter(5);
                chosenCharacter.Name = name;

                Console.Clear();
                Console.WriteLine("\n\n\n\n");

                centerText.WriteTextAndCenter("Welcome " + chosenCharacter.Name + "!");

                game.Playing(chosenCharacter);

                centerText.WriteTextAndCenter("Play again?(Y/N)");
                string answer = centerText.ReadTextAndCenter().ToUpper();
                Console.Clear();

                if (answer == "N")
                {
                    gameOver = true;
                    Console.WriteLine("\n\n\n\n\n\n\n\n");
                    centerText.WriteTextAndCenter("GAME OVER!");
                }

                Console.ReadLine();
            }
        }