Beispiel #1
0
        public void MoveToDirection(EDirection direction)
        {
            var validDirection = _currentRoom.ConnectedRooms.TryGetValue(direction, out Room room); //give back bool

            if (validDirection == true)
            {
                var result   = _currentRoom.ConnectedRooms[direction]; //gives back room
                var lastRoom = _currentRoom;
                _currentRoom = result;

                //               if ((_currentRoom.Name == "Door") || (_currentRoom.Name == "Window"))
                //              {
                //                   Console.WriteLine("You found a way out!!");
                //                   Console.WriteLine($"There are still ghosts in the house. Do you want to leave? (y/n)");
//
//                   var answer = Console.ReadLine();
//                   if ((answer == "yes") || (answer == "y"))
//                   {
//                       Console.WriteLine("You are a coward.");
//                   }
//                   else if ((answer == "no") || (answer == "n"))
//                   {
//                       Console.WriteLine("Choose a different direction.");
//                   }
//               }

                Console.Clear();
                Logos.LogoGame();

                switch (direction)
                {
                case EDirection.North:
                    direction = EDirection.South;
                    break;

                case EDirection.East:
                    direction = EDirection.West;
                    break;

                case EDirection.South:
                    direction = EDirection.North;
                    break;

                case EDirection.West:
                    direction = EDirection.East;
                    break;

                case EDirection.Up:
                    direction = EDirection.Down;
                    break;

                case EDirection.Down:
                    direction = EDirection.Up;
                    break;

                default:
                    break;
                }

                Console.WriteLine($"-- You came from the {lastRoom.Name} from {direction} direction. --");
            }
            else
            {
                Console.WriteLine("You walked into a wall. Try again");
                Console.WriteLine();
            }
        }
Beispiel #2
0
        private void Initialize()
        {
            Logos.LogoGame();

            SetPlayerName();
        }