ID:2280900
 
What would be the best way to implement a system where players can (after purchasing furniture etc. with in-game cash from a NPC) see their owned furniture in a separate window, and the user can choose to place the furniture down in their house?

When I first tried this years ago, I had the furniture be items in the player's inventory and they could right click each piece of furniture and pick to drop it down where they're standing. But I wonder if there's a better way. Using interfaces or the browser or something..
This is a very vague question, but I'll do my best to answer it in the way that I think you're actually meaning, rather than going off on some tangent about "a million different ways" that's in no way helpful to you or anyone else reading this in the future.

Some assumptions I will make:
  • You already have a UI for your item inventory.
  • You roughly understand what a "game state" is and how a user's input differs depending on what they're actually doing. (i.e. input for fighting vs when they're trying to build)
  • Building isn't the only thing you can do, so it shouldn't be the default game state.
  • You're a clever individual who can abstractify the information I present and put it into a format that works best for you.


So, let's start with the game states. Often times these appear in games as a "build mode" state and a "normal mode" state. Some games you have to press a certain key to enter "build mode" or be in a certain area such as your home, so I'll just assume that's how you want it to work.

So, having a trigger to put the client into build mode will be necessary. Once you're in build mode, your UI should likely change to show things that are pertinent to what you're wanting to build. This will include popping up their "build inventory" of available objects they have to pick from. It may also be useful to outline or point out which objects near the player is available for editing while they're in build mode. This could be an outline around the object or having them highlight on mouse over. Some kind of feedback to let the player subtly know, "hey, you can pick this up and move it".

That's our first event taken care of, now what next? Let's pick something from the inventory and place it down. You can obviously handle this one of many ways. You could make it drag-and-drop where the player drags the object from their inventory onto the map. Or you could make them select the object in their inventory and then click somewhere on the ground to have it appear, which would be easier to implement.

Again, feedback is going to be very helpful. You want the player to know what's going to happen when they click on the map again. So once they have an object in their build inventory selected and mouse over the map, they might see something like a "ghost" version of the object to check its orientation and placement while they move their mouse around. Either this or have a green marker on the floor outlining the object like you might see in an RTS or something that turns red when you mouse over a spot where they're not allowed to place it. That's all up to you, though.

So now the player can enter build mode, select objects in their inventory and then plonk them down onto the map, you can easily see how the reverse can be accomplished. Clicking on a placed item may change its orientation and right-clicking will pick it up, for example.

TL;DR

Implementing a Game State design pattern will pretty much get you 90% of the way there as far as the hard "design" part of it. Beyond that it's all very simple logic.