Пример #1
0
        public static string LookAt(GameObject gameObject)
        {
            string messageBoxText = "";

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

            if (gameObject is SurvivorObject)
            {
                SurvivorObject survivorObject = gameObject as SurvivorObject;

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

                if (survivorObject.CanInventory)
                {
                    messageBoxText += "can be picked up.";
                }
                else
                {
                    messageBoxText += "can not be picked up.";
                }
            }
            else
            {
                messageBoxText += $"The {gameObject.Name} cannot be picked up";
            }

            return(messageBoxText);
        }
Пример #2
0
        public static string LookAt(GameObject gameObject)
        {
            string messageBoxText = "";

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

            if (gameObject is SurvivorObject)
            {
                SurvivorObject survivorObject = gameObject as SurvivorObject;

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

                if (survivorObject.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);
        }
Пример #3
0
        private void HandleObjectUsed(object gameObject, EventArgs e)
        {
            if (gameObject.GetType() == typeof(SurvivorObject))
            {
                SurvivorObject survivorObject = gameObject as SurvivorObject;
                switch (survivorObject.Type)
                {
                case SurvivorObjectType.Food:
                    break;

                case SurvivorObjectType.Medicine:
                    break;

                case SurvivorObjectType.Tool:
                    break;

                case SurvivorObjectType.Weapon:
                    break;

                case SurvivorObjectType.Item:
                    break;

                case SurvivorObjectType.Information:
                    if (survivorObject.IsUsable)
                    {
                    }
                    break;

                default:
                    break;
                }
            }
        }
Пример #4
0
        private void FishAction()
        {
            // get location
            int location = _gameSurvivor.IslandLocationID;
            // get fish in that location, if any
            List <SurvivorObject> fishesInLocation  = new List <SurvivorObject>();
            List <GameObject>     objectsInLocation = _gameUniverse.GetGameObjectsByIslandLocationId(location);

            foreach (GameObject gameObject in objectsInLocation)
            {
                if (gameObject is SurvivorObject)
                {
                    SurvivorObject survivorObject = gameObject as SurvivorObject;
                    if (survivorObject.Type == SurvivorObjectType.Fish)
                    {
                        fishesInLocation.Add(survivorObject);
                    }
                }
            }
            // randomly chose a fish
            if (fishesInLocation.Count() != 0)
            {
                int numOfFishes = fishesInLocation.Count();
                int fishId;

                if (numOfFishes > 1)
                {
                    Random rnd = new Random();
                    fishId = rnd.Next(1, numOfFishes);
                }
                else
                {
                    fishId = 0;
                }

                SurvivorObject caughtFish = _gameUniverse.GetGameObjectById(fishesInLocation[fishId].Id) as SurvivorObject;

                //
                // note: survivor object is added to list and the island location is set to 0
                //
                _gameSurvivor.Inventory.Add(caughtFish);
                caughtFish.IslandLocationId = 0;

                //
                // update experience points, health, and lives
                //
                _gameSurvivor.ExperiencePoints += caughtFish.ExperiencePoints;
                _gameSurvivor.Health           += caughtFish.HealthPoints;
                _gameSurvivor.Lives            += caughtFish.Lives;

                //
                // display confirmation message
                //
                _gameConsoleView.DisplayConfirmSurvivorObjectAddedToInventory(caughtFish);
            }
            else if (fishesInLocation.Count() == 0)
            {
                _gameConsoleView.DisplayFishingErrorMessage();
            }
        }
Пример #5
0
 public void DisplayConfirmSurvivorObjectAddedToInventory(SurvivorObject objectAddedToInventory)
 {
     if (objectAddedToInventory.PickUpMessage != null)
     {
         DisplayGamePlayScreen("Pick up game item", objectAddedToInventory.PickUpMessage, ActionMenu.ObjectMenu, "");
     }
     else
     {
         DisplayGamePlayScreen("Pick up game item", $"The {objectAddedToInventory.Name} has been added to your inventory", ActionMenu.ObjectMenu, "");
     }
 }
Пример #6
0
        public SurvivorObject ScavengeForObjects(List <SurvivorObject> scavengerObjects)
        {
            scavengerObjects = new List <SurvivorObject>();
            SurvivorObject foundObject       = new SurvivorObject();
            Random         rnd               = new Random();
            int            scavengerObjectId = rnd.Next(1, scavengerObjects.Count);

            foundObject = scavengerObjects[scavengerObjectId];
            //foundObject.IslandLocationId = 0;

            return(foundObject);
        }
Пример #7
0
        public static string GameObjectsChooseList(IEnumerable <GameObject> gameObjects)
        {
            //
            // display table name and column headers
            //
            string messageBoxText =
                "Game Objects\n" +
                "\n" +

                //
                // display table header
                //
                "ID".PadRight(10) +
                "Name".PadRight(30) + "\n" +
                "---".PadRight(10) +
                "----------------------".PadRight(30) + "\n";

            //
            // display all traveler objects in rows
            //
            string gameObjectRows = null;

            foreach (GameObject gameObject in gameObjects)
            {
                // check if item is a survivor object
                // check if survivor object is visible
                // if it is visible, display it
                if (gameObject is SurvivorObject)
                {
                    SurvivorObject survivorObject = gameObject as SurvivorObject;

                    if (survivorObject.IsVisible == true)
                    {
                        gameObjectRows +=
                            $"{survivorObject.Id}".PadRight(10) +
                            $"{survivorObject.Name}".PadRight(30) +
                            Environment.NewLine;
                    }
                }
                else
                {
                    gameObjectRows +=
                        $"{gameObject.Id}".PadRight(10) +
                        $"{gameObject.Name}".PadRight(30) +
                        Environment.NewLine;
                }
            }

            messageBoxText += gameObjectRows;

            return(messageBoxText);
        }
Пример #8
0
        public SurvivorObject ScavengeForObjects(List <SurvivorObject> scavengerObjects)
        {
            SurvivorObject foundObject = new SurvivorObject();
            Random         rnd         = new Random();

            if (scavengerObjects.Count > 0)
            {
                int scavengerObjectId = rnd.Next(1, scavengerObjects.Count);
                foundObject = scavengerObjects[scavengerObjectId - 1];
            }

            return(foundObject);
        }
Пример #9
0
        public int DisplayGetSurvivorObjectToPickUp()
        {
            int  gameObjectId      = 0;
            bool validGameObjectId = false;

            //
            // get a list of survivor objects in the current island location
            //
            List <SurvivorObject> survivorObjectsInIslandLocation = _gameUniverse.GetSurvivorObjectsByIslandLocationId(_gameSurvivor.IslandLocationID);

            if (survivorObjectsInIslandLocation.Count > 0)
            {
                DisplayGamePlayScreen("Pick Up Game Object", Text.GameObjectsChooseList(survivorObjectsInIslandLocation), 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 current location
                    //
                    if (_gameUniverse.IsValidSurvivorObjectByLocationId(gameObjectId, _gameSurvivor.IslandLocationID))
                    {
                        SurvivorObject survivorObject = _gameUniverse.GetGameObjectById(gameObjectId) as SurvivorObject;
                        if (survivorObject.CanInventory)
                        {
                            validGameObjectId = true;
                        }
                        else
                        {
                            ClearInputBox();
                            DisplayInputErrorMessage("It appears you may not inventory that object. Please try again.");
                        }
                    }
                    else
                    {
                        ClearInputBox();
                        DisplayInputErrorMessage("It appears that you entered an invalid game object id. Please try again.");
                    }
                }
            }
            else
            {
                DisplayGamePlayScreen("Pick Up Game Object", "It appears there are no game objects here.", ActionMenu.ObjectMenu, "");
            }

            return(gameObjectId);
        }
Пример #10
0
        private void AskToScavenge()
        {
            //
            // display a list of NPCs in space-time location and get a player choice
            //
            int npcGetToScavenge = _gameConsoleView.DisplayGetNpcToAskToScavenge();

            //
            // get NPC to scavenge for an object
            // display object added to inventory
            //
            if (npcGetToScavenge != 0)
            {
                //
                // get the NPC from the universe
                //
                Animal theNpc = _gameUniverse.GetNpcById(npcGetToScavenge) as Animal;

                //
                // get found object and put it in inventory
                //
                List <SurvivorObject> objectsToScavengeFor = _gameUniverse.GetSurvivorObjectsByIslandLocationId(8);
                SurvivorObject        foundObject          = theNpc.ScavengeForObjects(objectsToScavengeFor);

                if (foundObject.IslandLocationId != 0)
                {
                    _gameConsoleView.DisplayConfirmScavengerObjectAddedToInventory(foundObject, theNpc);

                    //
                    // note: survivor object is added to list and the island location is set to 0
                    //
                    _gameSurvivor.Inventory.Add(foundObject);
                    foundObject.IslandLocationId = 0;

                    //
                    // update experience points, health, and lives
                    //
                    _gameSurvivor.ExperiencePoints += foundObject.ExperiencePoints;
                    _gameSurvivor.Health           += foundObject.HealthPoints;
                    _gameSurvivor.Lives            += foundObject.Lives;
                }
                else
                {
                    _gameConsoleView.DisplayScavengerErrorMessage(theNpc);
                }
            }
        }
Пример #11
0
        private void HandleObjectAddedToInventory(object gameObject, EventArgs e)
        {
            if (gameObject.GetType() == typeof(SurvivorObject))
            {
                SurvivorObject survivorObject = gameObject as SurvivorObject;

                _gameSurvivor.Exp += 5;

                switch (survivorObject.Type)
                {
                case SurvivorObjectType.Food:

                    _gameSurvivor.Health += survivorObject.Value;

                    //REMOVE OBJECT
                    if (survivorObject.IsConsumable)
                    {
                        survivorObject.LocationId = -1;     //-1 being used to declare it is gone
                    }
                    break;

                case SurvivorObjectType.Medicine:
                    break;

                case SurvivorObjectType.Weapon:
                    break;

                case SurvivorObjectType.Item:
                    break;

                case SurvivorObjectType.Information:
                    break;

                case SurvivorObjectType.Key:
                    _worldContents.UnlockRoom(survivorObject.RoomToUnlock);
                    break;

                case SurvivorObjectType.Tool:
                    _worldContents.RevealItem(survivorObject.ItemToReveal);
                    break;

                default:
                    break;
                }
            }
        }
Пример #12
0
        private void PutDownAction()
        {
            if (_gameSurvivor.Inventory != null)
            {
                int inventoryObjectToPutDownId = _gameConsoleView.DisplayGetInventoryObjectToPutDown();

                SurvivorObject survivorObject = _worldContents.GetGameOjbectById(inventoryObjectToPutDownId) as SurvivorObject;

                _gameSurvivor.Inventory.Remove(survivorObject);
                survivorObject.LocationId = _gameSurvivor.LocationId;

                _gameConsoleView.DisplayConfirmSurvivorObjectRemovedFromInventory(survivorObject);
            }
            else
            {
                _gameConsoleView.DisplayGamePlayScreen("Put Down Item", "You have nothing in your inventory to get rid of.", ActionMenu.ObjectMenu, "");
            }
        }
Пример #13
0
        public int DisplayGetSurvivorObjectToPickUp()
        {
            int  gameObjectId      = 0;
            bool validGameObjectId = false;

            //get list of survivor objects in current location
            List <SurvivorObject> survivorObjectsInCurrentLocation = _worldContents.GetSurvivorObjectsByLocationId(_gameSurvivor.LocationId);

            if (survivorObjectsInCurrentLocation.Count > 0)
            {
                DisplayGamePlayScreen("Pick up item", Text.GameObjectsChooseList(survivorObjectsInCurrentLocation), ActionMenu.ObjectMenu, "");

                while (!validGameObjectId)
                {
                    //get int from user
                    GetInteger($"Enter the Id number of the item you want to pick up:", 0, 0, out gameObjectId);

                    //validate integer as valid object id AND in current location
                    if (_worldContents.IsValidGameObjectByLocationId(gameObjectId, _gameSurvivor.LocationId))
                    {
                        SurvivorObject survivorObject = _worldContents.GetGameOjbectById(gameObjectId) as SurvivorObject;
                        if (survivorObject.CanInventory)
                        {
                            validGameObjectId = true;
                        }
                        else
                        {
                            ClearInputBox();
                            DisplayInputErrorMessage("You cannot pick that item up. Try again.");
                        }
                    }
                    else
                    {
                        DisplayInputErrorMessage("You entered an invalid item Id, try again.");
                    }
                }
            }
            else
            {
                DisplayGamePlayScreen("Pick up item", "There are no items here.", ActionMenu.ObjectMenu, "");
            }

            return(gameObjectId);
        }
Пример #14
0
        private void PickUpAction()
        {
            //display list of objects in current location id and get a choice
            int survivorObjectToPickUpId = _gameConsoleView.DisplayGetSurvivorObjectToPickUp();

            //add object to inventory
            if (survivorObjectToPickUpId != 0)
            {
                //get game object from world
                SurvivorObject survivorObject = _worldContents.GetGameOjbectById(survivorObjectToPickUpId) as SurvivorObject;

                //note: object added to list and location id is set to 0 - INVENTORY
                _gameSurvivor.Inventory.Add(survivorObject);
                survivorObject.LocationId = 0; // location id 0 means INVENTORY

                //display confirm message
                _gameConsoleView.DisplayConfirmSurvivorObjectAddedToInventory(survivorObject);
            }
        }
Пример #15
0
        public int DisplayGetInventoryObjectToPutDown()
        {
            int  survivorObjectId       = 0;
            bool validInventoryObjectId = false;

            if (_gameSurvivor.Inventory.Count > 0)
            {
                DisplayGamePlayScreen("Put Down Game Object", Text.GameObjectsChooseList(_gameSurvivor.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 survivorObjectId);

                    //
                    // find object in inventory
                    // note: LINQ used, but a foreach loop may also be used
                    //
                    SurvivorObject objectToPutDown = _gameSurvivor.Inventory.FirstOrDefault(o => o.Id == survivorObjectId);

                    //
                    // validate object in inventory
                    //
                    if (objectToPutDown != null)
                    {
                        validInventoryObjectId = true;
                    }
                    else
                    {
                        ClearInputBox();
                        DisplayInputErrorMessage("It appears you entered the Id of an object not in the inventory. Please try again.");
                    }
                }
            }
            else
            {
                DisplayGamePlayScreen("Pick Up Game Object", "It appears there are no objects currently in inventory.", ActionMenu.ObjectMenu, "");
            }

            return(survivorObjectId);
        }
Пример #16
0
        private void PutDownAction()
        {
            //
            // display a list of survivor objects in inventory and get a player choice
            //
            int inventoryObjectToPutDownId = _gameConsoleView.DisplayGetInventoryObjectToPutDown();

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

            //
            // remove the object from inventory and set the island location to the current value
            //
            _gameSurvivor.Inventory.Remove(survivorObject);
            survivorObject.IslandLocationId = _gameSurvivor.IslandLocationID;

            //
            // display confirmation message
            //
            _gameConsoleView.DisplayConfirmSurvivorObjectRemovedFromInventory(survivorObject);
        }
Пример #17
0
        public int DisplayGetInventoryObjectToPutDown()
        {
            int  survivorObjectId     = 0;
            bool validInventoryObject = false;

            if (_gameSurvivor.Inventory.Count > 0)
            {
                DisplayGamePlayScreen("Put Down Item", Text.GameObjectsChooseList(_gameSurvivor.Inventory), ActionMenu.ObjectMenu, "");

                while (!validInventoryObject)
                {
                    //get integer from user
                    GetInteger($"Enter the Id number of the item you want to put down: ", 0, 0, out survivorObjectId);

                    //find object in inventory
                    //note: LINQ used, but foreach loop may also be used
                    SurvivorObject objectToPutDown = _gameSurvivor.Inventory.FirstOrDefault(o => o.Id == survivorObjectId);

                    //validate object is in inventory
                    if (objectToPutDown != null)
                    {
                        validInventoryObject = true;
                    }
                    else
                    {
                        ClearInputBox();
                        DisplayInputErrorMessage("It appears you entered an Id that is not in your inventory. Try again.");
                    }
                }
            }
            else
            {
                DisplayGamePlayScreen("Put Down Item", "You have nothing in your inventory.", ActionMenu.ObjectMenu, "");
            }

            return(survivorObjectId);
        }
Пример #18
0
        private void PickUpAction()
        {
            //
            // display a list of survivor object in island location and get a player choice
            //
            int survivorObjectToPickUpId = _gameConsoleView.DisplayGetSurvivorObjectToPickUp();

            //
            // add the survivor object to survivor's inventory
            //
            if (survivorObjectToPickUpId != 0)
            {
                //
                // get the game object from the universe
                //
                SurvivorObject survivorObject = _gameUniverse.GetGameObjectById(survivorObjectToPickUpId) as SurvivorObject;

                //
                // note: survivor object is added to list and the island location is set to 0
                //
                _gameSurvivor.Inventory.Add(survivorObject);
                survivorObject.IslandLocationId = 0;

                //
                // update experience points, health, and lives
                //
                _gameSurvivor.ExperiencePoints += survivorObject.ExperiencePoints;
                _gameSurvivor.Health           += survivorObject.HealthPoints;
                _gameSurvivor.Lives            += survivorObject.Lives;

                //
                // display confirmation message
                //
                _gameConsoleView.DisplayConfirmSurvivorObjectAddedToInventory(survivorObject);
            }
        }
Пример #19
0
 public void DisplayConfirmSurvivorObjectRemovedFromInventory(SurvivorObject objectRemovedFromInventory)
 {
     DisplayGamePlayScreen("Put Down Game Object", $"The {objectRemovedFromInventory.Name} has been removed from your inventory.", ActionMenu.ObjectMenu, "");
 }
Пример #20
0
 public void DisplayConfirmScavengerObjectAddedToInventory(SurvivorObject objectAddedToInventory, Animal theAnimal)
 {
     DisplayGamePlayScreen("Choose Character to Ask to Scavenge", $"{theAnimal.Name} has scavenged for you and has brought back {objectAddedToInventory.Name}. It has been added to your inventory.", ActionMenu.NpcMenu, "");
 }
Пример #21
0
 public void DisplayConfirmSurvivorObjectAddedToInventory(SurvivorObject objectAddedToInventory)
 {
     DisplayGamePlayScreen("Pick Up Game Object", $"The {objectAddedToInventory.Name} has been added to your inventory.", ActionMenu.ObjectMenu, "");
 }
Пример #22
0
 public void DisplayConfirmSurvivorObjectRemovedFromInventory(SurvivorObject objectToPutDown)
 {
     DisplayGamePlayScreen("Put Down Item", $"The {objectToPutDown.Name} has been removed.", ActionMenu.ObjectMenu, "");
 }