I wanted to ask that how can we add constructible rooms to expand the business , which will eventually get unlocked with some money or other requirements.
The easiest way is to hard define how the building will looks, and how many rooms can be added. Then you'll just need an array representing the building in its raw form.
Each one of its index corresponding to a position on the map.
Let's say that you have a building with x floors, each one hosting up to ten rooms (five on top, five on bottom).
The index 0 will correspond to the first room (top left) on the ground level floor. The index 4 will correspond to the top right room. The index 5 will be for the bottom left room, and the index 9 for the bottom right room.
Then you can add as many from as you want. Index 10 is top left room on first floor, index 39 the bottom right room on the third floor, and so on.
And the value at a given index will define what kind of room is at this position, the values themselves being a pointer to an object corresponding to the room.
Therefore you need a "room" class, that will serve as generic base for your rooms. Then you'll create a class (inheriting from "room") for each kind of rooms (spa, bedroom, bar, gym, etc.).
That way, when the player create a new room, you just have to create a new object from the right class, and place a pointer to it on the array representing the building, at the index corresponding to the created room. Everything else will then be automatically handled without the need for you to care about what room is where.
To display the current floor, you just need something like this (pseudo code) :
Code:
for( i = 0 ; i < 10 ; i++ )
{ building[ ( floor*10 ) + i ].display( i ); }
The "display" method being in charge to draw the correct room at the position corresponding to the passed index.
When the player right click somewhere, you just need to catch the click and have something like:
Code:
building[ (floor*10) + mousePosToIndex() ].menu();
The "menu" method being in charge to display the menu corresponding to the room and to handle the choice made by the player and what they imply.
Optionally you can pass the index to the method, in order to draw the menu right on top of the room.
When the player left click somewhere, you just need to catch the click and have something like:
Code:
building[ (floor*10) + mousePosToIndex() ].enter();
The "enter" method handling whatever happen when the player is inside the room.
And so on.
Be noted that in fact the same apply whatever the engine.
It's only the code to write that will change, but if it's what you are searching for, then you aren't ready yet for this kind of game mechanism. In this case, starts by learning what are classes and how objects works, then after you'll be able to write this mostly by yourself.