|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmap.Grid
public class Grid
A Grid is divided into a set of Unit
s. The first Unit is in the upper
left corner with the values (0,0)
.
Every Unit in the grid is assigned to a Unit Id that is put together by
multipling the row of the Unit with the total number of Units per row and
adding the column of the Unit + 1.
e.g.:
Id(20) = (row_index * #units_per_row) + column_index + 1 =
(3 * 5) + 4 + 1 = 20
.
A Unit
may contains one or more MapItem
s.
Map Items are loaded from ".list"
files which
contain a collection of Map Items. In such a file following syntax is used:
1: 5 // Number of Columns in the Grid
2: 4 // Number of Rows in the Grid
3: -
4: 0 0 Hoobastank - The Reason.mp3
5: 0 0 Lenny Kravitz - Fly away.mp3
. . ...
17: 0 2 Kylie Minogue - Slow.mp3
. . ...
The first three lines specify the layout of the Grid, where as the rest
of the file contains the Map Items (one per line). The first two values
assign the Map Item to a Unit followed by the name of the item
MapItem
,
Unit
Constructor Summary | |
---|---|
Grid(java.lang.String resource)
Inits the Grid in building the Unit HashTable that holds UnitIds (Integer Objects) as a key with the corresponding Unit as value |
Method Summary | |
---|---|
MapItem |
getMapItem(java.lang.Integer unitId,
boolean bRotate)
Gets a Map Item of a given Unit. |
java.util.Vector |
getMapItems(java.lang.Integer unitId)
Returns all Map Items of a given Unit. |
java.lang.Integer |
getUnitId(int unitX,
int unitY)
Returns the UnitId of a given row and column |
int |
getUNITS_X()
Gets the number of columns of the Grid |
int |
getUNITS_Y()
Gets the number of rows of the Grid |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Grid(java.lang.String resource)
resource
- The resource where to get the items fromMethod Detail |
---|
public MapItem getMapItem(java.lang.Integer unitId, boolean bRotate)
true
, the next Map Item of the Unit will be returned.
unit
- the Unit where to get a Map Item frombRotate
- true
return the next item of the given
unitfalse
return the first item of the unit
public java.util.Vector getMapItems(java.lang.Integer unitId)
unitId
- the unitId to get Map Items from
public java.lang.Integer getUnitId(int unitX, int unitY)
unitX
- the columnunitY
- the row
public int getUNITS_X()
public int getUNITS_Y()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |