From: Mamutas P. <ma...@pr...> - 2004-01-03 04:46:48
|
Let me explain my idea a bit more. It might look similar to adding controls in Java's GridBagLayout, so if you are familiar with that, then you are on the fast track. :) Lets take an soldier as an example. He has following containers (not exactly like in the game, but enough for that example): left pocket, right pocket, backpack, belt. When soldier object is created, it will contain enumeration of those containers. When containers are created, each of them will be created with ContainerConstraint object, permanently attached to container. So, in our example containers might have following constraints: Container name Width Height Max Items Max Weight Type left pocket 1 2 2 10 Handheld right pocket 1 2 2 10 Handheld belt 6 1 6 20 Weapon backpack 3 4 12 100 ICarriable So, in this case if player would try to add an object with size 3x2 in his pocket, that object will not fit and the request to add will be denied. However, such object will fit easily in backpack. And... Wait a minute! Now, it occurred to me that there is a problem with layout: we need to keep track of what cells are occupied already. And we need to provide the interface for player to choose cells explicitly. So, it looks like the best way is to go with sort of table, which would describe each cell in addition to total limitations (weight, type, etc.). Well, in that case we need to assign a grid description to each container. Each cell will keep reference of the object it is storing, but the whole grid will manage weigh/type and other global parameter limitations. Regards, mamutas --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.556 / Virus Database: 348 - Release Date: 12/26/2003 |