monstersprite.java

来自「一个征途的rpg小游戏」· Java 代码 · 共 954 行 · 第 1/3 页

JAVA
954
字号
						}
						if(isWalkable[rdX+1][rdY]){
							x=x+4;
							this.nextFrame();
						}else{
							isSmart=false;
							dir=DIR_LEFT-1;
							this.setFrameSequence(left_seq);
						}
					}else{
						isStop=true;						
						if(isBattle==false){
							isBattle=true;	
							this.setFrameSequence(rightb_seq);
							this.nextFrame();
						}else{
							if(j<stopTime-battleSpeed){
								j++;
								isStopb=true;
								this.setFrameSequence(right);
							}else{
								if(isStopb==true){
									isStopb=false;
									this.setFrameSequence(rightb_seq);
								}								
								if(this.getFrame()==2){
									if(heroHp>0){
										heroHp=heroHp-heroBd;
									}
									j=0;
								}								
								this.nextFrame();
							}
						}
					}
				}
				break;
			case DIR_UP:
				if(!isSmart){
					if(centerDis<moveDis){
						i=0;
						if(isWalkable[ldX][ldY-1] && isWalkable[rdX][rdY-1]){
							this.y=this.y-4;
							this.nextFrame();							
						}else{
							dir=DIR_DOWN-1;
							this.setFrameSequence(down_seq);
						}
						}else{
							this.setFrameSequence(up);
							i++;
							if(i==stopTime){
								tempX=x;
								tempY=y;
								this.chgDir();							
							}
						}
				}else{
					if(!this.collidesWith(heroSprite,true)){
						if(isBattle==true){
							isBattle=false;
							this.setFrameSequence(up_seq);
						}
						if(isStop==true){
							this.setFrameSequence(up_seq);
							isStop=false;
						}
						if(isWalkable[ldX][ldY-1] && isWalkable[rdX][rdY-1]){
							y=y-4;
							this.nextFrame();	
						}else{
							isSmart=false;
							dir=DIR_DOWN-1;
							this.setFrameSequence(down_seq);
						}
					}else{
						isStop=true;						
						if(isBattle==false){
							isBattle=true;							
							this.setFrameSequence(upb_seq);
							this.nextFrame();
						}else{
							if(j<stopTime-battleSpeed){
								j++;
								isStopb=true;
								this.setFrameSequence(up);
							}else{
								if(isStopb==true){
									isStopb=false;
									this.setFrameSequence(upb_seq);
								}								
								if(this.getFrame()==2){
									if(heroHp>0){
										heroHp=heroHp-heroBd;
									}
									j=0;
								}								
								this.nextFrame();
							}
						}
					}
				}
				break;
			case DIR_DOWN:
				if(!isSmart){
					if(centerDis<moveDis){
						i=0;
						if(isWalkable[ldX][ldY+1] && isWalkable[rdX][rdY+1]){
							this.y=this.y+4;
							this.nextFrame();
						}else{
							dir=DIR_UP-1;
							this.setFrameSequence(up_seq);
						}
					}else{
						this.setFrameSequence(down);
						i++;
						if(i==stopTime){
							tempX=x;
							tempY=y;
							this.chgDir();							
						}
					}
				}else{
					if(!this.collidesWith(heroSprite,true)){
						if(isBattle==true){
							isBattle=false;
							this.setFrameSequence(down_seq);
						}
						if(isStop==true){
							this.setFrameSequence(down_seq);
							isStop=false;
						}
						if(isWalkable[ldX][ldY+1] && isWalkable[rdX][rdY+1]){
							y=y+4;
							this.nextFrame();
						}else{
							isSmart=false;
							dir=DIR_UP-1;	
							this.setFrameSequence(up_seq);
						}
					}else{
						isStop=true;						
						if(isBattle==false){
							isBattle=true;							
							this.setFrameSequence(downb_seq);
							this.nextFrame();
						}else{
							if(j<stopTime-battleSpeed){
								j++;
								isStopb=true;
								this.setFrameSequence(down);
							}else{
								if(isStopb==true){
									isStopb=false;
									this.setFrameSequence(downb_seq);
								}								
								if(this.getFrame()==2){
									if(heroHp>0){
										heroHp=heroHp-heroBd;
									}
									j=0;
								}								
								this.nextFrame();
							}
						}
					}
				}
				break;
			case DIR_LU:
				if(!isSmart){
					if(centerDis<moveDis){
						i=0;
						if(isWalkable[ldX-1][ldY] && isWalkable[ldX][ldY-1] && isWalkable[rdX][rdY-1]){
							this.x=this.x-2;
							this.y=this.y-2;
							this.nextFrame();
						}else{
							isSmart=false;
							dir=DIR_RD-1;
							this.setFrameSequence(rd_seq);
						}
					}else{
						this.setFrameSequence(lu);
						i++;
						if(i==stopTime){
							tempX=x;
							tempY=y;
							this.chgDir();							
						}
					}
				}else{
					if(!this.collidesWith(heroSprite,true)){
						if(isStop==true){
							this.setFrameSequence(lu_seq);
							isStop=false;
						}
						if(isBattle==true){
							isBattle=false;
							this.setFrameSequence(lu_seq);
						}
						if(isWalkable[ldX-1][ldY] && isWalkable[luX][ldY-1] && isWalkable[rdX][ruY-1]){
							x=x-2;
							y=y-2;
							this.nextFrame();
						}else{
							isSmart=false;
							dir=DIR_RD-1;
							this.setFrameSequence(rd_seq);
						}													
					}else{
						isStop=true;						
						if(isBattle==false){
							isBattle=true;							
							this.setFrameSequence(lub_seq);
							this.nextFrame();
						}else{
							if(j<stopTime-battleSpeed){
								j++;
								isStopb=true;
								this.setFrameSequence(lu);
							}else{
								if(isStopb==true){
									isStopb=false;
									this.setFrameSequence(lub_seq);
								}								
								if(this.getFrame()==2){
									if(heroHp>0){
										heroHp=heroHp-heroBd;
									}
									j=0;
								}								
								this.nextFrame();
							}
						}
					}
				}
				break;
			case DIR_RU:
				if(!isSmart){
					if(centerDis<moveDis){
						i=0;
						if(isWalkable[ldX][ldY-1] && isWalkable[rdX][rdY-1] && isWalkable[rdX+1][rdY]){
							this.x=this.x+2;
							this.y=this.y-2;
							this.nextFrame();
						}else{
							dir=DIR_LD-1;
							this.setFrameSequence(ld_seq);
						}
					}else{
						this.setFrameSequence(ru);
						i++;
						if(i==stopTime){
							tempX=x;
							tempY=y;
							this.chgDir();							
						}
					}
				}else{
					if(!this.collidesWith(heroSprite,true)){
						if(isStop==true){
							this.setFrameSequence(ru_seq);
							isStop=false;
						}
						if(isBattle==true){
							isBattle=false;
							this.setFrameSequence(rd_seq);
						}
						if(isWalkable[ldX][ldY-1] && isWalkable[rdX][rdY-1] && isWalkable[rdX+1][rdY]){
							x=x+2;
							y=y-2;
							this.nextFrame();
						}else{
							isSmart=false;
							dir=DIR_LD-1;
							this.setFrameSequence(ld_seq);
						}
					}else{
						isStop=true;						
						if(isBattle==false){
							isBattle=true;							
							this.setFrameSequence(rub_seq);
							this.nextFrame();
						}else{
							if(j<stopTime-battleSpeed){
								j++;
								isStopb=true;
								this.setFrameSequence(ru);
							}else{
								if(isStopb==true){
									isStopb=false;
									this.setFrameSequence(rub_seq);
								}								
								if(this.getFrame()==2){
									if(heroHp>0){
										heroHp=heroHp-heroBd;
									}
									j=0;
								}								
								this.nextFrame();
							}
						}
					}
				}					
				break;
			case DIR_RD:
				if(!isSmart){
					if(centerDis<moveDis){
						i=0;
						if(isWalkable[rdX+1][rdY] && isWalkable[ldX][ldY+1] && isWalkable[rdX][rdY+1]){
							this.x=this.x+2;
							this.y=this.y+2;
							this.nextFrame();
						}else{
							dir=DIR_LU-1;
							this.setFrameSequence(lu_seq);
						}

⌨️ 快捷键说明

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