示例#1
0
        public void UseTransporter(string item1, Player name, Location location)
        {                                                                 //changing locations like this doesn't trigger the search the room for an enemy function. it needs to.
            string LeavingLocation = location.LocationToString(location); //change Location into string

            Console.WriteLine("Please type the name of the location you would like to move to exactly as you see it below:");
            name.TransporterMove(name, LeavingLocation); //list the locations available to me by name
            string NewLocation = Console.ReadLine();

            if (NewLocation != "disused kitchen" && NewLocation != "old laboritory" && NewLocation != "medical room" && NewLocation != "sunken courtyard" && NewLocation != "dormitory")
            {
                Console.WriteLine("That location doesn't exist");
            }
            else
            {
                switch (NewLocation)
                {
                case "disused kitchen":
                    Location MoveTo         = name.FindLocation("disused kitchen");
                    bool     IsThereAnEnemy = MoveTo.IsThereAnEnemy(MoveTo);
                    FightLogic.IfEnemyFound(name, location, MoveTo, IsThereAnEnemy);
                    break;

                case "old laboritory":
                    Location MoveTo1         = name.FindLocation("old laboritory");
                    bool     IsThereAnEnemy1 = MoveTo1.IsThereAnEnemy(MoveTo1);
                    FightLogic.IfEnemyFound(name, location, MoveTo1, IsThereAnEnemy1);
                    break;

                case "medical room":
                    Location MoveTo2         = name.FindLocation("medical room");
                    bool     IsThereAnEnemy2 = MoveTo2.IsThereAnEnemy(MoveTo2);
                    FightLogic.IfEnemyFound(name, location, MoveTo2, IsThereAnEnemy2);
                    break;

                case "sunken courtyard":
                    Location MoveTo3         = name.FindLocation("sunken courtyard");
                    bool     IsThereAnEnemy3 = MoveTo3.IsThereAnEnemy(MoveTo3);
                    FightLogic.IfEnemyFound(name, location, MoveTo3, IsThereAnEnemy3);
                    break;

                case "dormitory":
                    Location MoveTo4         = name.FindLocation("dormitory");
                    bool     IsThereAnEnemy4 = MoveTo4.IsThereAnEnemy(MoveTo4);
                    FightLogic.IfEnemyFound(name, location, MoveTo4, IsThereAnEnemy4);
                    break;
                }
                Items Item2 = name.FindPlayerItem(item1, name);
                //need to remove from player items
                name.PlayerItems.Remove(Item2);
            }
        }
示例#2
0
        public void LocationLogic(Player name, Location location)
        {
            Location   currentLocation = location;
            FightLogic FightLogic      = new FightLogic();
            Game       Game            = new Game();
            TicTacToe  TicTacToe       = new TicTacToe();
            Actions    Actions         = new Actions();



            while (true)
            {
                string Action = Console.ReadLine();

                switch (Action)
                {
                case "1":     //look around
                    Console.WriteLine("You can see the following items");
                    location.ViewLocationItems(location);
                    Game.PlayerPrompt();
                    break;

                case "2":     //search an item
                    Console.WriteLine("Please type the name of the Item would you like to search exactly as you see it in the list");
                    string ItemSearch  = Console.ReadLine();
                    Items  ItemSearch2 = location.FindLocationItem(ItemSearch, location);
                    if (ItemSearch2 == null)
                    {
                    }
                    else
                    {
                        location.ItemDescription(ItemSearch);
                    }
                    Game.PlayerPrompt();
                    break;

                case "3":     //pick up an item
                    Console.WriteLine("Please type the name of the Item would you like to pick up exactly as you see it in the list");
                    string ItemKeep  = Console.ReadLine();
                    Items  ItemKeep2 = location.FindLocationItem(ItemKeep, location);
                    if (ItemKeep2 != null)
                    {
                        name.PlayerPickUpItem(ItemKeep2, location, ItemKeep2.CanPickUp);
                    }
                    Game.PlayerPrompt();
                    break;

                case "4":     //use an item
                    name.ViewPlayerItems();
                    if (name.PlayerItems.Count >= 1)
                    {
                        Console.WriteLine("Please type the name of the Item would you like to use");
                        string Item1       = Console.ReadLine();
                        bool   Item1Result = name.DoesPlayerHaveItem(Item1);   // check player has item

                        if (Item1Result)
                        {
                            Items ItemToUse = name.FindPlayerItem(Item1, name);
                            if (ItemToUse.GetItemAction() == "This item does nothing")
                            {
                                Console.WriteLine("Unlucky, that item does absolutely nothing");
                                name.PlayerItems.Remove(ItemToUse);
                                Game.PlayerPrompt();
                            }
                            else
                            {
                                Actions.UseItem(Item1, name, location);
                                Game.PlayerPrompt();
                            }
                        }
                        if (!Item1Result)
                        {
                            Console.WriteLine("You have not picked up that item");
                            Game.PlayerPrompt();
                        }
                    }
                    else
                    {
                        Game.PlayerPrompt();
                    }

                    break;

                case "5":     //view my items
                    name.ViewPlayerItems();
                    Game.PlayerPrompt();
                    break;

                case "6":                                                                          //change location
                    name.ViewLocationOptions(location);                                            //list possible locations as doors
                    string LeavingLocation = location.LocationToString(location);
                    string NewLocation     = Console.ReadLine();                                   //ask for door to go through
                    string NewLocation2    = location.DoorDirection(NewLocation, LeavingLocation); //convert door to location string
                    if (NewLocation2 == null)
                    {
                        Console.WriteLine("That location does not exist, did you type it in the format 'Door 1'?");
                        Game.PlayerPrompt();
                    }
                    else
                    {
                        Location NewLocation3 = name.FindLocation(NewLocation2); //convert location string into Location
                        currentLocation = NewLocation3;                          //set currentLocation to the new location name.
                        NewLocation3.WhereAmI(NewLocation3);

                        //move to fight sequences here if there is an enemy in the new location.
                        bool IsThereAnEnemy = NewLocation3.IsThereAnEnemy(NewLocation3);

                        FightLogic.IfEnemyFound(name, location, NewLocation3, IsThereAnEnemy);
                    }
                    break;

                default:
                    Console.WriteLine("Please enter a number between 1 and 6");
                    break;
                }
            }
        }