Beispiel #1
0
        /// <summary>
        /// display information about an inanimate object
        /// </summary>
        /// <param name="gameObject"></param>
        /// <returns>string</returns>
        public static string LookAt(GameObject gameObject)
        {
            string messageBoxText = "";

            messageBoxText =
                $"{gameObject.Name}\n" +
                " \n " +
                gameObject.Description + " \n" +
                " \n";

            if (gameObject is InanimateObject)
            {
                InanimateObject inanimateObject = gameObject as InanimateObject;

                messageBoxText += $"The {inanimateObject.Name} has a value of {inanimateObject.Value} and ";

                if (inanimateObject.CanInventory)
                {
                    messageBoxText += "may be added to your inventory.";
                }
                else
                {
                    messageBoxText += "may not be added to your inventory.";
                }
            }
            else
            {
                messageBoxText += $"The {gameObject.Name} may not be added to your inventory.";
            }

            return(messageBoxText);
        }
Beispiel #2
0
        /// <summary>
        /// method called by the ObjectAddedToInventory event
        /// </summary>
        /// <param name="gameObject"></param>
        /// <param name="e"></param>
        private void HandleObjectAddedToInventory(object gameObject, EventArgs e)
        {
            if (gameObject.GetType() == typeof(InanimateObject))
            {
                InanimateObject inanimateObject = gameObject as InanimateObject;
                switch (inanimateObject.InanimateObjType)
                {
                case InanimateObjectType.Food:
                    break;

                case InanimateObjectType.Medicine:
                    break;

                case InanimateObjectType.Weapon:
                    break;

                case InanimateObjectType.Treasure:
                    break;

                case InanimateObjectType.Information:
                    break;

                default:
                    break;
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// display a list of inanimate objects in the location and get a choice
        /// </summary>
        private void UseObjectAction()
        {
            //
            // display a list of inanimate objects in the location and the player's inventory and get a choice
            //
            int inanimateObjectToUseId = _gameConsoleView.DisplayGetInanimateObjectToUse();

            //
            // use the inanimate object
            //
            if (inanimateObjectToUseId != 0)
            {
                //
                // get the game object from the universe
                //
                InanimateObject inanimateObject = _gameUniverse.GetGameObjectById(inanimateObjectToUseId) as InanimateObject;

                if (inanimateObject.EffectiveLocations.Contains(0) || inanimateObject.EffectiveLocations.Contains(_currentLocation.LocationID))
                {
                    //
                    // note: inanimate object usage count is decremented
                    //
                    inanimateObject.UseCount--;
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// display a list of inanimate objects in the location and get a choice
        /// </summary>
        private void PickUpAction()
        {
            //
            // display a list of inanimate objects in the location and get a choice
            //
            int inanimateObjectToPickUpId = _gameConsoleView.DisplayGetInanimateObjectToPickUp();

            //
            // add the inanimate object to player's inventory
            //
            if (inanimateObjectToPickUpId != 0)
            {
                //
                // get the game object from the universe
                //
                InanimateObject inanimateObject = _gameUniverse.GetGameObjectById(inanimateObjectToPickUpId) as InanimateObject;

                //
                // note: inanimate object is added to the list and the location is set to 0
                //
                inanimateObject.LocationID = 0;

                //
                // display confirmation message
                //
                _gameConsoleView.DisplayConfirmInanimateObjectAddedToInventory(inanimateObject);
            }
        }
Beispiel #5
0
        /// <summary>
        /// display a message confirming that an object was used
        /// </summary>
        /// <param name="objectUsed"></param>
        public void DisplayConfirmInanimateObjectUsed(InanimateObject objectUsed)
        {
            string msg = (objectUsed.PickUpMessage ?? $"The {objectUsed.Name} has been used.  " +
                          "Press any key to continue.");

            DisplayGamePlayScreen("Use Game Object", msg, ActionMenu.ObjectMenu, "");

            Console.ReadKey();

            DisplayGamePlayScreen("Object Menu", "Select an action from the menu", ActionMenu.ObjectMenu, "");
        }
Beispiel #6
0
        /// <summary>
        /// show the inanimate objects in the player's inventory and get a choice
        /// </summary>
        /// <returns>int</returns>
        public int DisplayGetInventoryObjectToPutDown()
        {
            int  inanimateObjectId           = 0;
            bool validInventoryObjectId      = false;
            List <InanimateObject> inventory = _gameUniverse.GetInanimateObjectsByLocationId(0);

            if (inventory.Count > 0)
            {
                DisplayGamePlayScreen("Put Down Game Object", Text.GameObjectsChooseList(inventory), ActionMenu.ObjectMenu, "");

                while (!validInventoryObjectId)
                {
                    //
                    // get an integer from the player
                    //
                    GetInteger($"Enter the ID number of the object you wish to remove from your inventory: ", 0, 0, out inanimateObjectId);

                    //
                    // find object in inventory
                    //
                    InanimateObject objectToPutDown = inventory.FirstOrDefault(o => o.ObjectID == inanimateObjectId);

                    //
                    // validate object in inventory
                    //
                    if (objectToPutDown != null)
                    {
                        validInventoryObjectId = true;
                    }
                    else
                    {
                        ClearInputBox();

                        DisplayInputErrorMessage("It appears you entered the ID of an object that is not in inventory.  Please try again.");
                    }
                }
            }
            else
            {
                DisplayGamePlayScreen("Put Down Game Object", "It appears there are no objects currently in inventory.", ActionMenu.ObjectMenu, "");
            }

            return(inanimateObjectId);
        }
Beispiel #7
0
        /// <summary>
        /// display a list of inanimate objects in inventory and get a player choice
        /// </summary>
        private void PutDownAction()
        {
            //
            // display a list of inanimate objects in inventory and get a player choice
            //
            int inventoryObjectToPutDownId = _gameConsoleView.DisplayGetInventoryObjectToPutDown();

            //
            // get the game object from the universe
            //
            InanimateObject inanimateObject = _gameUniverse.GetGameObjectById(inventoryObjectToPutDownId) as InanimateObject;

            //
            // remove the object from inventory and set the space-time location to the current value
            //
            inanimateObject.LocationID = _gamePlayer.LocationID;

            //
            // display confirmation message
            //
            _gameConsoleView.DisplayConfirmInanimateObjectRemovedFromInventory(inanimateObject);
        }
Beispiel #8
0
        /// <summary>
        /// show the inanimate objects in the current location and get a choice
        /// </summary>
        /// <returns>int</returns>
        public int DisplayGetInanimateObjectToUse()
        {
            int  gameObjectId      = 0;
            bool validGameObjectId = false;

            //
            // get a list of inanimate objects in the current location
            //
            List <InanimateObject> currentInanimateObjects     = _gameUniverse.GetInanimateObjectsByLocationId(_gamePlayer.LocationID);
            List <InanimateObject> inanimateObjectsInInventory = _gameUniverse.PlayerInventory();

            currentInanimateObjects.AddRange(inanimateObjectsInInventory);

            //
            // remove inanimate objects that cannot be used
            //
            currentInanimateObjects.RemoveAll(inanimateObject => !inanimateObject.IsUsable);

            currentInanimateObjects.RemoveAll(inanimateObject => (inanimateObject.CanInventory && inanimateObject.LocationID != 0));

            if (currentInanimateObjects.Count > 0)
            {
                List <InanimateObject> sortedInanimateObjectList = currentInanimateObjects.OrderBy(x => x.Name).ToList();

                DisplayGamePlayScreen("Use Game Object", Text.GameObjectsUseList(sortedInanimateObjectList), ActionMenu.ObjectMenu, "");

                while (!validGameObjectId)
                {
                    //
                    // get an integer from the player
                    //
                    GetInteger($"Enter the ID number of the object you wish to use: ", 0, 0, out gameObjectId);

                    //
                    // validate integer as a valid game object ID and in the current location
                    //
                    if (_gameUniverse.IsValidInanimateObjectByPlayerLocationId(gameObjectId, _gamePlayer.LocationID))
                    {
                        InanimateObject inanimateObject = _gameUniverse.GetGameObjectById(gameObjectId) as InanimateObject;
                        if (inanimateObject.IsUsable)
                        {
                            if (!inanimateObject.EffectiveLocations.Contains(0) & !inanimateObject.EffectiveLocations.Contains(_gamePlayer.LocationID))
                            {
                                ClearInputBox();
                                DisplayGamePlayScreen("Use Game Object", "This item is not effective here.  Try using it somewhere else.", ActionMenu.ObjectMenu, "");
                                // DisplayInputErrorMessage("This item is not effective here.  Try using it somewhere else.");
                            }
                            validGameObjectId = true;
                        }
                        else
                        {
                            ClearInputBox();

                            DisplayInputErrorMessage("It appears you may not use that object.  Please try again.");
                        }
                    }
                    else
                    {
                        ClearInputBox();

                        DisplayInputErrorMessage("It appears you entered an invalid game object ID.  Please try again.");
                    }
                }
            }
            else
            {
                DisplayGamePlayScreen("Use Game Object", "It appears there are no objects to use here.", ActionMenu.ObjectMenu, "");
            }

            return(gameObjectId);
        }
Beispiel #9
0
 /// <summary>
 /// show a message confirming that an object has been removed from inventory
 /// </summary>
 /// <param name="objectRemovedFromInventory"></param>
 public void DisplayConfirmInanimateObjectRemovedFromInventory(InanimateObject objectRemovedFromInventory)
 {
     DisplayGamePlayScreen("Put Down Game Object", $"The {objectRemovedFromInventory.Name} has been removed from your inventory.", ActionMenu.ObjectMenu, "");
 }
Beispiel #10
0
        /// <summary>
        /// display a message confirming that an object was added to the player's inventory
        /// </summary>
        /// <param name="objectAddedToInventory"></param>
        public void DisplayConfirmInanimateObjectAddedToInventory(InanimateObject objectAddedToInventory)
        {
            string msg = (objectAddedToInventory.PickUpMessage ?? $"The {objectAddedToInventory.Name} has been added to your inventory.");

            DisplayGamePlayScreen("Pick Up Game Object", msg, ActionMenu.ObjectMenu, "");
        }
Beispiel #11
0
        /// <summary>
        /// show the inanimate objects in the current location and get a choice
        /// </summary>
        /// <returns>int</returns>
        public int DisplayGetInanimateObjectToPickUp()
        {
            int  gameObjectId      = 0;
            bool validGameObjectId = false;

            //
            // get a list of inanimate objects in the current location
            //
            List <InanimateObject> inanimateObjectsInLocation = _gameUniverse.GetInanimateObjectsByLocationId(_gamePlayer.LocationID);

            foreach (InanimateObject inanimateObject in inanimateObjectsInLocation.ToList())
            {
                if (!inanimateObject.CanInventory)
                {
                    inanimateObjectsInLocation.Remove(inanimateObject);
                }
            }

            if (inanimateObjectsInLocation.Count > 0)
            {
                DisplayGamePlayScreen("Pick Up Game Object", Text.GameObjectsChooseList(inanimateObjectsInLocation), ActionMenu.ObjectMenu, "");

                while (!validGameObjectId)
                {
                    //
                    // get an integer from the player
                    //
                    GetInteger($"Enter the ID number of the object you wish to add to your inventory: ", 0, 0, out gameObjectId);

                    //
                    // validate integer as a valid game object ID and in the current location
                    //
                    if (_gameUniverse.IsValidInanimateObjectByLocationId(gameObjectId, _gamePlayer.LocationID))
                    {
                        InanimateObject inanimateObject = _gameUniverse.GetGameObjectById(gameObjectId) as InanimateObject;
                        if (inanimateObject.CanInventory)
                        {
                            validGameObjectId = true;
                        }
                        else
                        {
                            ClearInputBox();

                            DisplayInputErrorMessage("It appears you may not inventory that object.  Please try again.");
                        }
                    }
                    else
                    {
                        ClearInputBox();

                        DisplayInputErrorMessage("It appears you entered an invalid game object ID.  Please try again.");
                    }
                }
            }
            else
            {
                DisplayGamePlayScreen("Pick Up Game Object", "It appears there are no game objects that can be picked up here.", ActionMenu.ObjectMenu, "");
            }

            return(gameObjectId);
        }
Beispiel #12
0
        /// <summary>
        /// a bad pun and a necessary evil to manage the usage of specific items in specific situations
        /// </summary>
        /// <param name="inanimateObject"></param>
        private void SpecialUseCases(InanimateObject inanimateObject)
        {
            NPC    npc;
            string message;

            switch (inanimateObject.ObjectID)
            {
            // magic wand
            case 23:

                message = "After a few moments of wildly flailing your arm around, you get bored and stop waving your wand.";

                _gameConsoleView.DisplayGamePlayScreen("Use Game Object", message, ActionMenu.ObjectMenu, "");

                break;

            // Professor Pluperfect's Primer Promoting Practical Panic
            case 24:
                switch (_currentLocation.LocationID)
                {
                case 18:
                    message = "If only you had studied this primer more earnestly when you had the chance.  Now, you're " +
                              "better off using it to prop up a couch that has a broken leg, and there don't appear to be many " +
                              "of those lying around here.";
                    break;

                default:

                    message = $"Wizards wield great power.  They can bend the laws of the universe to their will and alter " +
                              "reality itself.  Regrettably, and much to the detriment of many a wizard, a power that is often " +
                              "overlooked is the power to panic.  Knowing how and when to panic is one of the most important  " +
                              "skills a wizard can possess.  So, when is the right time to panic?  Every wizard knows that there " +
                              "is never a wrong time to panic.  But, the best wizards know that the best way to panic depends on " +
                              "circumstance.  As Volume 1 in Sage Susurrant's Sorceror Survival Series, Professor Pluperfect's " +
                              "Primer Promoting Practical Panic aims to ground wizards in the basic methods of panicking and " +
                              "how to determine the best method of panicking for most common situations.  Let's begin with one " +
                              "of the most difficult, and yet, universally useful, methods for panicking -- playing dead while " +
                              "running away screaming.  The most important thing to know about this method is...   ";
                    break;
                }
                _gameConsoleView.DisplayGamePlayScreen("Use Game Object", message, ActionMenu.ObjectMenu, "");
                break;

            // Portable Hole
            case 25:

                switch (_currentLocation.LocationID)
                {
                case 4:
                    npc = _gameUniverse.GetNpcById(1);

                    if (npc.LocationID == _currentLocation.LocationID)
                    {
                        if (inanimateObject.LocationID == 0)
                        {
                            inanimateObject.LocationID = _currentLocation.LocationID;

                            message = $"Pulling the portable hole out of your pocket, you throw it at the {npc.Name}.  " +
                                      $"But, the {npc.Name} casually steps to the side, dodging the portable hole which falls to the ground.  " +
                                      $"You will have to find some other way to defeat the {npc.Name}";

                            _gameConsoleView.DisplayGamePlayScreen("Use Game Object", message, ActionMenu.ObjectMenu, "");
                        }
                        else
                        {
                            message = $"The portable hole must be in your inventory before you can use it.";

                            _gameConsoleView.DisplayGamePlayScreen("Use Game Object", message, ActionMenu.ObjectMenu, "");
                        }
                        // UpdateLocation();
                    }
                    break;

                case 17:

                    Location specailLocation = _gameUniverse.GetLocationByLocationID(18);
                    specailLocation.IsAccessible = true;

                    _currentLocation.Description = $"You toss the portable hole into the lake of acid.  It appears that the acid " +
                                                   "is dissolving the hole as the hole sinks.  Then you notice that the acid appears to be pouring into the hole.  " +
                                                   "After an hour, a vortex appears in the lake where the portable hole is resting.  After a few more hours, the " +
                                                   "last of the lake of acid disappears into the portable hole.  Only a few shallow puddles remain.  The path to " +
                                                   "the island and what lies beyond is now open to you.  You carefully retrieve the portable hole.";

                    UpdateLocation();

                    _currentLocation.Description = "You stand in the large clearing where the lake of acid used to be.  " +
                                                   "A stillness still permeates this place but it is no longer ominous.  With the lake gone, a large ring of " +
                                                   "white sand, which takes on a slight pink hue in certain angles of view, surrounds a small grass mound.  " +
                                                   "In the middle of this mound, a stairway descends into the ground.";

                    _currentLocation.GeneralContents = "With the lake of acid gone, this area is rather pleasant.  " +
                                                       "You briefly consider the possibility of building a home here, then you notice that " +
                                                       "red acid is slowly seeping up from the ground.  You don't have time to determine whether it's " +
                                                       "the result of a natural spring or magic.";
                    break;

                case 18:

                    inanimateObject.LocationID = -1;

                    message = $"You throw the portable hole at the dragon.  A gust of wind catches it " +
                              "and lifts it up into the air, before gently depositing it on the dragon's left horn.  I'm not sure " +
                              "what you thought that would accomplish.  The portable hole is small and there's not even a chance " +
                              "that the dragon could put a foot in the hole and sprain its ankle.  Even so, you managed to " +
                              "momentarily distract the dragon, prolonging countless lives by an extra 5 seconds, you hero.  " +
                              "Got any other ideas?";

                    _gameConsoleView.DisplayGamePlayScreen("Use Game Object", message, ActionMenu.ObjectMenu, "");

                    _currentLocation.GeneralContents = "Having one horn hidden by the portable hole doesn't diminish the " +
                                                       "dragon's fearsomeness or the sense of your impending doom.";

                    //UpdateLocation();

                    _itsTheFinalCountdown = 3;

                    break;

                default:
                    break;
                }
                break;

            // Polymorph Potion
            case 26:
                switch (_currentLocation.LocationID)
                {
                case 4:
                    npc = _gameUniverse.GetNpcById(1);

                    inanimateObject.LocationID = -1;

                    _currentLocation.Description = $"With a clever bit of misdirection, you furtively draw out the polymorph potion " +
                                                   $"and cast it at the {npc.Name}.  The potion bottle strikes the {npc.Name} and shatters.  The {npc.Name} " +
                                                   "is transformed into a menu.";

                    _currentLocation.GeneralContents = "In front of you stands the Long Wall, measuring 15 feet high and hundreds of miles long.  But, your path does not end here.  " +
                                                       "It continues through an opening in the wall, beyond which lies the Magic Hedge Maze.  In front of the opening, a menu blocks " +
                                                       "your path.  The menu looks determined to stay there.  You could use magic to scale the Wall but the need to enforce a narrative prevents " +
                                                       "you from doing so.  You will have to find a way through the opening.";

                    UpdateLocation();

                    _currentLocation.Description = "You have traveled many weeks and faced many trials to get here.  You crossed the Pits of Evil Fire.  " +
                                                   "Then, you crossed the Evil Pits of Fire.  You out-styled Cliff the Conjurer in a bare-knuckled contest of coiffure-mancy.  " +
                                                   "You scaled the Cliffs (no relation) of Modest Scalability.  You perservered through Hodeg's " +
                                                   "Valley of Cute Puppies and Cuddly Kittens.  You survived the interminable boredom " +
                                                   "of the Featureless Plains.  You waded through the Swamp of the Indifferent Gators.  " +
                                                   "You cavorted across the sea on a pirate party cruise.  You braved the many perils of the Perilous Path.  " +
                                                   "You bested Cludar the Fleet-Footed in an Indecision Dance-off.  You did some other stuff too.  And, finally, you " +
                                                   "have reached a wall.";

                    inanimateObject.ItemUseMessage = "This appears to have no use here.";

                    break;

                default:
                    break;
                }
                break;

            // Teleportation Ring
            case 27:
                TeleportPlayer();
                break;

            //Marble Statue
            case 30:
                _currentLocation.Description = "On a hunch, you try to move the statue and discover that it rotates on the " +
                                               "pedestal.  You turn the statue so that it points to the opening where the basset hound is sitting.  With " +
                                               "a wink, the basset hound says \"You found the exit\".  Exuding an aura of arcane energy more powerful than " +
                                               "anything you have ever witnessed, the basset hound vanishes as purple lightning arcs out from the place he " +
                                               "stood.  The way is now open to you.";

                inanimateObject.IsUsable = false;

                UpdateLocation();

                _currentLocation.Description = "In the middle of this room, a marble statue stands on a pedestal.  " +
                                               "There is an opening in the south wall of the room, beyond which lies a dull, red lake.";

                _currentLocation.GeneralContents = "The statue, a life-size figure of a robed woman, points to the " +
                                                   "opening in the south wall of the room.  A plaque at the base of the statue that reads \"This way to " +
                                                   "the exit\".";

                npc = _gameUniverse.GetNpcById(5);

                npc.LocationID = -1;

                Location location = _gameUniverse.GetLocationById(17);

                location.IsAccessible = true;

                break;

            default:
                break;
            }
        }
Beispiel #13
0
        /// <summary>
        /// decrement an InanimateObject's number of uses if it is usable and has multiple uses
        /// </summary>
        /// <param name="inanimateObject"></param>
        /// <returns>int</returns>
        private int CalculateNumberOfUses(InanimateObject inanimateObject)
        {
            int numberOfUses = (inanimateObject.IsUsable && inanimateObject.UseCount > 0 ? inanimateObject.UseCount - 1 : inanimateObject.UseCount);

            return(numberOfUses);
        }
Beispiel #14
0
        /// <summary>
        /// method called by the ObjectUsed event
        /// </summary>
        /// <param name="gameObject"></param>
        /// <param name="e"></param>
        private void HandleObjectUsed(object gameObject, EventArgs e)
        {
            string message;

            if (gameObject.GetType() == typeof(InanimateObject))
            {
                InanimateObject inanimateObject = gameObject as InanimateObject;

                if (inanimateObject.IsUsable)
                {
                    if ((inanimateObject.CanInventory && inanimateObject.LocationID == 0) || !inanimateObject.CanInventory)
                    {
                        switch (inanimateObject.InanimateObjType)
                        {
                        case InanimateObjectType.Food:
                            break;

                        case InanimateObjectType.Medicine:

                            _gamePlayer.Health += inanimateObject.Value;

                            break;

                        case InanimateObjectType.Weapon:
                            break;

                        case InanimateObjectType.Treasure:
                            break;

                        case InanimateObjectType.Information:
                            break;

                        default:
                            break;
                        }

                        //
                        // recalculate number of uses
                        //
                        inanimateObject.UseCount += (inanimateObject.IsUsable && inanimateObject.UseCount > 0 ? -1 : 0);

                        //
                        // remove object from the game if it is consumable and has 0 uses remaining
                        //
                        inanimateObject.LocationID = (inanimateObject.IsConsumable && inanimateObject.UseCount == 0 ? -1 : inanimateObject.LocationID);

                        if (inanimateObject.LocationID == -1)
                        {
                            _gameConsoleView.DisplayConfirmInanimateObjectRemovedFromInventory(inanimateObject);
                        }

                        //
                        // display confirmation message
                        //
                        _gameConsoleView.DisplayConfirmInanimateObjectUsed(inanimateObject);

                        SpecialUseCases(inanimateObject);
                    }
                    else
                    {
                        message = $"The {inanimateObject.Name} must be in your inventory before you can use it.";

                        _gameConsoleView.DisplayGamePlayScreen("Use Game Object", message, ActionMenu.ObjectMenu, "");
                    }
                }
            }
        }