?? gamedata.java
字號:
package src;
import javax.microedition.lcdui.Image;
public abstract class GameData {
protected int missionID;
private static GameData instance = new GameDataSimple();
public static GameData getInstance(){
return instance;
}
/**
* 關卡ID
* @return 返回 missionID。
*/
public final int getMissionID() {
return missionID;
}
/**
* @param missionID 要設置的 missionID。
*/
public final void setMissionID(int missionID) {
if(this.getTotalMission() <= missionID || missionID <=0){
throw new IllegalArgumentException("Mission id error: " + missionID);
}
this.missionID = missionID;
this.loadCurrentMission();
}
public final void nextMission(){
if(missionID < this.getTotalMission()){
this.setMissionID(missionID+1);
}
}
/**
* 加載當前關卡的數據,本方法由抽象類隱式調用
*/
protected abstract void loadCurrentMission();
/**
* 獲得運行游戲使用的分辨率
* @return 返回僅有兩個元素的無符號整型數組,數組第一個元素是X軸分辨率,第二個元素是Y軸分辨率
*/
public abstract int[] getResolvingPower();
/**
* 獲取游戲顏色數
* @return
*/
public abstract int getTotalColor();
/**
* 獲取游戲類型
* @return
*/
public abstract int getGameType();
/**
* 獲取關卡數總計
* @return
*/
public abstract int getTotalMission();
////下面的方法全部針對當前關卡操作
/**
* 獲取當前關卡的字符串屬性。
* 每個屬性含意由具體實現定義
* @return
*/
public abstract String[] getMissionProperties();
/**
* 獲取當前關卡地圖的大小,以像素為單位,返回數組第一個元素為X軸大小,第二個元素為Y軸大小
* @return
*/
public abstract int[][][] getMapSize();
/**
* 獲取可通行區域地圖數組。第一維表示高度,第二維表示寬度,以貼圖為單位
* 數組元素中true代表可通過,false代表不可通過
* @return
*/
public abstract boolean[][] getBarrierData();
/**
* 獲取可通行區域地圖數組中每個單元格的寬度,以像素為單位
* @return
*/
public abstract int getBarrierWidth();
/**
* 獲取可通行區域地圖數組中每個單元格的高度,以像素為單位
* @return
*/
public abstract int getBarrierHeight();
/**
* 獲取地面貼圖的索引數組。數組元素為貼圖的圖片索引值,以貼圖為單位;
* 假設地面橫向由m個貼圖組成,縱向由n個貼圖組成,則返回int[n][m]
* @return
*/
public abstract short[][] getTilesIndex();
/**
* 獲取地面貼圖的圖片寬度,以像素為單位
* @return
*/
public abstract int getTileWidth();
/**
* 獲取地面貼圖的圖片高度,以像素為單位
* @return
*/
public abstract int getTileHeight();
/**
* 獲取地圖上的精靈索引。
* <pre>
* 假設地圖中有n個精靈,
* 則返回數組:int[n][6]
* 第n個精靈的數據:
* int[n][0] = 精靈的初始化X坐標
* int[n][1] = 精靈初始化Y坐標
* int[n][2] = 精靈的幀寬度
* int[n][3] = 精靈的幀高度
* int[n][4] = 精靈圖片的索引值
* int[n][5] = 精靈類型(ITEM=0x01, NPC=0x02, Tree & Structure=0x03, Other=0xFF)
* <pre>
* @return 返回二維整型數組
*/
public abstract int[][][] getSpritesData();
/**
* 返回玩家角色的基本數據
* int[0] = 圖片索引ID
* int[1] = 幀寬度
* int[2] = 幀高度
* int[3] = 檢測盒左上角X坐標,相對于角色位置的相對坐標,以像素為單位
* int[4] = 檢測盒左上角Y坐標,相對于角色位置的相對坐標,以像素為單位
* int[5] = 檢測盒高度
* int[6] = 檢測盒寬度
* @return int[7]
*/
public abstract int[] getPlayerInfo();
/**
* 獲取玩家角色的附加數值屬性。
* 這里的屬性個數不定,但均按預先設定的順序保存,即開發者可通過事先約定的索引值獲取特定屬性;
* 屬性含意由具體業務邏輯解析,本類中不對屬性內容解析處理
* @return
*/
public abstract int[] getPlayerNumProp();
/**
* 獲取玩家角色的附加字符串屬性。
* 這里的屬性個數不定,但均按預先設定的順序保存,即開發者可通過事先約定的索引值獲取特定屬性;
* 屬性含意由具體業務邏輯解析,本類中不對屬性內容解析處理
* @return
*/
public abstract String[] getPlayerStrProp();
/**
* 獲取圖片
* @param id
* @return
*/
public abstract Image findImage(int id);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -