📄 tilemanagerfakeiso.java
字号:
for( int y=0; y<tileMap.getMapSize().height; y++ ) {
for( int x=0; x<tileMap.getMapSize().width; x++ ) {
if( getMapBackGroundData()[x][y][0] != basicFloorId ) {
background = (Drawable) new MotionlessSprite( x*tileMap.getMapTileDim().width, // ground x=0
y*tileMap.getMapTileDim().height, // ground y=0
EnvironmentManager.getGraphicsForMaps(tileMap.getGraphicSet())[basicFloorId], // GroupOfGraphics
basicFloorIdTileNr, // number of internal tile
ImageLibRef.MAP_PRIORITY // priority
);
gDirector.addDrawable(background);
background = (Drawable) new MotionlessSprite( x*tileMap.getMapTileDim().width, // ground x=0
y*tileMap.getMapTileDim().height, // ground y=0
EnvironmentManager.getGraphicsForMaps(tileMap.getGraphicSet())[getMapBackGroundData()[x][y][0]], // GroupOfGraphics
getMapBackGroundData()[x][y][1], // number of internal tile
ImageLibRef.SECONDARY_MAP_PRIORITY // priority
);
gDirector.addDrawable( background );
}
else {
background = (Drawable) new MotionlessSprite( x*tileMap.getMapTileDim().width, // ground x=0
y*tileMap.getMapTileDim().height, // ground y=0
EnvironmentManager.getGraphicsForMaps(tileMap.getGraphicSet())[getMapBackGroundData()[x][y][0]], // GroupOfGraphics
getMapBackGroundData()[x][y][1], // number of internal tile
ImageLibRef.SECONDARY_MAP_PRIORITY // priority
);
gDirector.addDrawable( background );
}
if( getMapType() == tileMap.FAKEISO )
if( fakeIsoLayers[x][y] != null ) {
Iterator singleData = fakeIsoLayers[x][y].getData().iterator();
while( singleData.hasNext() ){
byte[] singleByteData = (byte[]) singleData.next();
background = (Drawable) new MotionlessSprite( x*tileMap.getMapTileDim().width, // ground x=0
y*tileMap.getMapTileDim().height, // ground y=0
EnvironmentManager.getGraphicsForMaps(tileMap.getGraphicSet())[ singleByteData[0] ], // GroupOfGraphics
singleByteData[1], // number of internal tile
FakeIsoLayers.getPriority( singleByteData[2] ) // priority
);
gDirector.addDrawable( background );
}
}
}
}
}
public byte getBasicFloorId(){
return basicFloorId;
}
public void setBasicFloorId( byte value ){
this.basicFloorId = value;
}
public byte getBasicFloorNr(){
return basicFloorIdTileNr;
}
public void setBasicFloorNr( byte value ){
this.basicFloorIdTileNr = value;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/** Add a new MapExit object to the array {@link #mapExits mapExits}
*
* @return a new MapExit object
*/
public MapExit addMapExit(ScreenRectangle r) {
return addMapExit( r, "" );
}
public MapExit addMapExit(ScreenRectangle r, String name) {
MapExit myMapExit = new MapExit(r,name);
if (mapExits == null) {
mapExits = new MapExit[1];
myMapExit.setMapExitID(0);
mapExits[0] = myMapExit;
} else {
MapExit[] myMapExits = new MapExit[mapExits.length+1];
myMapExit.setMapExitID(mapExits.length);
System.arraycopy(mapExits, 0, myMapExits, 0, mapExits.length);
myMapExits[mapExits.length] = myMapExit;
mapExits = myMapExits;
}
return myMapExit;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/** Add a new MapExit object to the array {@link #mapExits mapExits}
*
* @param me MapExit object
*/
public void addMapExit( MapExit me ) {
if (mapExits == null) {
mapExits = new MapExit[1];
mapExits[0] = me;
} else {
MapExit[] myMapExits = new MapExit[mapExits.length+1];
System.arraycopy(mapExits, 0, myMapExits, 0, mapExits.length);
myMapExits[mapExits.length] = me;
mapExits = myMapExits;
}
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/** Returns the MapExit which is on the side given by the specified rectangle.
* It's an helper for you : if your player is on a WorldMap and wants to go inside
* a TileMap use this method to retrieve a valid MapExit and get an insertion point.
*
* The MapExit is in fact a ScreenRectangle and the so called "insertion point"
* should be the center of this ScreenRectangle.
*
* @param rCurrent rectangle containing the player's current position, width & height
* the rectangle position can be anything BUT it should represent in some
* way the direction by which the player hits this TileMap zone.
* @return the appropriate MapExit, null if there are no MapExits.
*/
public MapExit findTileMapExit( Rectangle fromPosition ) {
if(mapExits==null) {
return null; // no position to analyze
}
/*
if(fromPosition==null)
return null; // no position to analyze
// We search on the first map exit
MapExit bExits[] = buildings[0].getBuildingExits();
for(int i=0; i<bExits.length; i++ ) {
if( bExits[i].getMapExitSide()==MapExit.WEST && fromPosition.x <= x+width/2 )
return bExits[i];
if( bExits[i].getMapExitSide()==MapExit.EAST && fromPosition.x >= x+width/2 )
return bExits[i];
if( bExits[i].getMapExitSide()==MapExit.NORTH && fromPosition.y <= y+height/2 )
return bExits[i];
if( bExits[i].getMapExitSide()==MapExit.SOUTH && fromPosition.y >= y+height/2 )
return bExits[i];
}
return bExits[0]; // default
}
*/
if(mapExits.length==1)
return mapExits[0];
for(int i=0; i<mapExits.length; i++ ) {
if( mapExits[i].getMapExitSide()==MapExit.WEST && fromPosition.x <= tileMap.x+tileMap.width/2 )
return mapExits[i];
if( mapExits[i].getMapExitSide()==MapExit.EAST && fromPosition.x >= tileMap.x+tileMap.width/2 )
return mapExits[i];
if( mapExits[i].getMapExitSide()==MapExit.NORTH && fromPosition.y <= tileMap.y+tileMap.height/2 )
return mapExits[i];
if( mapExits[i].getMapExitSide()==MapExit.SOUTH && fromPosition.y >= tileMap.y+tileMap.height/2 )
return mapExits[i];
}
return mapExits[0]; // default
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/** Returns the eventual MapExit the given player is intersecting.
*
* @param rCurrent rectangle containing the player's current position, width & height
* @return the ~Building:others tilemap the player is heading to (if he has reached it, or if there
* are any), null if none.
*/
public MapExit isIntersectingMapExit( int destX, int destY, Rectangle rCurrent ) {
if(mapExits==null)
return null;
for( int i=0; i<mapExits.length; i++ )
if( mapExits[i].toRectangle().contains(destX,destY)
&& mapExits[i].toRectangle().intersects( rCurrent ) )
return mapExits[i]; // mapExits reached
return null;
}
public boolean[][] getMapMask() {
return mapBackgroundDataMask;
}
public void freeMapBackGroundData(){
mapBackgroundData = null;
}
/* USED by Editor */
public void replaceGraphics(byte[][][] graphic){
mapBackgroundData = graphic;
}
public void replaceMask(boolean[][] mask){
mapBackgroundDataMask = mask;
}
public void replaceExits(MapExit[] exits){
mapExits = exits;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -