java.lang.Object
org.meowers.cide.data.GameObject
org.meowers.cide.data.GameData
- All Implemented Interfaces:
- java.io.Serializable
- public class GameData
- extends GameObject
Stores all the data necessary for a game to be run, or at least provides
wrappers to other storage classes.
- Version:
- %I%, %G%
|
Constructor Summary |
GameData()
Creates new GameData. |
|
Method Summary |
void |
addGameObject(GameObject gameObj)
Adds and GameObject object to store in the game data. |
GameObject |
getGameObject(int objType,
int index)
Gets a GameObject at a specified index of a specified
type. |
int |
getGameObjectCount(int objType)
Returns the number of GameObjects of the specified type
are stored here. |
int |
getTileSize()
Returns the size of tiles used in this game. |
private boolean |
isArrayDirty(java.util.ArrayList list)
Checks all the elements of an array of objects, and for each one of
class GameObject it checks if its dirty. |
boolean |
isDirty()
Returns the dirty state of this game data. |
private boolean |
isGameObjectTypeValid(int objType)
Checks to see if the type of object is one that is storable here. |
boolean |
setTileSize(int tileSize,
boolean destroy)
Set the size of tiles used in this game. |
stores
private java.util.ArrayList[] stores
tileSize
private int tileSize
GameData
public GameData()
- Creates new GameData.
isGameObjectTypeValid
private boolean isGameObjectTypeValid(int objType)
- Checks to see if the type of object is one that is storable here. In
particular, it must be a valid type and not a
GameData
type either.
addGameObject
public void addGameObject(GameObject gameObj)
- Adds and
GameObject object to store in the game data.
getGameObjectCount
public int getGameObjectCount(int objType)
- Returns the number of
GameObjects of the specified type
are stored here. The the type specified is not valid, returns zero.
getGameObject
public GameObject getGameObject(int objType,
int index)
- Gets a
GameObject at a specified index of a specified
type. Returns null if something went wrong.
isArrayDirty
private boolean isArrayDirty(java.util.ArrayList list)
- Checks all the elements of an array of objects, and for each one of
class
GameObject it checks if its dirty. Returns true
if any of the array's GameObject type elements are
dirty.
isDirty
public boolean isDirty()
- Returns the dirty state of this game data. This also does a deep check
of all contained data objects.
- Overrides:
isDirty in class GameObject
getTileSize
public int getTileSize()
- Returns the size of tiles used in this game.
setTileSize
public boolean setTileSize(int tileSize,
boolean destroy)
- Set the size of tiles used in this game. If tiles exist, the operation
fails unless the
destroy parameter is true,
in which case the existing tiles are discarded.
NOTE: Soon a method of changing the tile size non-destructivley should
be provided for maximum editing ability.