⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gamemanager.java

📁 一个以音乐为主题的杀怪手机游戏
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	  	if ( s.charAt(line) == '#' ){subStringLength++ ;break;}
	   
 			g.drawChar(s.charAt(line),dialogX+6,dialogY+2,0);
	  	dialogX+=g.getFont().charWidth(s.charAt(line));
	  	subStringLength++;
	  	if(dialogX>W-20){
	  		dialogY+=fontHeight;
	  		dialogX=1;
	  	}
	  	if (!s.equals(gameShow) && dialogY>H-10 ){ /////////////////////////////
	  		break;
	  	}else if(dialogY>H-30){break;}
	  	
	  	
	  }
	  if ( keyState[6]){
	  	 keyState[6] = false;
 		 
	  	 tmpPoint+= subStringLength;
	  	 subStringLength=0;
			 dialogY = H*2/3;
	  	 if (tmpPoint  >= s.length()){
	  	 	  
	  	 		tmpPoint = 0;
	  	 		line =0;
	  	 		talking = false;
	  	 		snow = false;
	  	 		subStringLength = 0;
	  	 		if (foePoint[menuI][12] > 0 && !s.equals(gameShow)){
	  	 			if(courseNum == foePoint[menuI][14]){
					 					courseNum += foePoint[menuI][15];
                     getSomeThing(foePoint[menuI][16]);
            }else if ( foePoint[menuI][14]< 0){
            	getSomeThing(foePoint[menuI][16]);
            	
            	
            }
					
					 
	   	    	}
	   	    	if( currentMapID == 7 && menuI ==1 && !flag1 ){flag1 = true; foePoint[menuI][12] = -foePoint[menuI][12];}
	  	 	  if( currentMapID == 6 && menuI ==4 && !flag2 ){flag2 = true; foePoint[menuI][12] = -foePoint[menuI][12];}
	   	    					
	  	 }
	  }else if (keyState[5]){
	  	    keyState[5] = false;
	  	   
	  	    tmpPoint = 0;
	  	 		line =0;
	  	 		talking = false;
	  	 		snow = false;
	  	 		subStringLength = 0;
	  	 		if ( foePoint[menuI][12] > 0 && !s.equals(gameShow)){
	  	 			if (courseNum == foePoint[menuI][14]){
					 				courseNum += foePoint[menuI][15];
					 				getSomeThing(foePoint[menuI][16]);
	   	    		}else if( foePoint[menuI][14]< 0){
	   	    			
	   	    			getSomeThing(foePoint[menuI][16]);
	   	    			
	   	    			}
					

	   	    	}
	   	    if( currentMapID == 7 && menuI ==1 && !flag1 ){flag1 = true; foePoint[menuI][12] = -foePoint[menuI][12];}
	  	 	  if( currentMapID == 6 && menuI ==4 && !flag2 ){flag2 = true; foePoint[menuI][12] = -foePoint[menuI][12];}	
	  	
	  	
	}
	
	  
	  
	  
	}
	
 
//=================================敵人==========================================
 
