📄 room.java
字号:
case 154:
case 155:
case 156:
case 157:
case 158:
case 160:
case 161:
case 163:
case 164:
case 166:
case 167:
case 168:
case 169:
case 170:
case 171:
case 172:
case 173:
case 174:
case 177:
case 178:
case 179:
case 180:
case 181:
case 182:
case 184:
case 185:
case 186:
case 189:
case 191:
case 192:
case 193:
case 194:
case 195:
case 196:
case 197:
case 198:
case 199:
case 200:
case 201:
case 202:
case 203:
case 204:
case 205:
case 206:
case 207:
case 208:
case 209:
case 210:
case 211:
case 212:
case 215:
case 216:
case 217:
default:
return 60;
}
return 0;
}
public static int GetRoomData(int i, int j)
{
try
{
return roomData[i][j];
}
catch(Exception e)
{
return -1;
}
}
public static void SetRoomData(int newId, int i, int j)
{
roomData[i][j] = newId;
}
public static int GetFloorData(int i, int j)
{
try
{
return floorData[i][j];
}
catch(Exception e)
{
return -1;
}
}
public static void SetFloorData(int newId, int i, int j)
{
floorData[i][j] = newId;
}
public static int GetObjectId(int posX, int posY)
{
if(IsCannotWalkFloor(floorData[posX][posY]))
return floorData[posX][posY];
if(IsWallId(floorData[posX][posY]))
return floorData[posX][posY];
if(roomData[posX][posY] != -1)
return roomData[posX][posY];
else
return -1;
}
public static void SetObjectId(int newId, int posX, int posY)
{
if(IsCannotWalkFloor(floorData[posX][posY]))
floorData[posX][posY] = newId;
else
if(IsWallId(floorData[posX][posY]))
floorData[posX][posY] = newId;
else
roomData[posX][posY] = newId;
}
public static boolean IsCannotWalkFloor(int id)
{
if(id >= 11 && id <= 19)
return true;
if(id >= 121 && id <= 129)
return true;
return id == 36 || id == 37 || id == 147;
}
public static boolean IsWallId(int id)
{
if(id == 20 || id == 21 || id == 131)
return true;
if(id == 30 || id == 31 || id == 141)
return true;
if(id >= 40 && id <= 43)
return true;
if(id >= 150 && id <= 153)
return true;
return id == 55 || id == 165;
}
static final boolean IsCornerWallId(int id)
{
if(id == 21 || id == 131)
return true;
if(id == 31 || id == 141)
return true;
return id == 37 || id == 147;
}
static final boolean IsCloseDoorXId(int id)
{
return id == 52 || id == 162;
}
static final boolean IsCloseDoorYId(int id)
{
if(id == 50 || id == 160)
return true;
return id == 53 || id == 163;
}
static final boolean IsOpenDoorYId(int id)
{
if(id == 51 || id == 161)
return true;
return id == 54 || id == 164;
}
static final boolean IsCloseTreasureId(int id)
{
return id == 97 || id == 207;
}
static final boolean IsOpenTreasureId(int id)
{
return id == 98 || id == 208;
}
static final boolean IsExaminableId(int id)
{
return id == 56 || id == 59 || id == 61 || id == 62 || id == 63 || id == 67 || id == 68 || id == 69 || id == 71 || id == 72 || id == 74 || id == 76 || id == 80 || id == 81 || id == 83 || id == 87 || id == 91 || id == 92 || id == 93 || id == 95 || id == 97 || id == 98;
}
static final boolean IsLinkAreaId(int id)
{
if(id >= 110 && id <= 121)
return true;
return id == 8 || id == 9;
}
public int GetWidth()
{
return width;
}
public int GetHeight()
{
return height;
}
public void SetLoadMapOk(boolean ok)
{
loadOk = ok;
}
public boolean IsLoadOk()
{
return loadOk;
}
public void Draw(Graphics g, int xOffset, int yOffset)
{
g.setClip(0, 0, 176, 178);
g.setColor(0);
g.fillRect(0, 0, 176, 178);
g.drawImage(img, xOffset, yOffset, 20);
}
public static void DrawObjData(Graphics g, int id, int xOffset, int yOffset)
{
g.setClip(xOffset, yOffset, 30, 30);
if(id < 110)
{
int posY = id / NUM_OBJ_X;
int posX = id - posY * NUM_OBJ_X;
g.drawImage(sourceImg, xOffset - posX * 30, yOffset - posY * 30, 20);
} else
{
int flipId = id - 110;
int posY = flipId / NUM_OBJ_X;
int posX = (flipId - posY * NUM_OBJ_X) + 1;
DirectGraphics dg = DirectUtils.getDirectGraphics(g);
dg.drawImage(sourceImg, (xOffset - sourceImg.getWidth()) + posX * 30, yOffset - posY * 30, 20, 8192);
}
}
public void CreateImage()
{
loadOk = false;
int posX = 0;
int posY = 0;
img = Image.createImage(30 * width, 30 * height);
Graphics g = img.getGraphics();
DirectGraphics dg = DirectUtils.getDirectGraphics(g);
g.setClip(0, 0, img.getWidth(), img.getHeight());
g.setColor(0);
g.fillRect(0, 0, img.getWidth(), img.getHeight());
int x = 0;
int y = 0;
int flipId = 0;
int mapImgWidth = sourceImg.getWidth();
boolean increaseY = false;
for(int i = 0; i < floorData.length; i++)
{
x = i * 30;
for(int j = 0; j < floorData[0].length; j++)
{
increaseY = false;
if(floorData[i][j] != -1)
{
y = j * 30;
increaseY = true;
if(floorData[i][j] < 110)
{
posY = floorData[i][j] / NUM_OBJ_X;
posX = floorData[i][j] - posY * NUM_OBJ_X;
g.setClip(x, y, 30, 30);
g.drawImage(sourceImg, x - posX * 30, y - posY * 30, 20);
} else
if(!GameManager.drawStupidLoop)
{
flipId = floorData[i][j] - 110;
posY = flipId / NUM_OBJ_X;
posX = (flipId - posY * NUM_OBJ_X) + 1;
g.setClip(x, y, 30, 30);
dg.drawImage(sourceImg, (x - mapImgWidth) + posX * 30, y - posY * 30, 20, 8192);
}
}
if(roomData[i][j] != -1 && !IsCloseTreasureId(roomData[i][j]) && !IsOpenTreasureId(roomData[i][j]) && !IsCloseDoorXId(roomData[i][j]) && !IsCloseDoorYId(roomData[i][j]) && !IsOpenDoorYId(roomData[i][j]))
{
if(!increaseY)
y = j * 30;
if(roomData[i][j] < 110)
{
posY = roomData[i][j] / NUM_OBJ_X;
posX = roomData[i][j] - posY * NUM_OBJ_X;
g.setClip(x, y, 30, 30);
g.drawImage(sourceImg, x - posX * 30, y - posY * 30, 20);
} else
if(!GameManager.drawStupidLoop)
{
flipId = roomData[i][j] - 110;
posY = flipId / NUM_OBJ_X;
posX = (flipId - posY * NUM_OBJ_X) + 1;
g.setClip(x, y, 30, 30);
dg.drawImage(sourceImg, (x - mapImgWidth) + posX * 30, y - posY * 30, 20, 8192);
}
}
}
}
loadOk = true;
}
private static int roomData[][] = null;
private static int floorData[][] = null;
private static int NUM_OBJ_X = 10;
static Image sourceImg = null;
private Image img;
private int id;
private int width;
private int height;
private boolean loadOk;
private Thread thread;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -