📄 tilemanagerfakeiso.java
字号:
/*
* Light And Shadow. A Persistent Universe based on Robert Jordan's Wheel of Time Books.
* Copyright (C) 2001-2003 WOTLAS Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package wotlas.common.universe;
import wotlas.common.*;
import wotlas.utils.*;
import wotlas.libs.persistence.*;
import wotlas.libs.graphics2D.*;
import wotlas.libs.graphics2D.drawable.*;
import wotlas.utils.*;
import wotlas.common.environment.*;
import wotlas.editor.*;
import java.awt.*;
import java.util.*;
/** Group of graphics represents an Id+ the size of the Tiles inside the image, and the name of the image
*
* @author Diego
* @see wotlas.common.universe.TileMap
* @see wotlas.client.TileMapData
*/
public class TileManagerFakeIso extends TileMapManager{
/** id used in Serialized interface.
*/
private static final long serialVersionUID = 556565L;
/*------------------------------------------------------------------------------------*/
static final byte MAPTYPE = TileMap.FAKEISO;
/** wht's the basic floor id, eventually used for overlay tiles?
* it's basicFloorId
*/
private byte basicFloorId;
private byte basicFloorIdTileNr;
/** Map exits...
*/
private MapExit[] mapExits;
transient private TileMap tileMap;
/** array with fake iso data
*/
private FakeIsoLayers[][] fakeIsoLayers;
/** data of additive layers of map.
*/
private byte[][][] mapBackgroundData;
private boolean[][] mapBackgroundDataMask;
/** only for persistence
*/
public TileManagerFakeIso( ) {
}
/** create the object
*/
public TileManagerFakeIso( TileMap tileMap) {
this.tileMap = tileMap;
}
/*------------------------------------------------------------------------------------*/
/** String Info.
*/
public String toString(){
return "FakeIso - ";
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/** id version of data, used in serialized persistance.
*/
public int ExternalizeGetVersion(){
return 2;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/** write object data with serialize.
*/
public void writeExternal(java.io.ObjectOutput objectOutput)
throws java.io.IOException {
objectOutput.writeInt( ExternalizeGetVersion() );
objectOutput.writeObject( mapBackgroundData );
objectOutput.writeObject( mapBackgroundDataMask );
objectOutput.writeObject( fakeIsoLayers );
objectOutput.writeByte( basicFloorId );
objectOutput.writeByte( basicFloorIdTileNr );
objectOutput.writeObject( mapExits );
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/** read object data with serialize.
*/
public void readExternal(java.io.ObjectInput objectInput)
throws java.io.IOException, java.lang.ClassNotFoundException {
int IdTmp = objectInput.readInt();
if( IdTmp == ExternalizeGetVersion() ){
mapBackgroundData = ( byte[][][] ) objectInput.readObject();
mapBackgroundDataMask = ( boolean[][] ) objectInput.readObject();
fakeIsoLayers = ( FakeIsoLayers[][] ) objectInput.readObject();
basicFloorId = objectInput.readByte();
basicFloorIdTileNr = objectInput.readByte();
mapExits = ( MapExit[] ) objectInput.readObject();
} else {
// to do.... when new version
}
}
public void setMapExits(MapExit[] myMapExits) {
this.mapExits = myMapExits;
}
public MapExit[] getMapExits() {
return mapExits;
}
public void setFakeIsoLayers( int x, int y, byte layer, byte imageId, byte tileNr, byte imageDirection) {
FakeIsoLayers theNext;
if( fakeIsoLayers[x][y] == null )
fakeIsoLayers[x][y] = new FakeIsoLayers( imageId, tileNr, imageDirection );
else
fakeIsoLayers[x][y].Add( imageId, tileNr, imageDirection );
theNext = fakeIsoLayers[x][y].getNext();
for( int floor=1; floor < layer; floor++){
if( theNext == null)
theNext = new FakeIsoLayers( imageId, tileNr, imageDirection );
else
theNext.Add( imageId, tileNr, imageDirection );
theNext = theNext.getNext();
}
if(layer != 0){
theNext.setNext( new FakeIsoLayers( imageId, tileNr, imageDirection ) );
}
}
public void setMap( int x, int y, Dimension mapTileDim, byte basicFloorId, byte basicFloorIdTileNr ){
this.basicFloorId = basicFloorId;
this.basicFloorIdTileNr = basicFloorIdTileNr;
this.tileMap.mapTileDim = mapTileDim;
Dimension mapSize = new Dimension();
mapSize.width = x;
mapSize.height = y;
tileMap.setMapSize( mapSize );
mapBackgroundData = new byte[x][y][2];
mapBackgroundDataMask = new boolean[x][y];
for( int xx=0; xx < x; xx++)
for( int yy=0; yy < y; yy++) {
mapBackgroundData[xx][yy][0] = basicFloorId;
mapBackgroundData[xx][yy][1] = basicFloorIdTileNr;
mapBackgroundDataMask[xx][yy] = TileMap.TILE_FREE;
}
fakeIsoLayers = new FakeIsoLayers[x][y];
for( int xx=0; xx < x; xx++)
for( int yy=0; yy < y; yy++)
fakeIsoLayers[xx][yy] = null;
}
public void setMapPoint(int x, int y, int map, int tileNr) {
if( x >= tileMap.getMapSize().width
|| y >= tileMap.getMapSize().height) {
Debug.signal( Debug.WARNING, null, "Tried to change a point inside of map, with coordinates over mapSize" );
return;
}
/*
if( map > (.length) ) {
Debug.signal( Debug.WARNING, null, "Tried to change a point inside of map, with a layer of declared layers " );
return;
}
*/
mapBackgroundData[x][y][0] = (byte) map;
mapBackgroundData[x][y][1] = (byte) tileNr;
mapBackgroundDataMask[x][y] = TileMap.TILE_FREE;
}
public byte[][][] getMapBackGroundData() {
return mapBackgroundData;
}
public byte getMapType(){
return MAPTYPE;
}
public void setTileMap(TileMap tileMap){
this.tileMap = tileMap;
}
public void drawAllLayer( GraphicsDirector gDirector ) {
Drawable background = null; // background image
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -