?? mycanvas.java~102~
字號:
text.setText(2, "癡情就幫你吧!");
break;
case 33:
text.setText(0, "諾奇奧尼:謝謝你了!");
break;
case 34:
text.setText(0, "胡爾:先別謝的那么快");
text.setText(1, ",你要答應我件事,在");
text.setText(2, "附近的河旁有個叫薩耶");
break;
case 35:
text.setText(0, "的人,他打賭輸了欠我");
text.setText(1, "一種藥材。你幫我要過");
text.setText(2, "來!");
break;
case 36:
text.setText(0, "諾奇奧尼:成!好的!");
text.setCanEnd(true); //與胡爾第一次對話結束
process = 3;
break;
case 37: //========== 與胡爾第二次對話
text.setText(0, "胡爾:站在這傻愣干嘛");
text.setText(1, ",還不快去!");
text.show();
text.setCanEnd(true); //此次對話結束
break;
case 38: //========== 與薩耶第一次對話
text.setText(0, "諾奇奧尼:你就是薩耶");
text.setText(1, "?");
text.show();
break;
case 39:
text.setText(0, "薩耶:嗯,就是我!");
break;
case 40:
text.setText(0, "諾奇奧尼:那就好了~");
text.setText(1, "是胡爾叫我來的,他說");
text.setText(2, "你欠他一種藥材,叫我");
break;
case 41:
text.setText(0, "幫他拿過去!");
break;
case 42:
text.setText(0, " …………");
break;
case 43:
text.setText(0, "欲知后事如何");
text.setText(1, " 請聽下回分解");
text.setCanEnd(true); //此次對話結束
process = 4;
SlideState = 3;
break;
case 44:
text.setText(0, "…………");
text.show();
text.setCanEnd(true); //此次對話結束
break;
case 45:
text.setText(0, "");
break;
case 46:
text.setText(0, "");
break;
case 47:
text.setText(0, "");
break;
case 48:
text.setText(0, "");
break;
case 49:
text.setText(0, "");
break;
case 50:
text.setText(0, "");
break;
}
dialogOn = false;
}
if (text.getTextState() == 3 && confirm == true) {
dialogID++;
dialogOn = true;
confirm = false;
}
}
public void SwitchScene() {
switch (SlideState) {
case 0: //沒有漸變,繼續判斷主角是否走到場景切換點
switch (scene) {
case 0: //戰斗頁面
break;
case 1: //在大地圖中( 1 號地圖)
if (hero.getNextGrid() == 15 ||
hero.getNextGrid() == 14) {
toScene = 2; //開始漸變,漸變完進入場景 2
SlideState = 3;
}
//當在泉水附近并面向泉水時,飲用泉水,恢復體力
if (hero.getNextGrid() == 39 && hero.getFaceDir() == 1 ||
hero.getNextGrid() == 39 && hero.getFaceDir() == 2 ||
hero.getNextGrid() == 40 && hero.getFaceDir() == 1 ||
hero.getNextGrid() == 45 && hero.getFaceDir() == 2 ||
hero.getNextGrid() == 45 && hero.getFaceDir() == 3 ||
hero.getNextGrid() == 46 && hero.getFaceDir() == 3) {
if (confirm) { //按下確定時
//提示身體恢復
if (text.getTextState() == 0) { //此時沒有顯示文本時
text.emptyText();
text.setText(0, "啊,這小泉水真甜!");
text.setText(1, "混身頓時一身輕松。");
text.show();
text.setCanEnd(true);
}
hero.restoreHPMP(); //恢復生命體力
confirm = false;
}
}
break;
case 2:
if (hero.getNextGrid() == 86 || //在門口處
hero.getPosX() == 120 && hero.getPosY() == 100 &&
hero.getFaceDir() == 2 ||
hero.getPosX() == 120 && hero.getPosY() == 92 &&
hero.getFaceDir() == 2 ||
hero.getPosX() == 128 && hero.getPosY() == 96 &&
hero.getFaceDir() == 2) {
toScene = 1; //開始漸變,漸變完進入場景 1
SlideState = 3;
}
//在房間中( 2 號地圖)
break;
}
break;
case 1: //漸入(由暗變亮)
case 2: //漸出(由亮變暗)
if (switchFightState == 1 ||
switchFightState == 2)
break;
case 3: //變暗后轉換場景
if (process == 4 && text.getTextState() == 0) { //是否劇情結束
gameState = 0; //設為菜單頁
menu.setGameStarted(false);
return;
}
switch (toScene) {
case 0: //場景與戰斗畫面的切換
if (switchFightState == 1) { //場景->戰斗,亮->暗
toScene = sceneAfterFight; //先保存戰斗前所在的場景號
switchFightState = 2; //進入戰斗畫面前也有漸變
SlideState = 0;
} else if (switchFightState == 3) { //戰斗->場景,亮->暗
switchFightState = 4; //進入場景頁面也有漸變
SlideState = 0;
}
break;
case 1: //即將切換到 1 號地圖
hero.loadScene(scene, 1); //切換到 1 號地圖
scene = 1;
SlideState = 0;
break;
case 2: //即將切換到 2 號地圖
hero.loadScene(scene, 2);
scene = 2;
SlideState = 0;
break;
}
break;
}
}
/////////////////////////////////////////////////////////////////////
public void keyPressed(int keyCode) {
System.out.println("---------------------------------");
System.out.println("scene = " + scene);
System.out.println("SlideState = " + SlideState);
System.out.println("gameState = " + gameState);
if (SlideState == 0) { //只有在沒有漸變的情況下才可以響應按鍵信息
if (firstBoot) {
firstBoot = false;
dialogOn = true;
}
switch (keyCode) {
case FIRE:
confirm = true; //按下確定
break;
}
switch (gameState) {
case 0: //菜單頁
menu.keyPressed(keyCode);
break;
case 1: //游戲頁
if (text.getTextState() == 0) //不顯示對話框時才能響應
hero.keyPressed(keyCode);
text.keyPressed(keyCode);
break;
}
}
}
protected void keyReleased(int keyCode) {
hero.keyReleased(keyCode);
confirm = false;
}
protected void paint(Graphics g) {
// System.out.println("---------------------------------");
// System.out.println("scene = " + scene);
// System.out.println("SlideState = " + SlideState);
// System.out.println("gameState = " + gameState);
Graphics tg = g;
g = gg;
//*****************************【PAINT START】************************
ClearScreen(g);
//游戲處理
switch (gameState) {
case 0: //菜單頁
menu.draw(g);
if (menu.isGameStarted()) { //游戲開始
hero.reset();
dialogOn = false;
dialogID = 1;
gameState = 1;
hero.loadScene(0, 2);
scene = 2;
SlideState = 0;
switchFightState = 4;
firstBoot = true;
}
break;
case 1: //游戲頁
if (hero.isFighted()) { //已觸發戰斗,或正在戰斗
if (hero.isDead()) {
gameState = 0; //主角死亡,回到游戲菜單
menu.reset();
}
if (scene != 0) { //已經觸發戰斗,但還在場景頁面漸變
toScene = 0; //即將切換到戰斗畫面
sceneAfterFight = scene; //記錄戰斗完后應該返回的場景號
scene = 0; //此次戰斗這條 if 語句不再執行
SlideState = 3;
switchFightState = 1; //場景->戰斗
}
} else { //處于場景頁面
if (scene == 0) {
scene = toScene; //漸變完后回到原來場景
toScene = 0; //戰斗結束漸暗處理完,即將處理變暗后的場景轉換
SlideState = 3;
switchFightState = 3; //戰斗->場景
}
}
switch (switchFightState) {
case 1: //場景->戰斗,亮->暗 應該:場景畫面
case 4: //戰斗->場景,暗->亮 應該:場景畫面
hero.drawMap(g);
hero.drawNPC(g);
hero.drawPlayer(g);
checkTalk(); //是否主角觸發了對話
setDialog(); //設置對話內容
break;
case 2: //場景->戰斗,暗->亮 應該:戰斗畫面
case 3: //戰斗->場景,亮->暗 應該:戰斗畫面
hero.drawBattle(g);
break;
}
SwitchScene();
text.paint(g);
break;
}
//******************************【PAINT END】**************************
g = tg;
g.drawImage(this.imgBuffer, 0, 0, 20);
}
/**
* 畫菜單
* @param g Graphics
*/
public void run() {
while (running) {
long start = System.currentTimeMillis();
try {
this.game_logic();
this.repaint();
this.serviceRepaints();
} catch (Exception e) {
e.printStackTrace();
}
;
long end = System.currentTimeMillis();
if ((80 - (end - start)) > 0) {
try {
thread.sleep(80 - (end - start));
} catch (InterruptedException ex) {
}
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -