Magic-Towers
目錄
一、團隊名稱、團隊成員介紹、任務分配
團隊名稱:MoTa
團隊成員介紹
網絡1713柳聰靈【組長】 201721123065
網絡1712李夢冰 201721123040
網絡1713蘭景暉 201721123064
任務分配
網絡1713柳聰靈【組長】--Model
- 游戲布局及障礙物的編碼及方法定義
- 游戲里的道具:鑰匙、葯水的編碼及方法定義
- 游戲npc的編碼及方法定義
- 畫UML類圖
網絡1713蘭景暉 --View
- 游戲道具及場景的視圖
- GUI界面設計:主界面、各類彈窗
網絡1712李夢冰 --Controller
- 玩家數據I/O流
- 游戲內部監聽器:存檔、選角色、退出
- 游戲地圖數據
- 編寫團隊博客
二、項目簡介
《魔塔》是一種策略類的固定數值RPG游戲。游戲需要動很多腦筋,任何一個輕率的選擇都可能導致游戲的失敗。魔塔游戲雖不大,但是制作精美,道具很多,而且難度不低,對智商是一次艱巨的考驗。雖然魔塔的界面很像是一般的地牢游戲,貌似隨便的打打殺殺就可以過關,但事實上玩這個游戲需要動很多腦筋,任何一個輕率的選擇都可能導致游戲的失敗,該游戲有屬性攻擊、防御、生命、金幣、經驗。
三、項目采用技術
- 文件I/O流
- 多線程
- GUI
四、項目亮點
主界面顯示主要信息功能
游戲動畫
-
攻擊者自由移動並有向不同方向移動的動作
-
攻擊者生命力減少及怪物消失
-
各個怪物有規律跳動
-
開門成功后門碎裂
-
全家福
五、項目關鍵代碼
數據I/O流功能
/*
游戲過程中,玩家由於各種原因需要退出終止游戲,但是還想下次繼續游戲。所以設計了游戲進度的保存/讀取的功能。使用了FileOutputStream、BufferedOutputStream、 ObjectOutputStream結合使用。
*/
public class PlayerFile {
public static final void savePlayer(Player player) {//保存玩家數據
//try-with-resource
try ( FileOutputStream out = new FileOutputStream("player.dat");
BufferedOutputStream bout = new BufferedOutputStream(out);
ObjectOutputStream obout = new ObjectOutputStream(bout);) {
obout.writeObject(player);
} catch (IOException e) {
}
}
public static final Player readPlayer() {//讀取玩家數據
Player player = null;
try (FileInputStream in = new FileInputStream("player.dat");
BufferedInputStream bin = new BufferedInputStream(in);
ObjectInputStream obin = new ObjectInputStream(bin);) {
player = (Player) obin.readObject();
} catch (IOException e) {
} catch (ClassNotFoundException e) {
}
return player;
}
}
游戲動作監聽器功能(部分)
/**
* 人物碰觸格子
*/
private void contact(int x, int y) {
// 坐標對應第y行第x列
if (mapData[y][x].contact(player)) {
// 可以通過時
Component component = mapView.getComponent(x + y * 11);
// 獲取該位置組件並判斷是否為門
if (mapData[y][x] instanceof Door) {
mapData[y][x] = Floor.FLOOR;
inofView.update();
mainView.setVisible(true);
((DoorView) component).show();
return;
}
mapView.remove(playerView);
mapView.add(new FloorView(), player.getX() + player.getY() * 11);
mapView.remove(x + y * 11);
mapView.add(playerView, x + y * 11);
player.setCoord(x, y);
// 通過后顯示提示
showInof(x, y);
if (mapData[y][x].getType() != Stairs.STAIRS_TYPE_DOWN_BIRTH
&& mapData[y][x].getType() != Stairs.STAIRS_TYPE_UP_BIRTH) {
mapData[y][x] = Floor.FLOOR;
player.getMapDataList().get(player.getNowFloor() - 1)[y][x] = 0;
}
} else {//不能通過
noEntryInof(x, y);
}
}
門及怪物的動畫消失代碼
六、項目git地址及個人博客地址
git地址
聰靈博客地址
夢冰博客地址
景暉博客地址
七、項目git提交記錄截圖(要體現出每個人的提交記錄、提交說明)
八、項目Issue記錄截圖
九、項目功能架構圖與主要功能流程圖
十、UML類圖
十一、代碼靜態掃描
第一次掃描
全部解決
十二、尚待改進或者新的想法
本次課設我們組最大的遺憾是沒有把網絡和數據庫的技術運用到,這一點尚待改進。
我們還有將地圖規划到50層的想法。