?? gamedatasimple.java
字號:
return NPCData;
}
public String[] getMissionProperties() {
return null;
}
public int[] getPlayerInfo() {
return null;
}
public int[] getPlayerNumProp() {
return null;
}
public String[] getPlayerStrProp() {
return null;
}
public int[] getResolvingPower() {
return null;
}
public int getTileHeight() {
return 0;
}
public short[][] getTilesIndex() {
return null;
}
public int getTileWidth() {
return 0;
}
public int getTotalColor() {
return 0;
}
public int getTotalMission() {
return 5;
}
protected void loadCurrentMission() {
}
//數據讀取 GameTools.java
// ///////////////////////////////////////////////////////////////////////
byte type;
int length_1;
int length_2;
int length_3;
int Array_1[];
int Array_2[][];
int Array_3[][][];
/** 創建圖片時使用的數組 */
private static byte byteArray[];
/** 讀文件時使用的輸入流 */
private static InputStream input;
/**
* 圖片文件大小
*/
public int image_size[];
// 一維數組
public void createArray_1(int index) {
Array_1 = readFromFile("gamedata.c", index);
}
//二維數組
public void createArray_2(int index) {
int data[];
data = readFromFile("gamedata.c", index);
for (int i = 0; i < data.length; i++) {
int column = i / length_1;
int row = i % length_2;
Array_2[column][row] = data[i];
}
}
//三維數組
public void createArray_3(int index) {
int data[];
data = readFromFile("gamedata.c", index);
for (int i = 0; i < data.length; i++) {
int column = (i / length_2) / length_3;
int row = (i / length_2) % 2;
int line = i / length_1;
Array_3[column][row][line] = data[i];
}
}
////////////////////////////
public int[] GetArray_1(int index) {
createArray_1(index);
return Array_1;
}
public int[][] GetArray_2(int index) {
createArray_2(index);
return Array_2;
}
public int[][][] GetArray_3(int index) {
createArray_3(index);
return Array_3;
}
////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////
//從文件讀取一維數組
//index 數組編號
////////////////////////
public int[] readFromFile(String fileName, int index) {
String returnString = null;
DataInputStream dis = new DataInputStream(getClass()
.getResourceAsStream(fileName));
try {
int ch = 0;
byte a = 0;
byte b = 0;
byte c = 0;
int skip = 0;
type = 0;
length_1 = 1;
length_2 = 1;
length_3 = 1;
do {
type = dis.readByte();
switch (type) {
case 1:
a = dis.readByte();
b = dis.readByte();
length_1 = (b << 8) | (a & 0xff);
a = dis.readByte();
b = dis.readByte();
skip = (b << 8) | (a & 0xff);
break;
case 2:
a = dis.readByte();
b = dis.readByte();
length_1 = (b << 8) | (a & 0xff);
a = dis.readByte();
b = dis.readByte();
length_2 = (b << 8) | (a & 0xff);
a = dis.readByte();
b = dis.readByte();
skip = (b << 8) | (a & 0xff);
break;
case 3:
a = dis.readByte();
b = dis.readByte();
length_1 = (b << 8) | (a & 0xff);
a = dis.readByte();
b = dis.readByte();
length_2 = (b << 8) | (a & 0xff);
a = dis.readByte();
b = dis.readByte();
length_3 = (b << 8) | (a & 0xff);
a = dis.readByte();
b = dis.readByte();
skip = (b << 8) | (a & 0xff);
break;
default:
}
if (index != 1) {
dis.skipBytes(skip);
}
System.out.println("33");
} while (index-- != 1);
int k = length_1 * length_2 * length_3;
int[] data = new int[k];
System.out.println(k);
for (int i = 0; i < k; i++) {
a = dis.readByte();
if (a == -1) {
b = dis.readByte();
switch (b) {
case 1://相同的shortInt數據
break;
case 2://shortInt數據
c = dis.readByte();
for (int j = 1; j <= c; j++) {
a = dis.readByte();
b = dis.readByte();
ch = (b << 8) | (a & 0xff);
i++;
}
i--;
break;
case 3://相同的byte數據
c = dis.readByte();
b = dis.readByte();
for (int j = 1; j <= c; j++) {
data[i] = b;
if (i == k - 1)
continue;
i++;
}
i--;
break;
}
} else {
data[i] = a;
}
if (i == k - 2)
break;
}
return data;
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
dis.close();
} catch (IOException e1) {
// TODO 自動生成 catch 塊
e1.printStackTrace();
}
}
return null;
}
////////////////////////////////////////////////////////////////////////////////////////////
/**
*
* @param Image[]
* img 存放的圖片數組
* @param String
* imgname 讀取資源圖片名稱
* @param int
* Image_ID 圖片讀取的ID,一般為零
* @param int
* Image_Num 圖片讀取的數目
*/
public void createImage(Image[] img, String imgname, int ID,
int Image_Num, Object o) {
short AllImage = 0;
int start = 1;
try {
input = o.getClass().getResourceAsStream("/res/" + imgname);
DataInputStream datainputstream = new DataInputStream(input);
AllImage = datainputstream.readByte();
// System.out.println("GameTools "+AllImage);
image_size = new int[AllImage];
for (int i = 0; i < AllImage; i++) {
byte a = datainputstream.readByte();
byte b = datainputstream.readByte();
image_size[i] = (b << 8) | (a & 0xff);
if (i <= Image_Num) {
start += 2;
}
}
for (int i = 0; i < Image_Num; i++) {
byteArray = null;
byteArray = new byte[image_size[i]];
datainputstream.read(byteArray);
img[i] = Image.createImage(byteArray, 0, byteArray.length);
datainputstream.readByte();
start += image_size[i] + 1;
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -