コード例 #1
0
        public int DisplayGetObjectToInteractWithId()
        {
            int  interactiveObjectId    = 0;
            bool validInteractiveObject = false;

            //
            // get a list of game onjects in the current space-time location
            //
            List <InteractiveObject> interactiveObjectsInIslandLocation = _gameUniverse.GetInteractiveObjectsByIslandLocationId(_gameSurvivor.IslandLocationID);

            if (interactiveObjectsInIslandLocation.Count > 0)
            {
                DisplayGamePlayScreen("Interact With an Object", Text.InteractiveObjectsChooseList(interactiveObjectsInIslandLocation), ActionMenu.ObjectMenu, "");

                while (!validInteractiveObject)
                {
                    //
                    // get an integer from the player
                    //
                    GetInteger($"Enter the Id number of the object you wish to interact with: ", 0, 0, out interactiveObjectId);

                    //
                    // validate integer as a valid game object id and in current location
                    //
                    if (_gameUniverse.IsValidGameObjectByLocationId(interactiveObjectId, _gameSurvivor.IslandLocationID))
                    {
                        validInteractiveObject = true;
                    }
                    else
                    {
                        ClearInputBox();
                        DisplayInputErrorMessage("It appears you entered an invalid game object id. Please try again.");
                    }
                }
            }
            else
            {
                ClearInputBox();
                DisplayGamePlayScreen("Interact With an Object", "It appears there are no game objects here.", ActionMenu.ObjectMenu, "");
                interactiveObjectId = 0;
            }

            return(interactiveObjectId);
        }