boolean bossBluting = false;
	private void foe(Graphics g ){
		foeAdd++;
		if(foeAdd> 32700)
			foeAdd=0;
	  for( int i = 0; i< foePoint.length;i++){
		   if (foePoint[i][6] >=1 && foePoint[i][0]>winX -2 && foePoint[i][0] < winX+W/16 +2 &&foePoint[i][1]>winY-2 && foePoint[i][1]<winY+H/16+2 ){
		   	//System.out.println("mX"+magicPositionX+" -mY"+magicPositionY+"     -fX"+foePoint[i][0]+" fY"+foePoint[i][1]);
	     	  tmpMapPassable = (byte)Math.abs(currentMap_Under[foePoint[i][1]][foePoint[i][0]]); // 取值
 
	   		  currentMap_Under[foePoint[i][1] ][foePoint[i][0]] = (byte)-tmpMapPassable;     // 阻止通行
	   		  
	   		  
 			if (Math.abs(foePoint[i][0] - manPositionX) <= 2 && Math.abs(foePoint[i][1] - manPositionY )<=3 && !showSubMenu){
 				 canTalking = true;
 				 if (foePoint[i][12] > 0){
 				 		nearly = true;
 				 	
 				 		g.drawImage(messageReady,mapX+foePoint[i][2]+(foePoint[i][0]-winX)*16,mapY+foePoint[i][3]+(foePoint[i][1]-winY-3)*16,0);
 				 			if ( keyState[6] && !talking){
 				 				keyState[6]= false;
								if( !showSubMenu)talking = true;
								menuI = i;
								for ( int j=0 ; j<= courseScope[i].length-1 ;j+=2){
										//System.out.println( courseScope[i][j] + " / ");
	    		    	        	if ( courseScope[i][j] == courseNum ){
										currentDialogue = Dialogue[i][courseScope[i][j+1]]; break;}else{currentDialogue = "<> .......";}/////////////////////////////////////////////
	    		    		          
	    	    		        }
	    	    	}
 				 	}//else{ nearly = false;}
 				 if (foePoint[i][1] >= manPositionY ) {
 				 	overDraw = true;
 				 	foePoint[i][5] = 4;hitMan(0,-1,i);
 				 	if (foePoint[i][1] == manPositionY ){ if(foePoint[i][0] >= manPositionX){foePoint[i][5] = 6;hitMan(-1,0,i);}else{foePoint[i][5] = 7;hitMan(1,0,i);}}
 				 	}else {
 				 		overDraw = false;
 				 		foePoint[i][5] = 5;hitMan(0,1,i);
 				 			if (foePoint[i][1] == manPositionY ){ if(foePoint[i][0] >= manPositionX){foePoint[i][5] = 6;hitMan(-1,0,i);}else{foePoint[i][5] = 7;hitMan(1,0,i);}}
 				 		
 				 	}
 				 
 			}else {  nearly = false; canTalking = false;}
 				
	     		if ( foePoint[i][7]==1 && !talking  && !showSubMenu){  
	     		
	   	    	switch(foePoint[i][5]){
	   	    		case -2:
	   	    		  if (  !bossBluting){ 
	   	    		  
	   	    		  	 if (foePoint[i][0] == manPositionX){bossMagicStepX =0;}else { bossMagicStepX = 5*(foePoint[i][0] - manPositionX)/Math.abs(foePoint[i][0] - manPositionX);}
	   	    		  	 if (foePoint[i][1] == manPositionY){bossMagicStepY =0;}else { bossMagicStepY = 5*(foePoint[i][1] - manPositionY)/Math.abs(foePoint[i][1] - manPositionY);}
	   	    		  	 
	   	    		  	 bossMagicPositionX = foePoint[i][0];
	   	    		  	 bossMagicPositionY = foePoint[i][1];
	   	    		  	 
	   	    		  	 bossBluting = true;
	   	    		  	 if (foePoint[i][0] == manPositionX && foePoint[i][1] == manPositionY) {bossBluting = false;}
	   	    		  }
	   	    			if (  (foeAdd% 100) <= (60+Math.abs(r.nextInt()%6)) && foeAdd% 100 >=10){
	   	    							
	   	    							if ( foePoint[i][0] >= foePoint[i][8] && (manPositionX-foePoint[i][0])<0){
	   	    								bossActive =2;
	   	    								foePoint[i][2]+=1+(manPositionX-foePoint[i][0])/2*Math.abs(r.nextInt()%6);
	   	    							} 
	   	    							if ( foePoint[i][0] <  foePoint[i][8]+foePoint[i][10] && (manPositionX-foePoint[i][0]) >0 ){
	   	    								bossActive =2;
	   	    								foePoint[i][2]+=1+(manPositionX-foePoint[i][0])/2*Math.abs(r.nextInt()%6);
	   	    							} 
	   	    							if ( foePoint[i][1] >= foePoint[i][9] && (manPositionY-foePoint[i][1])<0 ){
	   	    								bossActive =2;
	   	    								foePoint[i][3]+=1+(manPositionY-foePoint[i][1])/2*Math.abs(r.nextInt()%6);
	   	    							} 
	   	    							if ( foePoint[i][1] <  foePoint[i][9]+foePoint[i][11] && (manPositionY-foePoint[i][1]) >0 ){
	   	    								bossActive =2;
	   	    								foePoint[i][3]+=1+(manPositionY-foePoint[i][1])/2*Math.abs(r.nextInt()%6);
	   	    							}
	   	    		 }else if ( foeAdd%100 >= (70-Math.abs(r.nextInt()%6))  ){
	   	    		 
	   	    							if ( foePoint[i][0] >= foePoint[i][8] && (manPositionX-foePoint[i][0])>0){
	   	    									bossActive =2;
	   	    								foePoint[i][2]-=1+(manPositionX-foePoint[i][0])/2*Math.abs(r.nextInt()%5);
	   	    							} 
	   	    							if ( foePoint[i][0] <  foePoint[i][8]+foePoint[i][10] && (manPositionX-foePoint[i][0]) <0 ){
	   	    									bossActive =2;
	   	    								foePoint[i][2]-=1+(manPositionX-foePoint[i][0])/2*Math.abs(r.nextInt()%5);
	   	    							} 
	   	    							if ( foePoint[i][1] >= foePoint[i][9] && (manPositionY-foePoint[i][1])>0 ){
	   	    									bossActive =2;
	   	    								foePoint[i][3]-=1+(manPositionY-foePoint[i][1])/2*Math.abs(r.nextInt()%5);
	   	    							} 
	   	    							if ( foePoint[i][1] <  foePoint[i][9]+foePoint[i][11] && (manPositionY-foePoint[i][1]) <0 ){
	   	    									bossActive =2;
	   	    								foePoint[i][3]-=1+(manPositionY-foePoint[i][1])/2*Math.abs(r.nextInt()%5);
	   	    							}
	   	    		 }else {bossActive =1;}
	   	    		break;
	   	    		case -1:
	   	    			if ( foePoint[i][0] >= foePoint[i][8] && (manPositionX-foePoint[i][0]) <0 ){
	   	    				foePoint[i][2]+=(manPositionX-foePoint[i][0])/2*Math.abs(r.nextInt()%4);
	   	    			} 
	   	    			if ( foePoint[i][0] <  foePoint[i][8]+foePoint[i][10] && (manPositionX-foePoint[i][0]) >0 ){
	   	    				foePoint[i][2]+=(manPositionX-foePoint[i][0])/2*Math.abs(r.nextInt()%4);
	   	    			} 
	   	    			if ( foePoint[i][1] >= foePoint[i][9] && (manPositionY-foePoint[i][1]) <0 ){
	   	    				foePoint[i][3]+=(manPositionY-foePoint[i][1])/2*Math.abs(r.nextInt()%4);
	   	    			} 
	   	    			if ( foePoint[i][1] <  foePoint[i][9]+foePoint[i][11] && (manPositionY-foePoint[i][1]) >0 ){
	   	    				foePoint[i][3]+=(manPositionY-foePoint[i][1])/2*Math.abs(r.nextInt()%4);
	   	    			}
	   	    		break;
	   	    		case 0:
	   	    		  if ( currentMap_Under[foePoint[i][1] -1][foePoint[i][0] ] >0  && (foePoint[i][1] -1) > 1){
	   	    		  	foePoint[i][3] -= foeSpeed;
	   	    		  }else{
	   	    		  		foePoint[i][5] = Math.abs(r.nextInt()%4);
	   	    		  }
	   	    		   
	   	    		break;
	   	    		case 1:
	   	    		  if ( currentMap_Under[foePoint[i][1] +1][foePoint[i][0] ] >0   && ( foePoint[i][1] +1) < mapWidth-1 ){
	   	    		  	foePoint[i][3] += foeSpeed;
	   	    		  }else{
	   	    		  	foePoint[i][5] = Math.abs(r.nextInt()%4);
	   	    		  }
	   	    		   
	   	    		break;
	   	    		case 2:
	   	    		  if ( currentMap_Under[foePoint[i][1] ][foePoint[i][0] -1] >0  && ( foePoint[i][0] -1) > 1 ){
	   	    		  	foePoint[i][2] -= foeSpeed;
	   	    		  }else{foePoint[i][5] = Math.abs(r.nextInt()%4);
	   	    		  }
	   	    		   
	   	    		break;
	   	    		case 3:
	   	    		  if ( currentMap_Under[foePoint[i][1] ][foePoint[i][0] +1] >0 && ( foePoint[i][0] +1) < mapHeight -1){
	   	    		  	foePoint[i][2] += foeSpeed;
	   	    		  }else {foePoint[i][5] = Math.abs(r.nextInt()%4);
	   	    		  }
	   	    		   
	   	    		break;
	   	    		case 4://人型物體方向控制
	   	    		   if ( foePoint[i][1] > foePoint[i][9]  && currentMap_Under[foePoint[i][1] -1][foePoint[i][0] ] >0 && currentMap_Under[foePoint[i][1] -2][foePoint[i][0] ] >0  ){
	   	    		  	foePoint[i][3] -= foeSpeed;
	   	    		  	
	   	    		  }else  if ( !canTalking ) {
	   	    		  		foePoint[i][5] = Math.abs(r.nextInt()%4)+4;
	   	    		  }
	   	    		break;
	   	    		case 5://人型物體方向控制
	   	    		   if ( foePoint[i][1] < foePoint[i][9]+foePoint[i][11] && currentMap_Under[foePoint[i][1] +1][foePoint[i][0] ] >0 && currentMap_Under[foePoint[i][1] +2][foePoint[i][0] ] >0  ){
	   	    		  	foePoint[i][3] += foeSpeed;
	   	    		  }else  if (!canTalking ){
	   	    		  		foePoint[i][5] = Math.abs(r.nextInt()%4)+4;
	   	    		  }
	   	    		break;
	   	    		case 6://人型物體方向控制
	   	    		   if ( foePoint[i][0] > foePoint[i][8]  &&  currentMap_Under[foePoint[i][1] ][foePoint[i][0] -1] >0 &&  currentMap_Under[foePoint[i][1] ][foePoint[i][0] -2] >0){
	   	    		  	foePoint[i][2] -= foeSpeed;
	   	    		  }else  if (!canTalking ){
	   	    		  		foePoint[i][5] = Math.abs(r.nextInt()%4)+4;
	   	    		  }
	   	    		break;
	   	    		case 7://人型物體方向控制
	   	    		   if ( foePoint[i][0] < foePoint[i][8]+foePoint[i][10]  && currentMap_Under[foePoint[i][1] ][foePoint[i][0] +1] >0 && currentMap_Under[foePoint[i][1] ][foePoint[i][0] +2] >0   ){
	   	    		  	foePoint[i][2] += foeSpeed;
	   	    		  }else  if (!canTalking ){
	   	    		  		foePoint[i][5] = Math.abs(r.nextInt()%4)+4;
	   	    		  }
	   	    		break;
	   	    	}
	   	    	
	   	      if ( foePoint[i][2] >  16 ){
	   	      	foePoint[i][2] = 0; 
	   	      	 currentMap_Under[foePoint[i][1]][foePoint[i][0]] = (byte)tmpMapPassable; 
 
	   	      	foePoint[i][0]++;
	   	       }else{
	   	      	if(foePoint[i][2]< -16){
	   	      		foePoint[i][2] = 0;
	   	      		currentMap_Under[foePoint[i][1]][foePoint[i][0]] = (byte)tmpMapPassable;  
 
	   	      		foePoint[i][0]--;
	   	        }
	   	      }
	   	      if ( foePoint[i][3] >  16 ){
	   	      	foePoint[i][3] = 0;
	   	      	 currentMap_Under[foePoint[i][1] ][foePoint[i][0]] = (byte)tmpMapPassable; 
 
	   	      	 foePoint[i][1]++;
	   	      	}else{
	   	      		 if(foePoint[i][3]< -16){
	   	      		 		foePoint[i][3] = 0;
	   	      		 	  currentMap_Under[foePoint[i][1] ][foePoint[i][0]] = (byte)tmpMapPassable;  
 
	   	      		 	  foePoint[i][1]--;
	   	      		 	}
	   	      }
	   	      
	   	   		if ( foePoint[i][0] == manPositionX && foePoint[i][1] == manPositionY &&  foePoint[i][12]<0){
	   	   			manHealth -= 5;
	   	   			
	   	   			}//manMove = false;gameState = stateOver;
	   	   		//if ( foePoint[i][0] - manPositionX <= 0 && foePoint[i][1] - manPositionY <= 0){manHealth -= 5;if(manHealth <0){manHealth = 0;}}
	   	      
	   	    }
	   	    //if ( Math.abs((magicPositionX*16+magicX) - (foePoint[i][0]*16+foePoint[i][2]))<=8 && Math.abs((magicPositionY*16+magicY) - (foePoint[i][1]*16+foePoint[i][3]))<=8 && !magicHit){
	   	    	if ( !talking && foePoint[i][12] < 0 && foePoint[i][0] == magicPositionX  && foePoint[i][1] == magicPositionY  && !magicHit){//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=
	   	    //	System.out.println(" !!!!!!!!! ");
	   	    	if(foePoint[i][7] ==1){
	   	    		switch(currentMagic){
	   	    			case 0:
	   	    			   	magicAdd = 0;
	   	    					magicPositionX =0;
	   	    					magicPositionY =0;
	   	    					useMagic = true;
	   	    					magicHit = true;
	   	    			break;	
	   	    			case 1:
	   	    			  foePoint[i][6] --; 
	   	    			  if (foePoint[i][6] <=0) {
	   	    			  	manDart +=10;if (manDart>50){manDart =50;}
	   	    					currentMap_Under[foePoint[i][1] ][foePoint[i][0]] = (byte)tmpMapPassable;
	   	    					    
	   	    					 
	   	    				}
	   	    				magicAdd = 0;
	   	    				magicHit = true;
	   	    				useMagic = true;
	   	    			break;
	   	    			case 2:
	   	    			  foePoint[i][6] --; 
	   	    			  if (foePoint[i][6] <=0) {
	   	    			  	manDart +=10;if (manDart>50){manDart =50;}
	   	    					currentMap_Under[foePoint[i][1] ][foePoint[i][0]] = (byte)tmpMapPassable;
	   	    					
	   	    				}
							magicAdd = 0;
	   	    			 	magicHit = true;
	   	    				useMagic = true;
	   	    				
	   	    			break;		   	    		    			
	   	    		}
	   	    		}
	   	    		 
	   	    	//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=
	   	    } //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=
	   	    
	   		  if (foePoint[i][7] ==1){ // 
	   		  
	   		  	switch(foePoint[i][4]){// 敵人外觀選擇
	   		  		/*case 1:
	   		  	
	   		  			g.setClip( foePoint[i][2]+mapX+(foePoint[i][0]-winX)*16-6,foePoint[i][3]+mapY+(foePoint[i][1]-winY)*16-4,20,20);
	   		  			
	   		  			g.drawImage(cz1 ,foePoint[i][2]+mapX+(foePoint[i][0]-winX)*16-6 - (foeAdd+i)%4*20,foePoint[i][3]+mapY+(foePoint[i][1]-winY)*16-4,20 );
	   		  			
	   		  			g.setClip(0,0,W,H);
	   		  		
	   		  			//g.setColor(246,166,66);
	   						//g.drawRect((foePoint[i][0]-winX)*16+mapX,(foePoint[i][1]-winY)*16+mapY,16,16);
	   		  		 
	   		  		break;*/
	   		  		/*
	   		  		case 2:
	   		  	
	   		  			g.setClip( foePoint[i][2]+mapX+(foePoint[i][0]-winX)*16-10,foePoint[i][3]+mapY+(foePoint[i][1]-winY-1)*16,33,30);
	   		  			g.drawImage(cz2 ,foePoint[i][2]+mapX+(foePoint[i][0]-winX)*16-10 - foeAdd%2*33,foePoint[i][3]+mapY+(foePoint[i][1]-winY-1)*16,20 );
	   		  			g.setClip(0,0,W,H);
	   		  			
	   		  			//g.setColor(246,166,66);
	   						//g.drawRect((foePoint[i][0]-winX)*16+mapX,(foePoint[i][1]-winY)*16+mapY,16,16);
	   		  		break;
	   		  		
	   		  		
	   		  		case 3: //竹筍
	   		  			g.setClip( foePoint[i][2]+mapX+(foePoint[i][0]-winX)*16-3,foePoint[i][3]+mapY+(foePoint[i][1]-winY-1)*16-1,14,35);
	   		  			g.drawImage(cz3 ,foePoint[i][2]+mapX+(foePoint[i][0]-winX)*16-3 - foeAdd%2*14,foePoint[i][3]+mapY+(foePoint[i][1]-winY-1)*16-1,20 );
	   		  			g.setClip(0,0,W,H);//28,37
	   		  		break;*/
	   		  		case 4: //侍女
	   		  			if(talking){
	   		  					g.setClip( foePoint[i][2]+mapX+(foePoint[i][0]-winX)*16-3,foePoint[i][3]+mapY+(foePoint[i][1]-winY-1)*16-7,23,38);
	   		  				  g.drawImage(cz4 ,foePoint[i][2]+mapX+(foePoint[i][0]-winX)*16-3,foePoint[i][3]+mapY+(foePoint[i][1]-winY-1)*16- (foePoint[i][5]-4)*38-7,20 );
	   		  				  g.setClip(0,0,W,H);//28,37
	   		  			}else{
	   		  				g.setClip( foePoint[i][2]+mapX+(foePoint[i][0]-winX)*16-3,foePoint[i][3]+mapY+(foePoint[i][1]-winY-1)*16-7,23,38);
	   		  				g.drawImage(cz4 ,foePoint[i][2]+mapX+(foePoint[i][0]-winX)*16-3 - foeAdd%4*23,foePoint[i][3]+mapY+(f

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -