コード例 #1
0
        private void PickUpAction()
        {
            //
            //Display list of traveler objects in location
            //
            int travelerObjectToPickUpId = _gameConsoleView.DisplayGetTravlerObjectToPickUp();

            //
            //add to inventory
            //
            if (travelerObjectToPickUpId != 0)
            {
                //
                //get game object from universe
                //
                TravelerObject travelerObject = _gameShip.GetGameObjectById(travelerObjectToPickUpId) as TravelerObject;

                //
                //set object location to 0
                //
                _gameTraveler.Inventory.Add(travelerObject);
                travelerObject.LocationId = 0;

                //
                //confirm
                //
                _gameConsoleView.DisplayConfirmTravelerObjectAddedToInventory(travelerObject);
            }
        }
コード例 #2
0
ファイル: Text.cs プロジェクト: mcadam5/FinalTitanicGame
        public static string LookAt(GameObject gameObject)
        {
            string messageBoxText = "";

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

            if (gameObject is TravelerObject)
            {
                TravelerObject travelerObject = gameObject as TravelerObject;

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

                if (travelerObject.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
 public void DisplayConfirmTravelerObjectAddedToInventory(TravelerObject objectAddedToInventory)
 {
     if (objectAddedToInventory.PickUpMessage != null)
     {
         DisplayGamePlayScreen("Pick Up Game Object", objectAddedToInventory.PickUpMessage, ActionMenu.ObjectMenu, "");
     }
     else
     {
         DisplayGamePlayScreen("Pick Up Game Object", $"The {objectAddedToInventory.Name} has been added to your inventory.", ActionMenu.ObjectMenu, "");
     }
 }
コード例 #4
0
        public int DisplayGetTravlerObjectToPickUp()
        {
            int  gameObjectId      = 0;
            bool vaildGameObjectId = false;

            //
            //list of traveler objects in current location
            //

            List <TravelerObject> travelerObjectsInLocation = _gameShip.GetTravelerObjectsByLocationId(_gameTraveler.LocationID);

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

                while (!vaildGameObjectId)
                {
                    //
                    //get ineger from player
                    //
                    GetInteger($"Enter the Id number of the object you wish to add to your inventory:", 1, 12, out gameObjectId);

                    //
                    //vailidate integer
                    //
                    if (_gameShip.IsValidTravelerObjectByLocationId(gameObjectId, _gameTraveler.LocationID))
                    {
                        TravelerObject travelerObject = _gameShip.GetGameObjectById(gameObjectId) as TravelerObject;
                        if (travelerObject.CanInventory)
                        {
                            vaildGameObjectId = true;
                        }
                        else
                        {
                            ClearInputBox();
                            DisplayInputErrorMessage("It appears you cannot currently add this item to your inventory.");
                        }
                    }
                    else
                    {
                        ClearInputBox();
                        DisplayInputErrorMessage("It appears you have entered an invaild game object id. Please try again.");
                    }
                }
            }
            else
            {
                DisplayGamePlayScreen("Pick Up Game Object", "It appears there are no available game objects.", ActionMenu.ObjectMenu, "");
            }

            return(gameObjectId);
        }
コード例 #5
0
        public int DisplayGetInventoryObjectToPutDown()
        {
            int  travelerObjectId       = 0;
            bool validInventoryObjectId = false;

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

                while (!validInventoryObjectId)
                {
                    //
                    //get int from user
                    //
                    GetInteger($"Enter the Id number of the object you would like to drop from inventory.", 1, 12, out travelerObjectId);

                    //
                    //find object
                    //
                    TravelerObject objectToPutDown = _gameTraveler.Inventory.FirstOrDefault(o => o.Id == travelerObjectId);

                    //
                    //validate object in inventory
                    //
                    if (objectToPutDown != null)
                    {
                        validInventoryObjectId = true;
                    }
                    else
                    {
                        ClearInputBox();
                        DisplayInputErrorMessage("It appears your inventory does not contain this object. please try again");

                        //return to main menu
                    }
                }
            }
            else
            {
                DisplayGamePlayScreen("Pick Up Game Object", "It appears there are no objects in your inventory", ActionMenu.ObjectMenu, "");

                //return to main menu
            }

            return(travelerObjectId);
        }
コード例 #6
0
        private void PutDownAction()
        {
            //
            //display list of objects in inventory
            //
            int inventoryObjectToPutDownId = _gameConsoleView.DisplayGetInventoryObjectToPutDown();

            //
            //get object from universe
            //
            TravelerObject travelerObject = _gameShip.GetGameObjectById(inventoryObjectToPutDownId) as TravelerObject;

            //
            //remove from inventory
            //
            _gameTraveler.Inventory.Remove(travelerObject);
            travelerObject.LocationId = _gameTraveler.LocationID;

            //
            //confirmation
            //
            _gameConsoleView.DisplayConfirmTravelerObjectAddedToInventory(travelerObject);
        }
コード例 #7
0
 public void DisplayConfirmTravelerObjectRemovedFromInventory(TravelerObject objectRemovedFromInventory)
 {
     DisplayGamePlayScreen("Put Down Game Object", $"The {objectRemovedFromInventory.Name} has been removed from your inventory.", ActionMenu.ObjectMenu, "");
 }
コード例 #8
0
        private void HandleObjectAddedToInventory(object gameObject, EventArgs e)
        {
            if (gameObject.GetType() == typeof(TravelerObject))
            {
                TravelerObject travelerObject = gameObject as TravelerObject;
                switch (travelerObject.Type)
                {
                case TravelerObjectType.Food:
                    _gameTraveler.Health += travelerObject.Value;

                    //
                    //adds life if > than 100
                    //
                    if (_gameTraveler.Health >= 100)
                    {
                        _gameTraveler.Health = 100;
                        _gameTraveler.Lives -= 1;
                    }
                    if (travelerObject.IsConsumable)
                    {
                        travelerObject.LocationId = -1;
                    }

                    break;

                case TravelerObjectType.MealCard:
                    if (true)
                    {
                        _gameShip.GetLocationByID(3).Accessable = true;
                    }

                    break;

                case TravelerObjectType.Medicine:
                    _gameTraveler.Health += travelerObject.Value;

                    //
                    //adds life if > than 100
                    //
                    if (_gameTraveler.Health >= 100)
                    {
                        _gameTraveler.Health = 100;
                        _gameTraveler.Lives += 1;
                    }
                    if (travelerObject.IsConsumable)
                    {
                        travelerObject.LocationId = -1;
                    }

                    break;

                case TravelerObjectType.BagOfGold:

                    break;

                case TravelerObjectType.Necklace:

                    if (true)
                    {
                        _gameShip.GetLocationByID(3).Accessable = true;
                        _gameShip.GetLocationByID(1).Accessable = false;
                    }

                    break;

                case TravelerObjectType.Document:

                    //wins game

                    if (true)
                    {
                    }
                    break;

                case TravelerObjectType.Key:
                    //
                    //all three keys unlocks Captains office
                    //

                    //if (_gameTraveler.Inventory.Contains(TravelerObjectType.Key = 3))
                    //{
                    //    _gameShip.GetLocationByID(5).Accessable = true;
                    //}
                    break;

                default:
                    break;
                }
            }
        }
コード例 #9
0
 public void DisplayConfirmTravelerObjectAddedToInventory(TravelerObject objectAddedToInventory)
 {
     DisplayGamePlayScreen("Pick Up Game Object", $"The {objectAddedToInventory.Name} has been added to your inventory.", ActionMenu.MainMenu, "");
 }