import javax.microedition.lcdui.*; import java.io.*; import java.lang.*; import java.util.Timer; import popup.*; import java.util.Random; import java.util.Vector; import javax.microedition.media.*; public class SwordCanvas extends Canvas implements PopupListener { static int life,energy,skillpoint,x,y,maxlife,maxenergy; static int level; static int experience; static int gold; static int direction; static int basicPower; int totalPower; int[] skillArray,tn; int addMagic,addPower; int stealB; int addPdP; int curNPC; int speed=4; int count; int[] weapon; int curKey; boolean isUpdated; static int[] startX,startY; int curweapon; int curEl; boolean isTask,isTask2; boolean hasBoat; boolean isHiding; boolean isGameOver; boolean tran; boolean isWalking; boolean[] dlg; String[] dlgMenu; boolean isWin,isDie; String strTip; String strDlg; String strPro; String[] attackMenu=new String[]{ "落日","乱电", "残风", "召狼", "召熊", "召龙", "隐身","遁走", "附身", "回血", "补气", "攻击"}; int offY,offX; int dlgn; int dlgMenuChoose; static Image imgHero; static int w,h; static int x0,y0,sl=0,i,j; int killCount; static int[] W,H; int[] mapArray; int[] spriteNum; static int[] screenStart=new int[]{16,29,33,47,68,77,83}; int sx,sy; int sn; Sprite[] SPI; Sprite[] NPC; int attackNumber; int nn; boolean isProMenu,isAttMenu,isTranMenu; boolean isFighting; boolean isTalking; boolean isChange; boolean isGameMenu; int step; static boolean running; String[] dlgM; static Image screenPic; static Image imgNPC; static Image imgProBG,imgState; InputStream is; Vector winString=new Vector(0,1); //static Image[] p; static Image[] screen; static Image[] spic; static Image atpic,imgAttackBG; static Image spic0; Image imgDlg; static Image[] sword; String[] mapName=new String[]{"牛家村","冰火岛 ","大智岛","襄阳城","蓬莱岛","竞技场"}; boolean updateMan; static Graphics g1; Random rand; Player mapPlayer,attPlayer; boolean isWeather; int offsetY=36; Timer timer; int[][] snow=new int[30][30]; TimerTask moveTask,attackTask,attackControlTask,changeMapTask,weatherTask; protected Popup popup; protected String helpStr = "游戏背景:"+ "\n\n" + "高手是寂寞的;而磨砺自身成为高手的过程,则是孤独的。"+ "\n\n" + "操作方法:"+ "\n\n" + "游戏中用方向键和2、4、6、8键控制主角移动以及进行菜单选择,5键或OK键选定,3键调出/关闭属性菜单,左软键调出操作菜单,可查看帮助信息,保存游戏或回到主菜单。"+ "\n\n" + "关键提示:"+ "\n\n" + "玩家每次升级将得到一点技能属性用来学习技能,每项技能所能修炼的最高等级受主角等级限制,技能等级越高,效果越显著。使用“召狼”等技能时,召唤出的宠物将被优先攻击。使用技能会消耗主角的“气力”,“回气”技能将耗费一定数量的金钱。主角战死会损失一定比例的经验及金钱。"+ "\n\n" + "在战斗过程中菜单选项将不会响应。"+ "\n\n" + "招式详解:"+ "\n\n" + "落日:用内力聚成一个落日,对单个敌人造成极大伤害。"+ "\n\n" + "乱电:在天空中形成流星般的巨石,砸向全部敌人。"+ "\n\n" + "残风:耗费自身的血和气来形成一股飓风,对全部敌人造成较大伤害。"+ "\n\n" + "召狼:召唤精灵狼来辅助战斗,生命力较弱但攻击力很强。"+ "\n\n" + "召熊:召唤精灵熊来辅助战斗,攻击力很弱但生命力较强,可以用作战斗中的护盾。"+ "\n\n" + "召龙:召唤神龙来辅助战斗,可以反弹敌人部分攻击并反伤敌人。"+ "\n\n" + "隐身:在数回合内主角将不受攻击,但使用附身或攻击敌人则会失效。"+ "\n\n" + "遁走:从战斗中直接逃走,技能等级高则逃走成功率大。"+ "\n\n" + "附身:召唤影子与主角并肩作战,使主角生命力和攻击力按比例上升。"+ "\n\n" + "回血:恢复主角一定比例的生命力。"+ "\n\n" + "回气:恢复主角一定比例的气力,但要耗费一定量的金钱。"; public SwordCanvas() { setFullScreenMode(true); running=true; w = getWidth(); h= getHeight()-offsetY; } void init() { isGameOver = false; i=0; level=1; experience=0; skillpoint=0; basicPower=7; gold=0; maxlife=71; life=71; energy=40; maxenergy=40; direction=6; addMagic=0; addPower=0; stealB=0; addPdP=0; curweapon=9; totalPower=basicPower+addPower+addPdP*basicPower/100; weapon=new int[]{9,9,9,9,9,9}; skillArray=new int[]{0,0,0,0,0,0,0,0,0,1,0}; spriteNum=new int[]{60,28,153,76,16,2,0}; startX=new int[]{464,144,32,192,32,128,16}; startY=new int[]{448,432,224,320,144,176,112}; dlg=new boolean[]{false,false,false,false,false,false,false}; tn=new int[]{0,0,0,0,0}; W=new int[]{32,32,32,24,24,16,16}; H=new int[]{32,32,32,24,24,18,18}; if(sl==0) { if(dlg[0]) { x=startX[0]; y=startY[0]; message(2); } else { x=384; y=304; } } else { x=startX[sl]; y=startY[sl]; } if(x>=w/2) { if(x<=W[sl]*16-w/2) x0=x-w/2; else x0=W[sl]*16-w; } else x0=0; if(y>=h/2) { if(y<=H[sl]*16-h/2) y0=y-h/2; else y0=H[sl]*16-h; } else y0=0; isTask=false; isTask2=false; hasBoat=false; isDie=false; isWin=false; isWalking=false; isHiding=false; tran=false; isProMenu=false; isAttMenu=false; isFighting=false; isChange=false; isGameMenu=false; isTalking=false; strTip=null; strDlg=null; SPI=new Sprite[8]; timer=new Timer(); rand=new Random(1000); changeMapTask=null; is=getClass().getResourceAsStream("/Screen"+toString(sl)+".dat"); readMap(is); if(spriteNum[sl]!=0) { is=getClass().getResourceAsStream("/sprite"+toString(sl)+".dat"); readSprite(is); } if(sl==0&&!dlg[0]) message(2); weatherTask=new TimerTask(this,-2); timer.schedule(weatherTask,0,400); } void readSprite(InputStream s) { int i,c,temp; i=0; c=0; temp=0; NPC=null; NPC=new Sprite[spriteNum[sl]]; try { while((c=s.read())!=-1) { switch(c) { case ',': NPC[i++]=new Sprite( temp/10000, temp%10000/100, temp%100); temp=0; break; default: temp=10*temp+c-48; break; } } } catch(java.io.IOException ioe) { } is=null; } void readMap(InputStream s) { int x,y,c,temp; x=0; y=0; temp=0; mapArray=null; mapArray=new int[W[sl]*H[sl]]; int i = 0; try { while((c=s.read())!=-1) { switch(c) { case '\n': y++; x=0; temp=0; break; case ',': mapArray[y*W[sl]+x++]=temp; temp=0; break; default: temp=10*temp+c-48; break; } } } catch(java.io.IOException ioe) { } if(sl==3) { x=getRandom(96)+72; if(mapArray[x]/100==1) { mapArray[x]=mapArray[x]%100+9800; { if(mapArray[x+1]/100==1) mapArray[x+1]=mapArray[x+1]%100+1800; if(mapArray[x-1]/100==1) mapArray[x-1]=mapArray[x-1]%100+1900; if(mapArray[x-24]/100==1) mapArray[x-24]=mapArray[x-24]%100+1600; if(mapArray[x+24]/100==1) mapArray[x+24]=mapArray[x+24]%100+1700; } } x=getRandom(96)+264; if(mapArray[x]/100==1) { mapArray[x]=mapArray[x]%100+9800; { if(mapArray[x+1]/100==1) mapArray[x+1]=mapArray[x+1]%100+1800; if(mapArray[x-1]/100==1) mapArray[x-1]=mapArray[x-1]%100+1900; if(mapArray[x-24]/100==1) mapArray[x-24]=mapArray[x-24]%100+1600; if(mapArray[x+24]/100==1) mapArray[x+24]=mapArray[x+24]%100+1700; } } } else if(sl==6) { for(int ii=0;ii<256;ii++) { if(mapArray[ii]/100==1) mapArray[ii]=mapArray[ii]%100+(getRandom(100)<70?(getRandom(3)+16)*100:100); } } is=null; } public void keyRepeated(int keyCode) { int action=getGameAction(keyCode); if(action==Canvas.UP||action==Canvas.DOWN||action==Canvas.LEFT||action==Canvas.RIGHT) keyPressed(keyCode); } public void keyPressed(int keyCode) { int action=getGameAction(keyCode); if (popup!=null&&popup.isActive()) { popup.keyPressed(keyCode, action); repaint(); return; } if(keyCode==35) MenuCanvas.midlet.exit(); curKey=keyCode; if(!isChange) { switch(action) { case GAME_B: if(!isWin&&!isDie&&!isChange&&!isTranMenu&&!isTalking&&!isGameMenu&&moveTask==null) { isProMenu=!isProMenu; offY=0; offX=0; i=0; j=0; repaint(); } break; case UP: if(isGameMenu) { i=i-1>=0?i-1:0; repaint(); } else if(!isProMenu&&!isTranMenu&&!isWin&&!isDie&&!isTalking&&strTip==null&&!isFighting) { if(moveTask==null) { if(direction/3!=2) { direction=6; repaint(); } else setMoveTask(); } } else if(isProMenu) { strPro=null; offY=0; j=0; i=i-1>=0?i-1:3; repaint(); } else if(isTranMenu) { if(dlg[2]) i=i-1>=0?i-1:5; else if(isTask) i=i-1>=0?i-1:4; else i=i-1>=0?i-1:3; repaint(0,0,128,128); } else if(isAttMenu) { i=i-4>=0?i-4:i+8; repaint(); } else if(isTalking&&strTip==null)//对对话菜单的操作 { if(curNPC==6||curNPC==4||curNPC==5) dlgMenuChoose=dlgMenuChoose-1>=0?dlgMenuChoose-1:dlgMenu.length-1; repaint(); } break; case DOWN://下键 if(isGameMenu) { i=i+1<=4?i+1:4; repaint(); } else if(!isProMenu&&!isFighting&&!isTranMenu&&!isWin&&!isDie&&!isTalking&&strTip==null) { if(moveTask==null) { if(direction/3!=1) { direction=3; repaint(); } else setMoveTask(); } } else if(isProMenu) { strPro=null; offY=0; i=i+1<4?i+1:0; j=0; repaint(); } else if(isTranMenu) { if(dlg[2]) i=i+1<6?i+1:0; else if(isTask) i=i+1<5?i+1:0; else i=i+1<4?i+1:0; repaint(); } else if(isAttMenu) { i=i+4<12?i+4:i-8; repaint(); } else if(isTalking&&strTip==null)//对话时候的菜单选项 { if(curNPC==6||curNPC==4||curNPC==5) dlgMenuChoose=dlgMenuChoose+1<=dlgMenu.length-1?dlgMenuChoose+1:0; repaint(); } break; case LEFT://左键 if(isProMenu) { if(i==2) j=j-1>=0?j-1:10; else if(i==1&&j>0) for(int ii=j-1;ii>=0;ii--) { if(weapon[ii]!=9) { offY=0; j=ii; break; } } repaint(); } else if(!isProMenu&&!isFighting&&!isTranMenu&&!isWin&&!isDie&&!isTalking&&strTip==null&&!isGameMenu) { if(moveTask==null) { if(direction/3!=0) { direction=0; repaint(); } else setMoveTask(); } } else if(isAttMenu) { i=i-1>=0?i-1:11; repaint(); } else if(isTalking&&strTip==null) { if(curNPC==6||curNPC==4||curNPC==5) i=i-1>=0?i-1:0; repaint(); } break; case RIGHT://右键 if(isProMenu) { if(i==2) { j=j+1<11?j+1:0; repaint(); } else if(i==1) { for(int ii=j+1;ii<6;ii++) { if(weapon[ii]!=9) { offY=0; j=ii; break; } } repaint(); } } else if(!isProMenu&&!isTranMenu&&!isFighting&&!isWin&&!isDie&&!isTalking&&strTip==null&&!isGameMenu) { if(moveTask==null) { if(direction/3!=3) { direction=9; repaint(); } else setMoveTask(); } } else if(isAttMenu) { i=i+1<=11?i+1:0; repaint(); } else if(isTalking&&strTip==null)//对话时候的菜单选项 { if(curNPC==6||curNPC==4) i=i+1<=1?i+1:0; else if(curNPC==5) { switch(sn) { case 1: i=i+1<=2?i+1:0; break; case 2: i=i+1<=1?i+1:0; break; default: break; } } repaint(); } break; case FIRE: FIRE(); break; default: switch(keyCode) { case KEY_NUM1://1键取消 // if(isAttMenu&&!isProMenu) // { // isAttMenu=false; // attackNumber=4; // repaint(); // } // else if(isProMenu&&i==2) { gold+=(weapon[j]%3+1)*(weapon[j]%3+1)*100; if(curweapon==weapon[j]) curweapon=9; weapon[j]=9; addPower=0; addMagic=0; addPdP=0; totalPower=basicPower; repaint(0,0,240,309); } break; case -6: FIRE(); break; default: break; } break; } } } public void FIRE() { if(isGameOver){ MenuCanvas.loadResource(); SwordMIDlet.show(SwordMIDlet.menuCanvas); MenuCanvas.se.stopSound(mapPlayer); } if(isGameMenu) { if(i==4) { isGameMenu=!isGameMenu; repaint(); } else if(i==3) { SwordStore store=new SwordStore(); store.save(); store=null; isGameMenu=false; screen=null; MenuCanvas.loadResource(); SwordMIDlet.show(SwordMIDlet.menuCanvas); MenuCanvas.se.stopSound(mapPlayer); } else if(i==0) {if(popup == null)popup = new Popup(); showPopup(helpStr.toCharArray(), Popup.ALT_OK, 0, 0, 0); } else if(i==2) { MenuCanvas.isAudioOn=!MenuCanvas.isAudioOn; if(MenuCanvas.isAudioOn) MenuCanvas.se.playSound(mapPlayer); else MenuCanvas.se.pauseSound(mapPlayer); isGameMenu=false; repaint(); } else { SwordStore store=new SwordStore(); store.save(); store=null; isGameMenu=false; repaint(); } } else if(isProMenu) { if(i==2&&skillpoint>0&&skillArray[j]<10) { if(skillArray[j]==0||level>=3*skillArray[j]) { if(j==9||j==10||j==7) { if(skillArray[j]<5) { skillArray[j]++; skillpoint--; } } else { skillArray[j]++; skillpoint--; } } repaint(0,0,160,128); } else if(i==3) { if(weapon[j]!=9) { curweapon=weapon[j]; addMagic=0; addPower=0; addPdP=0; switch(curweapon) { case 0: addPower=5; stealB=10; break; case 1: addPower=10; stealB=25; break; case 2: addPower=15; stealB=45; break; case 3: addMagic=10; break; case 4: addMagic=20; break; case 5: addMagic=30; break; case 6: addPdP=15; break; case 7: addPdP=25; break; case 8: addPdP=35; break; default: break; } totalPower=basicPower+addPower+addPdP*basicPower/100; if(isFighting) SPI[0].basicPower=totalPower; repaint(); } } } else if(isTranMenu) { if(sl!=i) { if(sl!=0) { if(gold>=100) { gold-=100; changeMap(i); } else { strTip="银两不够"; isTranMenu=false; repaint(); } } else changeMap(i); } else { isTranMenu=false; repaint(); } } else if(isAttMenu) { if((i<11&&skillArray[i]>0)||i==11) setAttack(i); } else if(strTip!=null) { strTip=null; strDlg=null; imgDlg=null; repaint(); } else if(isTalking) { if(curNPC<2) { if(sn==dlgM.length-1) { isTalking=false; dlg[curNPC]=true; imgDlg=null; } else { sn++; createDialogImage(dlgM[sn]); } repaint(); } else switch(curNPC) { case 2: if(sn==2) { dlg[curNPC]=true; imgDlg=null; isTalking=false; changeMap(5); } else { sn++; createDialogImage(dlgM[sn]); repaint(); } break; case 3: if(sn==5) { gold+=10000; isTask2=true; sn++; } else if(sn==6||sn==7) { //removeCommand(con); isTalking=false; dlg[curNPC]=true; imgDlg=null; } else { sn++; createDialogImage(dlgM[sn]); } repaint(); break; case 6://船工 if(dlgMenuChoose==0) { if(hasBoat) { strTip="你已经有船了"; isTalking=false; } else if(gold>=600) { gold-=600; hasBoat=true; isTalking=false; strTip="买卖成功"; } else { strTip="银两不够"; isTalking=false; } } else { isTalking=false; imgDlg=null; } repaint(); break; case 5://洪七公 switch(sn) { case 0: if(dlgMenuChoose==0) { sn=1; dlgMenu=new String[2]; dlgMenu[0]="现在分配"; dlgMenu[1]="以后再说"; } else if(dlgMenuChoose==1) { dlgMenu=null; isTask=true; sn=2; } else { isTalking=false; imgDlg=null; return; } createDialogImage(dlgM[sn]); repaint(); break; case 2: { isTalking=false; imgDlg=null; //removeCommand(con); } repaint(); break; case 1: if(dlgMenuChoose==0) { if(gold>=10000) { gold-=10000; for(int ii=0;ii<11;ii++) { while(skillArray[ii]>0) { skillArray[ii]--; skillpoint++; } } isTalking=false; imgDlg=null; //removeCommand(con); } else { strTip="银两不够"; isTalking=false; } } else { isTalking=false; imgDlg=null; } repaint(); break; default: break; } break; case 4://竞技官 if(dlgMenuChoose==0) { if(gold>=350) { gold-=350; isTalking=false; imgDlg=null; changeMap(6);//进入竞技场 killCount=0; } else { strTip="银两不够"; isTalking=false; } } else { isTalking=false; imgDlg=null; } repaint(); break; default: break; } } else if(isWin) { if(sl!=6) { isWin=false; updateMan=false; winString=new Vector(0,1); repaint(); } else { isWin=false; if(killCount==10) { gold+=10000; changeMap(3); } else repaint(); } } else if(isDie)//死亡后重生 { isDie=false; isFighting=false; life=maxlife; energy=maxenergy; experience-=(experience-getExperience(level))*20/100; gold=gold*70/100; changeMap(0); } else if(curKey==-6) { isGameMenu=true; repaint(); } } public void keyReleased(int keyCode) { int action = getGameAction(keyCode); if(action==Canvas.UP||action==Canvas.DOWN||action==Canvas.LEFT||action==Canvas.RIGHT) { isWalking=false; } } public void drawGameMenu(Graphics g) { g.setColor(0,0,100); g.fillRoundRect(71,73,86,118,30,30); g.setColor(getRandom(255),getRandom(255),getRandom(255)); g.drawRoundRect(71,73,86,118,30,30); g.setColor(0); g.drawRoundRect(70,72,88,120,30,30); g.setColor(getRandom(255),getRandom(255),getRandom(255)); g.drawRoundRect(69,71,90,122,30,30); String[] text=new String[]{"帮助说明","保存游戏",MenuCanvas.isAudioOn?"关闭音效":"打开音效","回主菜单","继续游戏"}; for(int ii=0;ii<5;ii++) { if(i==ii) MenuCanvas.ge.drawStringShadow(g,0x00ff00,0x00ff00,0,text[ii],113,ii*20+80,g.HCENTER|g.TOP); else MenuCanvas.ge.drawStringShadow(g,0,0,-1,text[ii],113,ii*20+80,g.HCENTER|g.TOP); } } public int getRandom(int n) { int r =rand.nextInt(); if(r<0) r=-r; r=r%n; return r; } public void drawWeather(Graphics g1) { switch(weatherTask.s) { case 0://雨天 int energy=-10; if(isWeather) energy=-10+getRandom(5); g1.setColor(-1); for(int j=0;j<14;j++) for(int i=energy+j;i<270;i+=30) { if(getRandom(100)<80) g1.drawLine(i,j*20,i+6,j*20+6); } break; case 1: g1.setColor(-1); if(isWeather) { for(int i=snow.length-1;i>0;i--) { for(int j=0;j<snow[0].length;j++) snow[i][j]=snow[i-1][j]; } for(int j=0;j<snow[0].length;j++) { snow[0][j]=200/snow[0].length*j+getRandom(120)-10; if(snow[0][j]>=0) snow[0][j]=snow[0][j]*100+getRandom(120); else snow[0][j]=snow[0][j]*100-getRandom(120); } } /*画雪*/ for(int i=0;i<snow.length;i++) { if(snow[i][0]/100==300) continue; for(int j=0;j<snow[0].length;j++) g1.fillArc(snow[i][j]/100,i*18+Math.abs(snow[i][j])%100,1+getRandom(2),1+getRandom(2),0,360); } break; case 2: break; } isWeather=false; } public void setMoveTask() { isWalking=true; moveTask=new TimerTask(this,7); timer.schedule(moveTask,0,50); } public void message(int ii) { i=0; dlgM=null; dlgMenu=null; isTalking=true; curNPC=ii-2; switch(ii) { case 2: dlgM=new String[7]; dlgM[0]="尹风:如今奸臣当道,国家有难,匹夫有责.郭大侠苦守襄阳,为夫决意前往助守襄阳"; dlgM[1]="晶晶:官人做得对。"; dlgM[2]="尹风:此去不知何时才能回,娘子要保重身体."; dlgM[3]="晶晶:官人一路上要多加小心"; dlgM[4]="尹风:夫君记住了"; dlgM[5]="晶晶:......(呜咽)"; dlgM[6]="晶晶:大事为重,不用挂念我."; break; case 3: dlgM=new String[1]; dlgM[0]="前方是土匪出没,危害乡民,请不要轻易前往"; break; case 4: dlgM=new String[3]; dlgM[0]="黄药师:你从很远的地方来的,是为了找郭靖吧!"; dlgM[1]="尹风:是,求仙人指点。"; dlgM[2]="黄药师:好,随我来"; break; case 5:// dlgM=new String[9]; dlgM[0]="尹风:郭大侠,不才愿助您驻守襄阳!"; dlgM[1]="郭靖:现在有一件很重要的事需要你的帮忙。"; dlgM[2]="尹风:大侠请说!"; dlgM[3]="郭靖:马上就到冬季,将士们需要100件去寒之物。"; dlgM[4]="尹风:这个好办,我来的路上经过一个荒岛,上面野兽众多,找点皮毛还不容易。"; dlgM[5]="郭靖:这样便好,那就托付与你了,这些银两你带上。"; dlgM[6]="获得银两10000"; dlgM[7]="郭靖:早去早回。"; dlgM[8]="郭靖:太好了,有了这些虎皮,整个冬天都不怕了,过了这个冬天就是复我河山之时!"; break; case 6: dlgM=new String[1]; dlgMenu=new String[2]; dlgM[0]="你希望参加这个勇士的竞技吗?需要收取350两费用,竞技必须是杀死所有野兽才会停止."; dlgMenu[0]="参加"; dlgMenu[1]="离开"; break; case 7://洪七公 dlgM=new String[3]; dlgM[0]="最近老觉得身体不好,本想自己去收集些药引,可是力不从心了,希望你可以帮助我,我将会给你一些报酬"; dlgM[1]="重新分配技能点需要10000两,交纳费用后你可以将技能点重新分配"; dlgM[2]="在荒岛收集10粒九花玉露丸,5棵通天草,在大智岛收集10棵千年人参,在蓬莱收集5个灵芝"; dlgMenu=new String[3]; dlgMenu[0]="分配技能"; dlgMenu[1]="接受任务"; dlgMenu[2]="离开这里"; break; case 8://船工 dlgM=new String[1]; dlgMenu=new String[2]; dlgMenu[0]="购买"; dlgMenu[1]="离开"; dlgM[0]="在这里你找不到比我这更好的船了!船只价格是600两,你赶紧买吧!"; break; } if(!dlg[ii-2]) sn=0; else if(ii<5) sn=dlgM.length-1; else if(ii==5) { if(tn[4]==20) sn=7; else sn=6; } else sn=0; createDialogImage(dlgM[sn]); repaint(); } public void update(Vector string) { if(sl==6) killCount++; if(curEl!=15) { String temp; temp=null; boolean out=false; string.addElement((String)("获得金钱:"+String.valueOf(nn)));//更新金钱 string.addElement((String)("获得经验:"+String.valueOf(sn)));//更新经验值 gold+=nn; while(true) { if(experience+sn>=getExperience(level+1)) { level++; skillpoint++; out=true; energy=20*level+20; maxenergy=energy; maxlife=level*level+10*level+60; life=maxlife; basicPower=5*level+2; totalPower=basicPower+addPdP*basicPower/100+addPower; } else break; } experience+=sn; if(out) string.addElement((String)("人物等级提升到第"+String.valueOf(level)+"级"));//更新等级 for(int iii=0;iii<6;iii++) { if(weapon[iii]==9) { int ii=getRandom(100); switch(curEl) { case 2: if(ii<=2&&ii>=0&&!hasWeapon(0)) { weapon[iii]=0; temp="承影剑"; } else if(ii<=6&&ii>=3&&!hasWeapon(3)) { weapon[iii]=3; temp="干将莫邪剑"; } break; case 3: if(ii<=5&&ii>=0&&!hasWeapon(0)) { weapon[iii]=0; temp="承影剑"; } else if(ii<=10&&ii>=6&&!hasWeapon(3)) { weapon[iii]=3; temp="干将莫邪剑"; } else if(ii<=14&&ii>=11&&!hasWeapon(6)) { weapon[iii]=6; temp="赤霄剑"; } break; case 4: if(ii<=7&&ii>=0&&!hasWeapon(0)) { weapon[iii]=0; temp="承影剑"; } else if(ii<=11&&ii>=8&&!hasWeapon(1)) { weapon[iii]=1; temp="纯钧剑"; } else if(ii<=18&&ii>=12&&!hasWeapon(3)) { weapon[iii]=3; temp="干将莫邪剑"; } else if(ii<=25&&ii>=19&&!hasWeapon(6)) { weapon[iii]=6; temp="赤霄剑"; } break; case 5: if(ii<=5&&ii>=0&&!hasWeapon(1)) { weapon[iii]=1; temp="纯钧剑"; } else if(ii<=15&&ii>=6&&!hasWeapon(3)) { weapon[iii]=3; temp="干将莫邪剑"; } else if(ii<=18&&ii>=16&&!hasWeapon(4)) { weapon[iii]=4; temp="龙渊剑"; } else if(ii<=27&&ii>=19&&!hasWeapon(6)) { weapon[iii]=6; temp="赤霄剑"; } break; case 6: if(ii<=8&&ii>=0&&!hasWeapon(1)) { weapon[iii]=1; temp="纯钧剑"; } else if(ii<=14&&ii>=9&&!hasWeapon(4)) { weapon[iii]=4; temp="龙渊剑"; } else if(ii<=17&&ii>=15&&!hasWeapon(7)) { weapon[iii]=7; temp="湛泸剑"; } break; case 7: if(ii<=10&&ii>=0&&!hasWeapon(1)) { weapon[iii]=1; temp="纯钧剑"; } else if(ii<=18&&ii>=11&&!hasWeapon(4)) { weapon[iii]=4; temp="龙渊剑"; } else if(ii<=23&&ii>=19&&!hasWeapon(7)) { weapon[iii]=7; temp="湛泸剑"; } break; case 8: if(ii<=3&&ii>=0&&!hasWeapon(2)) { weapon[iii]=2; temp="鱼肠剑"; } else if(ii<=13&&ii>=4&&!hasWeapon(4)) { weapon[iii]=4; temp="龙渊剑"; } else if(ii<=19&&ii>=14&&!hasWeapon(7)) { weapon[iii]=7; temp="湛泸剑"; } break; case 9: if(ii<=5&&ii>=0&&!hasWeapon(2)) { weapon[iii]=2; temp="鱼肠剑"; } else if(ii<=8&&ii>=6&&!hasWeapon(5)) { weapon[iii]=5; temp="泰阿剑"; } else if(ii<=15&&ii>=12&&!hasWeapon(8)) { weapon[iii]=8; temp="轩辕剑"; } break; case 10: if(ii<=7&&ii>=0&&!hasWeapon(2)) { weapon[iii]=2; temp="鱼肠剑"; } else if(ii<=13&&ii>=8&&!hasWeapon(5)) { weapon[iii]=5; temp="泰阿剑"; } else if(ii<=19&&ii>=14&&!hasWeapon(8)) { weapon[iii]=8; temp="轩辕剑"; } break; default: break; } break; } } if(temp!=null) { string.addElement((String)("获得武器:"+temp)); } if(isTask&&sl!=6&&temp==null) { temp=null; int ii; ii=getRandom(100); if(ii<30) { switch(curEl) { case 4://豺 if(tn[0]<10) { tn[0]++; temp="九花玉露丸"; } break; case 5://狼 if(tn[1]<5) { tn[1]++; temp="通天草"; } break; case 6://虎 if(tn[4]<20&&isTask2) { tn[4]++; temp="虎皮"; } break; case 9://僵尸将军 if(tn[2]<10) { tn[2]++; temp="千年人参"; } break; case 10://Boss if(tn[3]<5) { tn[3]++; temp="灵芝"; } break; default: break; } } if(temp!=null) { string.addElement((String)("获得任务物品:"+temp)); } } temp=null; if(sl==6&&killCount!=10) { string.addElement((String)("还须进行"+toString(10-killCount)+"场战斗")); } if(sl==6&&killCount==10) { string.addElement((String)("获得银子10000两")); } } else { isGameOver = true; } } public void createDialogImage(String s) { strDlg=s; dlgn=10; imgDlg=null; int dw = dlgn*15; int dh = ((s.length()-1)/dlgn+1)*20+3; if(dlgMenu!=null) dh = ((s.length()-1)/dlgn+1)*20+20; imgDlg=Image.createImage(dw,dh); if(dlgMenu!=null)//显示对话菜单 imgDlg=Image.createImage(dw,dh); g1=imgDlg.getGraphics(); g1.setFont(MenuCanvas.mFont); g1.setColor(0x9B7319); g1.fillRect(0,0,dw,dh); g1.setColor(0xffffff); g1.drawRect(0,0,dw-1,dh-1); g1=null; } public void drawDialog(Graphics g) { g.setColor(0xffffff); g.drawImage(imgDlg,w/2-imgDlg.getWidth()/2,h/2-imgDlg.getHeight()/2,0); for(int i=0;i<strDlg.length()/dlgn+1;i++) { if(i==strDlg.length()/dlgn) g.drawString(strDlg.substring(i*dlgn),w/2-imgDlg.getWidth()/2+2,h/2-imgDlg.getHeight()/2+2+i*20,0); else g.drawString(strDlg.substring(i*dlgn,i*dlgn+dlgn),w/2-imgDlg.getWidth()/2+2,h/2-imgDlg.getHeight()/2+2+i*20,0); } if(dlgMenu!=null)//显示对话菜单 { MenuCanvas.ge.drawClipImage(g,MenuCanvas.imgArrow,60,168,5,10,0,0); MenuCanvas.ge.drawClipImage(g,MenuCanvas.imgArrow,196-45,168,5,10,5,0); g.setColor(-1); g.drawString(dlgMenu[dlgMenuChoose],108,167,g.HCENTER|g.TOP); } } int getEnemyNum() { int ii=getRandom(1000); if(ii<400) return(0); else if(ii<600) return(1); else if(ii<800) return(2); else if(ii<950) return(3); else return(4); //return(0); } /*判断角色移动方向上下一步的标志位*/ int getMapMark() { int r=0; switch(direction/3) { case 1://向下 if(y<H[sl]*16-32) r=mapArray[((y+31)/16+1)*W[sl]+x/16]/100; break; case 0://向左 if(x!=0) r=mapArray[(y+31)/16*W[sl]+x/16-1]/100; break; case 3://向右 if(x!=W[sl]*16-16) r=mapArray[(y+31)/16*W[sl]+x/16+1]/100; break; case 2://向上 if(y!=0) r=mapArray[((y+31)/16-1)*W[sl]+x/16]/100; break; } return r; } public static void createImage() { try { screen=null; screenPic=Image.createImage("/screen.png"); imgProBG=Image.createImage("/proBg.png"); imgState=Image.createImage("/state.png"); sword=new Image[9]; for(int i=0;i<9;i++) { sword[i]=Image.createImage("/sword"+String.valueOf(i)+".png"); } switch(sl) { case 0://城郊 screen=new Image[29]; for(int ii=0;ii<13;ii++) { screen[ii+16]=Image.createImage(16,16); g1=screen[ii+16].getGraphics(); g1.drawImage(screenPic,-(ii+16)%10*16,-(ii+16)/10*16,0); g1=null; } break; case 1: screen=new Image[20]; for(int ii=0;ii<4;ii++) { screen[ii+16]=Image.createImage(16,16); g1=screen[ii+16].getGraphics(); g1.drawImage(screenPic,-(ii+29)%10*16,-(ii+29)/10*16,0); g1=null; } break; case 2: screen=new Image[30]; for(int ii=0;ii<14;ii++) { screen[ii+16]=Image.createImage(16,16); g1=screen[ii+16].getGraphics(); g1.drawImage(screenPic,-(ii+33)%10*16,-(ii+33)/10*16,0); g1=null; } break; case 3: screen=new Image[37]; for(int ii=0;ii<21;ii++) { screen[ii+16]=Image.createImage(16,16); g1=screen[ii+16].getGraphics(); g1.drawImage(screenPic,-(ii+47)%10*16,-(ii+47)/10*16,0); g1=null; } break; case 4: screen=new Image[25]; for(int ii=0;ii<9;ii++) { screen[ii+16]=Image.createImage(16,16); g1=screen[ii+16].getGraphics(); g1.drawImage(screenPic,-(ii+68)%10*16,-(ii+68)/10*16,0); g1=null; } break; case 5: screen=new Image[22]; for(int ii=0;ii<6;ii++) { screen[ii+16]=Image.createImage(16,16); g1=screen[ii+16].getGraphics(); g1.drawImage(screenPic,-(ii+77)%10*16,-(ii+77)/10*16,0); g1=null; } break; case 6: screen=new Image[19]; for(int ii=0;ii<3;ii++) { screen[ii+16]=Image.createImage(16,16); g1=screen[ii+16].getGraphics(); g1.drawImage(screenPic,-(ii+83)%10*16,-(ii+83)/10*16,0); g1=null; } break; default: break; } for(int ii=0;ii<16;ii++) { screen[ii]=Image.createImage(16,16); g1=screen[ii].getGraphics(); g1.drawImage(screenPic,-ii%10*16,-ii/10*16,0); g1=null; } screenPic=null; if(imgNPC==null) imgNPC=Image.createImage("/NPCSprite.png"); if(spic==null) { spic=new Image[6]; for(int i=0;i<6;i++) spic[i]=Image.createImage("/"+String.valueOf(i)+".png"); } if(imgHero==null) imgHero=Image.createImage("/player.png"); if(atpic==null) atpic=Image.createImage("/attackSprite.png"); } catch(java.io.IOException ioe) { } } int getExperience(int s) { return(s*(s+1)*(2*s+1)*25/6); } public void changeMap(int l) { isTranMenu=false; sl=l; x=startX[sl]; y=startY[sl]; if(x>=w/2) { if(x<=W[sl]*16-w/2) x0=x-w/2; else x0=W[sl]*16-w; } else x0=0; if(y>=h/2) { if(y<=H[sl]*16-h/2) y0=y-h/2; else y0=H[sl]*16-h; } else y0=0; is=getClass().getResourceAsStream("/Screen"+toString(sl)+".dat"); readMap(is); if(sl!=6) { is=getClass().getResourceAsStream("/sprite"+toString(sl)+".dat"); readSprite(is); } changeMapTask=null; changeMapTask=new TimerTask(this,13); timer.schedule(changeMapTask,0,200); isChange=true; } public void cancelMove() { moveTask.cancel(); moveTask=null; } public void cancelAttackTask() { attackTask.cancel(); while(attackTask.cancel()) { } attackTask=null; } public void move() { if(direction%3==0&&step==0)//||direction%3==0) { if(getMapMark()>1&&getMapMark()<10)//对话NPC出现的Tile { if(getMapMark()==4) { if(tn[0]==10&&tn[1]==5&&tn[2]==10&&tn[3]==5) message(4); } else message(getMapMark()); cancelMove(); direction=direction/3*3; repaint(); } else if(getMapMark()==99)//场景出入口 { if(hasBoat) { isTranMenu=true; i=0; } else strTip="请去找船工买船"; cancelMove(); direction=direction/3*3; repaint(); } else if(getMapMark()==97) { cancelMove(); if(tn[0]==10&&tn[1]==5&&tn[2]==10&&tn[3]==5&&tn[4]==20) setAttack(1,15); else { isTranMenu=true; direction=direction/3*3; repaint(); } } else if(getMapMark()==98) { cancelMove(); int ii=getRandom(2*sl+1)*10; gold+=ii*(2*sl+1); strTip=ii>0?"获得"+toString(ii*(2*sl+1))+"两银子":"一无所获"; switch(direction/3) { case 1: if(y<H[sl]*16-32) mapArray[((y+31)/16+1)*W[sl]+x/16]=mapArray[(y+31)/16*W[sl]+x/16]; break; case 0: if(x!=0) mapArray[(y+31)/16*W[sl]+x/16-1]=mapArray[(y+31)/16*W[sl]+x/16]; break; case 3://向右 if(x!=W[sl]*16-16) mapArray[(y+31)/16*W[sl]+x/16+1]=mapArray[(y+31)/16*W[sl]+x/16]; break; case 2://向上 if(y!=0) mapArray[((y+31)/16-1)*W[sl]+x/16]=mapArray[(y+31)/16*W[sl]+x/16]; break; } repaint(); } else if(getMapMark()>10&&getMapMark()<21) { setAttack(getEnemyNum(),getMapMark()-10); if(!isFighting) { if(direction%3==0&&step==0) { direction+=1; step=1; } if(direction%3==0&&step==1) { direction+=2; step=0; } if(direction%3==1||direction%3==2) direction=direction/3*3; switch(direction) { case 7://向上1 y-=speed; if(y0>0&&y-y0<=h/2) y0-=speed; repaint(); break; case 4://向下1 y+=speed; if(y0<(H[sl]-(h+15)/16)*16&&y-y0>=h/2) y0+=speed; repaint(); break; case 1://向左1 x-=speed; if(x0>0&&x-x0<=w/2) x0-=speed; repaint(); break; case 10://向右1 x+=speed; if(x0<(W[sl]-w/16)*16&&x-x0>=w/2) x0+=speed; repaint(); break; default://静止状态 repaint(); break; } } else { switch(direction/3) { case 0://向左 x-=16; break; case 1://向下 y+=16; break; case 2://向上 y-=16; break; case 3://向右 x+=16; break; } if(x>=w/2) { if(x<=W[sl]*16-w/2) x0=x-w/2; else x0=W[sl]*16-w; } else x0=0; if(y>=64) { if(y<=H[sl]*16-h/2) y0=y-h/2; else y0=H[sl]*16-h; } else y0=0; } cancelMove(); } else if(getMapMark()==1) { if(direction%3==0&&step==0) { direction+=1; step=1; } else if(direction%3==0&&step==1) { direction+=2; step=0; } else if(direction%3==1||direction%3==2) direction=direction/3*3; switch(direction) { case 7://向上1 y-=speed; if(y0>0&&y-y0<=h/2) y0-=speed; repaint(); break; case 4://向下1 y+=speed; if(y0<(H[sl]-(h+15)/16)*16&&y-y0>=h/2) y0+=speed; repaint(); break; case 1://向左1 x-=speed; if(x0>0&&x-x0<=w/2) x0-=speed; repaint(); break; case 10://向右1 x+=speed; if(x0<(W[sl]-w/16)*16&&x-x0>=w/2) x0+=speed; repaint(); break; default://静止状态 repaint(); break; } } else { moveTask.cancel(); moveTask=null; direction=direction/3*3; repaint(); } } else { if(direction%3==0&&step==0) { direction+=1; step=1; } else if(direction%3==0&&step==1) { direction+=2; step=0; } else if(direction%3==1||direction%3==2) direction=direction/3*3; switch(direction) { case 6: if(step==1)//向上2 { y-=speed; if(y0>0&&y-y0<=h/2) y0-=speed; repaint(); } if(step==0)//向上4 { y-=speed; if(y0>0&&y-y0<=h/2) y0-=speed; if(!isWalking) cancelMove(); repaint(); } break; case 7://向上1 y-=speed; if(y0>0&&y-y0<=h/2) y0-=speed; repaint(); break; case 8://向上3 y-=speed; if(y0>0&&y-y0<=h/2) y0-=speed; repaint(); break; case 3: if(step==1) { y+=speed; if(y0<(H[sl]-(h+15)/16)*16&&y-y0>=h/2) y0+=speed; repaint(); } if(step==0) { y+=speed; if(y0<(H[sl]-(h+15)/16)*16&&y-y0>=h/2) y0+=speed; repaint(); if(!isWalking) cancelMove(); } break; case 4://向下1 y+=speed; if(y0<(H[sl]-(h+15)/16)*16&&y-y0>=h/2) y0+=speed; repaint(); break; case 5://向下2 y+=speed; if(y0<(H[sl]-(h+15)/16)*16&&y-y0>=h/2) y0+=speed; repaint(); break; case 0: if(step==1) { x-=speed; if(x0>0&&x-x0<=w/2) x0-=speed; repaint(); } if(step==0) { x-=speed; if(x0>0&&x-x0<=w/2) x0-=speed; repaint(); if(!isWalking) cancelMove(); } break; case 1://向左1 x-=speed; if(x0>0&&x-x0<=w/2) x0-=speed; repaint(); break; case 2://向左2 x-=speed; if(x0>0&&x-x0<=w/2) x0-=speed; repaint(); break; case 9: if(step==1) { x+=speed; if(x0<(W[sl]-w/16)*16&&x-x0>=w/2) x0+=speed; repaint(); } if(step==0) { x+=speed; if(x0<(W[sl]-w/16)*16&&x-x0>=w/2) x0+=speed; repaint(); if(!isWalking) cancelMove(); } break; case 10://向右1 x+=speed; if(x0<(W[sl]-w/16)*16&&x-x0>=w/2) x0+=speed; repaint(); break; case 11://向右2 x+=speed; if(x0<(W[sl]-w/16)*16&&x-x0>=w/2) x0+=speed; repaint(); break; default://静止状态 repaint(); break; } } } public void setAttack(int k) { attackTask=null; switch(k) { case 0: if(energy>=10*skillArray[0]) { attackTask=new TimerTask(this,4); energy-=10*skillArray[0]; isAttMenu=false; if(isHiding) { isHiding=!isHiding; SPI[0].p=130; } } break; case 1: if(energy>=10*skillArray[1]) { attackTask=new TimerTask(this,5); energy-=10*skillArray[1]; isAttMenu=false; if(isHiding) { isHiding=!isHiding; SPI[0].p=130; } } break; case 2: if(energy>=20*skillArray[2]&&life>=4*skillArray[2]*maxlife/100) { attackTask=new TimerTask(this,6); energy-=20*skillArray[2]; life-=4*skillArray[2]*maxlife/100; SPI[0].life=life; isAttMenu=false; if(isHiding) { isHiding=!isHiding; SPI[0].p=130; } } break; case 3: if(energy>=(20*skillArray[3])) { SPI[1]=new Sprite(8*skillArray[3]*skillArray[3]+40,4*skillArray[3]*skillArray[3]+10); SPI[1].p=120; SPI[1].x=36; SPI[1].y=112+32+40; energy-=20*skillArray[3]; isAttMenu=false; attackNumber=4; repaint(); } break; case 4://召熊 if(energy>=(30*skillArray[4])) { SPI[2]=new Sprite(20*skillArray[4]*skillArray[4]+60,skillArray[4]*skillArray[4]+7); SPI[2].p=100; SPI[2].x=36; SPI[2].y=64+32+40; energy-=30*skillArray[4]; isAttMenu=false; attackNumber=4; repaint(); } break; case 5: if(energy>=30*skillArray[5]) { SPI[3]=new Sprite(10*skillArray[5]*skillArray[5]+40,0); SPI[3].p=110; SPI[3].x=36; SPI[3].y=32+32+40; energy-=30*skillArray[5]; isAttMenu=false; attackNumber=4; repaint(); } break; case 6: if(energy>=5*skillArray[6]) { SPI[0].p=140; if(tran) { tran=!tran; maxlife=level*level+10*level+60; life=life-life*10*skillArray[8]/(100+10*skillArray[8])>maxlife?maxlife:(life-life*10*skillArray[8]/(100+10*skillArray[8])); SPI[0].life=life; basicPower=5*level+2; totalPower=basicPower+addPower+addPdP*basicPower/100; SPI[0].basicPower=totalPower; } isHiding=true; energy-=5*skillArray[6]; count=0; isAttMenu=false; attackNumber=4; repaint(); } break; case 7://遁走 if(energy>=10*skillArray[7]*skillArray[7]) { energy-=10*skillArray[7]*skillArray[7]; if(getRandom(100)<20*skillArray[7]) { isFighting=false; repaint(); attackControlTask.cancel(); attackControlTask=null; for(int ii=0;ii<8;ii++) SPI[ii]=null; if(tran) { tran=!tran; maxlife=20*level+60; life=life-life*10*skillArray[8]/(100+10*skillArray[8])>maxlife?maxlife:(life-life*10*skillArray[8]/(100+10*skillArray[8])); basicPower=3*level+2; totalPower=basicPower+basicPower*addPdP/100+addPower; } repaint(); } else { isAttMenu=false; attackNumber=4; repaint(); } } break; case 8://附身 if(energy>=30+3*skillArray[8]*skillArray[8]&&!tran) { energy-=30+3*skillArray[8]*skillArray[8]; tran=true; if(isHiding) isHiding=!isHiding; SPI[0].p=150; maxlife+=maxlife*10*skillArray[8]/100; life+=life*10*skillArray[8]/100; SPI[0].life=life; basicPower+=basicPower*20*skillArray[8]/100; totalPower=basicPower+addPdP*basicPower/100+addPower; SPI[0].basicPower=totalPower; count=0; isAttMenu=false; attackNumber=4; repaint(); } break; case 9: if(energy>=3*skillArray[9]*skillArray[9]) { energy-=3*skillArray[9]*skillArray[9]; attackTask=new TimerTask(this,10); isAttMenu=false; } break; case 10: if(gold>=20*skillArray[10]*maxenergy/100) { gold-=20*skillArray[10]*maxenergy/100; attackTask=new TimerTask(this,11); isAttMenu=false; } break; case 11: attackTask=new TimerTask(this,0); if(isHiding) isHiding=!isHiding; isAttMenu=false; attackNumber=0; break; case 12: attackTask=new TimerTask(this,9); attackTask.j=attackNumber; break; case 22: attackTask=new TimerTask(this,2); break; case 21: attackTask=new TimerTask(this,1); break; } if(attackTask!=null) { if(attackTask.type==4) timer.schedule(attackTask,0,200); else timer.schedule(attackTask,0,250); } } /*判断怪物掉出的宝是否角色已经拥有*/ boolean hasWeapon(int s) { boolean temp=false; for(int ii=0;ii<6;ii++) { if(weapon[ii]==s) { temp=true; break; } } return(temp); } public void setAttack(int n,int lvl) { if(n!=0) { try { imgAttackBG=Image.createImage("/attackBg"+String.valueOf(getRandom(9))+".png"); } catch(Exception e) { } if(MenuCanvas.isAudioOn) { MenuCanvas.se.closeSound(mapPlayer); attPlayer=MenuCanvas.se.createPlayer("/attack.mid",1000); MenuCanvas.se.playSound(attPlayer); } for(int i=0;i<n;i++) { SPI[i+4]=new Sprite(lvl); SPI[i+4].x=166; SPI[i+4].y=i*32+((lvl-1)/3==1?15:0)+64+108; if(lvl!=15) SPI[i+4].p=(lvl-1)*10; else SPI[i+4].p=160; } SPI[0]=new Sprite(life,totalPower); SPI[0].x=36; SPI[0].y=224; SPI[0].p=130; curEl=lvl;//将当前战斗的怪的等级设为给定等级 isFighting=true; isAttMenu=true; sn=0; nn=0; attackControlTask=new TimerTask(this,8); timer.schedule(attackControlTask,0,100); repaint(); } } String toString(int s) { return(String.valueOf(s)); } public void drawScrollPro(Graphics g) { g.setClip(88,208,140,85); int page=1+(strPro.length()-1)/10; for(int iii=0;iii<page;iii++) { if(iii==page-1) MenuCanvas.ge.drawStringShadow(g,0,0,-1,strPro.substring(iii*10),87,280+offY+iii*18,0); else MenuCanvas.ge.drawStringShadow(g,0,0,-1,strPro.substring(iii*10,(iii+1)*10),87,280+offY+iii*18,0); } offY-=3; if(-offY>(strPro.length()-1)/8*18) offY=0; g.setClip(0,0,240,309); } public void drawTranMenu(Graphics g) { g.setColor(0,0,100); g.fillRoundRect(71,73,86,120,30,30); g.setColor(getRandom(255),getRandom(255),getRandom(255)); g.drawRoundRect(71,73,86,120,30,30); g.setColor(0); g.drawRoundRect(70,72,88,122,30,30); g.setColor(getRandom(255),getRandom(255),getRandom(255)); g.drawRoundRect(69,71,90,124,30,30); MenuCanvas.ge.drawStringShadow(g,0xff0000,0x00ff00,0x00ff00,"当前所在地:"+mapName[sl],116,48,g.HCENTER|g.TOP); MenuCanvas.ge.drawStringShadow(g,0,0x0000ff,0x00ff00,"请选择你要前往的地方",116,211,g.HCENTER|g.TOP); for(int k=0;k<6;k++) { if(!isTask&&k==4) continue; if(!dlg[2]&&k==5) continue; if(k==i) MenuCanvas.ge.drawStringShadow(g,0,0x0000ff,0x00ff00,mapName[k],113,k*20+90,g.HCENTER|g.TOP); else MenuCanvas.ge.drawStringShadow(g,0x00ff00,0,-1,mapName[k],113,k*20+90,g.HCENTER|g.TOP); } } public void drawProMenu(Graphics g) { g.drawImage(imgProBG,0,0,0); switch(i) { case 0://状态显示 MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,0x00ff00,"血:"+toString(life)+"/"+toString(maxlife),100,20,0); MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,0x00ff00,"气:"+toString(energy)+"/"+toString(maxenergy),100,38,0); MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,0x00ff00,"经验:"+toString(experience)+" / "+toString(getExperience(level+1)),100,56,0); MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,0x00ff00,"银两:"+toString(gold),100,74,0); MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,0x00ff00,"攻击力:"+toString(basicPower)+"+"+toString(addPower+basicPower*addPdP/100),100,92,0); MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,0x00ff00,"等级:"+toString(level),100,110,0); MenuCanvas.ge.drawStringShadow(g,0xffff00,0xffff00,0xff0000,"你可以在这里查看",100,214,0); MenuCanvas.ge.drawStringShadow(g,0xffff00,0xffff00,0xff0000,"尹风的各项属性",100,230,0); break; case 1: String temp=new String(); switch(weapon[j]) { case 0: temp="承影剑"; break; case 1: temp="纯钧剑"; break; case 2: temp="鱼肠剑"; break; case 3: temp="干将莫邪剑"; break; case 4: temp="龙渊剑"; break; case 5: temp="泰阿剑"; break; case 6: temp="赤霄剑"; break; case 7: temp="湛泸剑"; break; case 8: temp="轩辕剑"; break; } if(weapon[j]!=9) { if(curweapon!=weapon[j]) MenuCanvas.ge.drawStringShadow(g,0xff0000,0xff0000,-1,temp,139,16,0); else MenuCanvas.ge.drawStringShadow(g,0x00ff00,0x00ff00,-1,temp,139,16,0); g.setColor(97,66,31); g.fillRect(100,36,112,112); g.setColor(0); g.drawRect(100,36,112,112); g.setColor(-1); g.drawRect(99,35,114,114); g.setColor(0); g.drawRect(98,34,116,116); MenuCanvas.ge.drawClipImage(g,MenuCanvas.imgArrow,105-offX,90,5,10,0,0); MenuCanvas.ge.drawClipImage(g,MenuCanvas.imgArrow,200+offX,90,5,10,5,0); offX+=2; if(offX==4) offX=0; g.drawImage(sword[weapon[j]],110,40,0); } MenuCanvas.ge.drawStringShadow(g,0,0,-1,"绿色为当前装备",94,150,0); MenuCanvas.ge.drawStringShadow(g,-1,-1,0,"可以按"1"卖掉",94,168,0); if(weapon[j]!=9) { g.setColor(255,255,255); switch(weapon[j]) { case 0: strPro="有影无形的长剑,双手合握之中是一截剑柄,只有剑柄不见长剑剑身,见于《列子-汤问》。物理攻击力加5,吸血10%"; break; case 1: strPro="铸剑之时,雷公打铁,雨娘淋水,蛟龙捧炉,天帝装炭。千年赤堇山山破而出锡,万载若耶江江水干涸而出铜。铸剑大师欧冶子承天之命呕心沥血与众神铸磨十载此剑方成。剑成之后,众神归天,赤堇山闭合如初,若耶江波涛再起,欧冶子也力尽神竭而亡,见于《越绝书》。。物理攻击力加10,吸血25%"; break; case 2: strPro="夫专诸之刺王僚,飞鹰击殿,见于司马迁《史记-刺客列传》。物理攻击力加15,吸血45%"; break; case 3: strPro="传干将、莫邪是两把剑,但是没有人能分开它们。干将、莫邪是两个人,同样,也没有人能将他(她)们分开。干将、莫邪是干将、莫邪铸的两把剑。干将是雄剑,莫邪是雌剑。干将是丈夫,莫邪是妻子。技能攻击力加10%"; break; case 4: strPro="欧冶子和干将为铸此剑,凿开茨山,放出山中溪水,引至铸剑炉旁成北斗七星环列的七个池中,是名“七星”。渔丈人自刎于伍子胥示高洁,事见于《吴越春秋》。技能攻击力加20%"; break; case 5: strPro="欧冶子和干将两大剑师联手所铸。晋攻楚三载,楚王此剑退敌,见于《越绝书》。技能攻击力加30%"; break; case 6: strPro="刘邦斩蛇起义之物。饰有七彩珠、九华玉的寒光逼人、刃如霜雪的宝剑,剑身上清晰镌刻着两个篆字:赤霄。基础攻击力加15%"; break; case 7: strPro="湛泸是一把剑,更是一只眼睛。湛泸:湛湛然而黑色也。五金之英,太阳之精,出之有神,服之有威。一把无坚不摧而又不带丝毫杀气的兵器。基础攻击力加25%"; break; case 8: strPro="众神采首山之铜为黄帝所铸,后传与夏禹。剑身一面刻日月星辰,一面刻山川草木。剑柄一面书农耕畜养之术,一面书四海一统之策。基础攻击力加35%"; break; } drawScrollPro(g); } temp=null; break; case 2://技能显示 if(strPro==null) strPro="你可以在这里升级尹风的技能,尹风的技能分召唤系,元素系,特质系和辅助系共四大系十一种,每种技能的效果以及需要的气值都会随着技能等级的提高而提高,同时升级的时候要注意,每种技能在升级后都必须隔3个人物等级才能继续升级"; if(j<4) { MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,0x00ff00,"落日:"+(skillArray[0]>0?"等级"+toString(skillArray[0]):"未修炼"),100,20,0); MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,0x00ff00,"乱电:"+(skillArray[1]>0?"等级"+toString(skillArray[1]):"未修炼"),100,45,0); MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,0x00ff00,"残风:"+(skillArray[2]>0?"等级"+toString(skillArray[2]):"未修炼"),100,70,0); MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,0x00ff00,"召狼:"+(skillArray[3]>0?"等级"+toString(skillArray[3]):"未修炼"),100,95,0); } else if(j<8) { MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,0x00ff00,"召熊:"+(skillArray[4]>0?"等级"+toString(skillArray[4]):"未修炼"),100,20,0); MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,0x00ff00,"召龙:"+(skillArray[5]>0?"等级"+toString(skillArray[5]):"未修炼"),100,45,0); MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,0x00ff00,"隐身:"+(skillArray[6]>0?"等级"+toString(skillArray[6]):"未修炼"),100,70,0); MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,0x00ff00,"遁走:"+(skillArray[7]>0?"等级"+toString(skillArray[7]):"未修炼"),100,95,0); } else { MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,0x00ff00,"附身:"+(skillArray[8]>0?"等级"+toString(skillArray[8]):"未修炼"),100,20,0); MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,0x00ff00,"治疗:"+(skillArray[9]>0?"等级"+toString(skillArray[9]):"未修炼"),100,45,0); MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,0x00ff00,"回气:"+(skillArray[10]>0?"等级"+toString(skillArray[10]):"未修炼"),100,70,0); } MenuCanvas.ge.drawStringShadow(g,0,0,-1,"剩余技能点:"+toString(skillpoint),100,120,0); g.setColor(0); g.drawRect(98,20+j%4*25,80,20); g.setColor(-1); g.drawRect(97,19+j%4*25,82,22); g.setColor(0); g.drawRect(96,18+j%4*25,84,24); drawScrollPro(g); break; case 3://任务显示 if(strPro==null) strPro="这里显示的是尹风需要完成的任务,当任务还没有接到时不会在这里显示,接到任务后会显示其完成情况。"; if(isTask) { MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,0x00ff00,"收集物品",100,13,0); MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,0x00ff00,"九花玉露丸:"+(tn[0]==10?"完成":toString(tn[0])),100,31,0); MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,0x00ff00,"通天草:"+(tn[1]==5?"完成":toString(tn[1])),100,49,0); MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,0x00ff00,"千年人参:"+(tn[2]==10?"完成":toString(tn[2])),100,67,0); MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,0x00ff00,"灵芝:"+(tn[3]==5?"完成":toString(tn[3])),100,85,0); if(isTask2) MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,0x00ff00,"虎皮: "+(tn[4]==20?"完成":toString(tn[4])),100,103,0); } drawScrollPro(g); break; } g.setColor(getRandom(255),getRandom(255),getRandom(255)); g.drawRect(14,49+i*58,44,26); g.setColor(getRandom(255),getRandom(255),getRandom(255)); g.drawRect(13,48+i*58,46,28); } public void drawGameOver(Graphics g) { try{ Image img = Image.createImage("/loadBg.png"); g.drawImage(img,0,0,g.TOP|g.LEFT); img = null; }catch(IOException e){} String strOver = "襄樊之战是元朝统治者消灭"+ "南宋统一中国的一次重要战役,是中国历史上宋"+ "元封建王朝更迭的关键一战在尹风的帮助下,郭"+ "大侠从南宋淳三年固守襄阳历时六年,"+ ",到咸淳九年,最后终因孤城无援,"+ "以南宋襄樊失陷而告结束。尹风和晶晶姑娘"+ "退守江南,协助郭靖和丐帮继续抗蒙大业。"+ "敬请等待后续故事。"; int page=1+(strOver.length()-1)/15; for(int iii=0;iii<page;iii++) { if(iii==page-1) MenuCanvas.ge.drawStringShadow(g,0,0,-1,strOver.substring(iii*15),10,60+iii*15,0); else MenuCanvas.ge.drawStringShadow(g,0,0,-1,strOver.substring(iii*15,(iii+1)*15),10,60+iii*15,0); } } public void drawState(Graphics g) { g.drawImage(imgState,0,309-36,g.TOP|g.LEFT); g.setColor(0,0,255); g.fillRect(146,h-14+offsetY,54*energy/maxenergy,3); g.setColor(255,0,0); g.fillRect(41,h-16+offsetY,54*life/maxlife,3); g.setColor(128,128,255); g.fillRect(70,h-32+offsetY,106*(experience-getExperience(level))/(getExperience(level+1)-getExperience(level)),3); } public void drawAttackMenu(Graphics g) { g.setFont(MenuCanvas.mFont); g.setColor(0x9B7319); g.fillRect(20,20,200,20); g.setColor(0); g.drawRect(20,20,200,20); g.setColor(-1); g.drawRect(19,19,202,22); g.setColor(0); g.drawRect(18,18,204,24); g.setColor(0x0000ff); g.setClip(20,20,200,20); for(int iii=0;iii<attackMenu.length;iii++) { if(iii<11&&skillArray[iii]==0) MenuCanvas.ge.drawStringShadow(g,0,0,-1,attackMenu[iii],30-i*40+iii*40,21,0); else MenuCanvas.ge.drawStringShadow(g,0x00ff00,0x00ff00,-1,attackMenu[iii],30-i*40+iii*40,21,0); if((iii==i&&iii<11&&skillArray[iii]>0)||i==11) MenuCanvas.ge.drawStringShadow(g,0x0000ff,0x0000ff,-1,attackMenu[iii],30-i*40+iii*40,21,0); } g.setClip(0,0,240,309); MenuCanvas.ge.drawClipImage(g,MenuCanvas.imgArrow,12-offX,25,5,10,0,0); MenuCanvas.ge.drawClipImage(g,MenuCanvas.imgArrow,224+offX,25,5,10,5,0); offX+=3; if(offX==9) offX=0; } public void drawWin(Graphics g,Vector string) { int h=(string.size()+1)*30; g.setColor(0,0,100); g.fillRoundRect(48,90,156,h,30,30); g.setColor(getRandom(255),getRandom(255),getRandom(255)); g.drawRoundRect(48,90,156,h,30,30); g.setColor(0); g.drawRoundRect(47,89,158,h+2,30,30); g.setColor(getRandom(255),getRandom(255),getRandom(255)); g.drawRoundRect(46,88,160,h+2,30,30); g.setColor(0xffff00); MenuCanvas.ge.drawStringShadow(g,0,0,-1,"战斗胜利",126,96,g.HCENTER|g.TOP); g.setColor(-1); for(int ii=0;ii<string.size();ii++) g.drawString((String)(string.elementAt(ii)),126,120+ii*28,g.HCENTER|g.TOP); } public void paint(Graphics g) { if(isGameOver) { drawGameOver(g); return; } //System.gc(); g.setFont(MenuCanvas.mFont); g.setColor(0,0,0); g.fillRect(0,0,w,h); if(!isChange) { if(changeMapTask!=null) { changeMapTask.cancel(); changeMapTask=null; } int u,v,o; if(isFighting) { g.drawImage(imgAttackBG,0,0,g.TOP|g.LEFT); for(int i=0;i<8;i++) { if(SPI[i]!=null) { if(i>3) { if(SPI[i].level<4||SPI[i].level>6) { if(SPI[i].level!=15) { g.setClip(SPI[i].x,SPI[i].y,16,32); g.drawImage(atpic,SPI[i].x-SPI[i].p%10*16,SPI[i].y-SPI[i].p/10*32,0); } else { g.setClip(SPI[i].x,SPI[i].y,32,32); g.drawImage(atpic,SPI[i].x,SPI[i].y-SPI[i].p/10*32-SPI[i].p%10*32,0); } } else { g.setClip(SPI[i].x,SPI[i].y,32,16); g.drawImage(atpic,SPI[i].x,SPI[i].y-SPI[i].p/10*32-SPI[i].p%10*16,0); } } else if(i==1) { g.setClip(SPI[1].x,SPI[1].y,32,16); g.drawImage(atpic,SPI[1].x,SPI[1].y-SPI[1].p/10*32-SPI[1].p%10*16,0); } else { g.setClip(SPI[i].x,SPI[i].y,16,32); g.drawImage(atpic,SPI[i].x-SPI[i].p%10*16,SPI[i].y-SPI[i].p/10*32,0); } g.setClip(0,0,240,309); g.setColor(0,0,0); if(i<4&&i!=0) g.drawRect(26,(3-i)*32+15+64+64,5,16); else if(i>=4&&i!=0) g.drawRect(190,(i-4)*32+15+64+108,5,16); g.setColor(255,0,0); if(i>=4) g.fillRect(191,(i-3)*32-16*SPI[i].life/(SPI[i].level*SPI[i].level*15+10)+64+108,4,16*SPI[i].life/(SPI[i].level*SPI[i].level*15+10)-1); else switch(i) { case 1://狼 g.fillRect(27,96-16*SPI[1].life/(8*skillArray[3]*skillArray[3]+40)+64+64,4,16*SPI[1].life/(8*skillArray[3]*skillArray[3]+40)-1); break; case 2://熊 g.fillRect(27,64-16*SPI[2].life/(20*skillArray[4]*skillArray[4]+60)+64+64,4,16*SPI[2].life/(20*skillArray[4]*skillArray[4]+60)-1); break; case 3://龙 g.fillRect(27,32-16*SPI[3].life/(10*skillArray[5]*skillArray[5]+40)+64+64,4,16*SPI[3].life/(10*skillArray[5]*skillArray[5]+40)-1); break; } } } if(spic0!=null) g.drawImage(spic0,sx,sy,0); if(attackTask!=null) { if(attackTask.type==5)//乱电效果 { switch(attackTask.s) { case 2: for(int ii=0;ii<5;ii++) { g.drawImage(spic[1],getRandom(60)+160,0,0); g.drawImage(spic[1],getRandom(60)+160,32,0); } break; case 3: for(int ii=0;ii<5;ii++) { g.drawImage(spic[1],getRandom(60)+160,0,0); g.drawImage(spic[1],getRandom(60)+160,32,0); g.drawImage(spic[1],getRandom(60)+160,64,0); g.drawImage(spic[1],getRandom(60)+160,96,0); } break; case 4: for(int ii=0;ii<5;ii++) { g.drawImage(spic[1],getRandom(60)+160,0,0); g.drawImage(spic[1],getRandom(60)+160,32,0); g.drawImage(spic[1],getRandom(60)+160,64,0); g.drawImage(spic[1],getRandom(60)+160,96,0); g.drawImage(spic[1],getRandom(60)+160,128,0); g.drawImage(spic[1],getRandom(60)+160,160,0); } break; case 5: for(int ii=0;ii<5;ii++) { g.drawImage(spic[1],getRandom(60)+160,0,0); g.drawImage(spic[1],getRandom(60)+160,32,0); g.drawImage(spic[1],getRandom(60)+160,64,0); g.drawImage(spic[1],getRandom(60)+160,96,0); g.drawImage(spic[1],getRandom(60)+160,128,0); g.drawImage(spic[1],getRandom(60)+160,160,0); g.drawImage(spic[1],getRandom(60)+160,192,0); } for(int i=0;i<4;i++) { if(SPI[i+4]!=null) { if(SPI[i+4].level!=15) SPI[i+4].life-=(2*skillArray[1]*skillArray[1]+10)*(100+addMagic)/100; } } break; case 6: for(int i=0;i<4;i++) { if(SPI[i+4]!=null) { if(SPI[i+4].life<=0) { sn+=100*SPI[i+4].level*SPI[i+4].level/level; nn+=4*SPI[i+4].level*SPI[i+4].level; SPI[i+4]=null; } } } break; case 7: attackNumber=4; cancelAttackTask(); repaint(); break; default: break; } } else if(attackTask.type==6)//残风效果 { switch(attackTask.s) { case 2: for(int ii=0;ii<6;ii++) { g.drawImage(spic[2],50,getRandom(128),0); g.drawImage(spic[2],82,getRandom(128),0); } break; case 3: for(int ii=0;ii<6;ii++) { g.drawImage(spic[2],50,getRandom(128),0); g.drawImage(spic[2],82,getRandom(128),0); g.drawImage(spic[2],114,g
- 粉丝: 11
- 资源: 22
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- (源码)基于CC++和wxWidgets框架的LEGO模型火车控制系统.zip
- (源码)基于C语言的操作系统实验项目.zip
- (源码)基于C++的分布式设备配置文件管理系统.zip
- (源码)基于ESP8266和Arduino的HomeMatic水表读数系统.zip
- (源码)基于Django和OpenCV的智能车视频处理系统.zip
- (源码)基于ESP8266的WebDAV服务器与3D打印机管理系统.zip
- (源码)基于Nio实现的Mycat 2.0数据库代理系统.zip
- (源码)基于Java的高校学生就业管理系统.zip
- (源码)基于Spring Boot框架的博客系统.zip
- (源码)基于Spring Boot框架的博客管理系统.zip