コード例 #1
0
        /// <summary>
        /// display the player objects to collect
        /// </summary>
        /// <returns></returns>
        public int DisplayGetPlayerObjectToPickUp()
        {
            int  gameObjectsId      = 0;
            bool validGamerObjectId = false;

            //
            // get a list of player objects in the current location
            //
            List <PlayerObject> playerObjectsInLocation = _gameUniverse.GetPlayerObjectsByLocationId(_gamePlayer.SpaceTimeLocationID);

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

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

                    //
                    // validate integer as a valid game object id and in current location
                    //
                    if (_gameUniverse.IsValidPlayerObjectByLocationId(gameObjectsId, _gamePlayer.SpaceTimeLocationID))
                    {
                        PlayerObject playerObject = _gameUniverse.GetGameObjectById(gameObjectsId) as PlayerObject;
                        if (playerObject.CanInventory)
                        {
                            validGamerObjectId = 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 here.", ActionMenu.ObjectMenu, "");
            }
            return(gameObjectsId);
        }