亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? enemy.java

?? 用java編寫的程序
?? JAVA
字號:
import java.awt.*;

/**
 * 定義敵人的類
 */
public class Enemy{
	private int xPos;
	private int yPos;
	private int xVPos;
	private int yVPos;
	private int direction;
	
	//敵人是否失去反抗能力
	private boolean alarm;
	//敵人失去防抗能力的時間
	private int alarmTime;
	private boolean ghostMode;
	private Rectangle Enemy;
	private int speed;
	private int interval;
	private int Colour;
	private int AI_time1, AI_time2;
	private int lefttime, uptime, righttime, downtime;
	private int gameFlow;
	private boolean ghost;
	private boolean canMoveUp, canMoveDown, canMoveLeft,canMoveRight;
	private boolean cantGoAnyWhere;
	private int prisonTime;
	private boolean stop;
	
	/**
	 **根據x、y、顏色、是否已經出牢籠、剩余多長時間才可出牢籠
	 **構造敵人對象
	 */
	public Enemy(int a, int b, int c, boolean cantGoAnyWhere, int prisonTime){
		xPos = a;
		yPos = b;
		xVPos = xPos;
		yVPos = yVPos;
		direction = 3;
		speed = 3;
		interval = 63 + 21*((int)(Math.random()*10));
		AI_time1 = 0;
		Colour = c;
		this.prisonTime = prisonTime;
		this.cantGoAnyWhere = cantGoAnyWhere;
		Enemy = new Rectangle(xPos -10, yPos - 10, 21, 21);
	}

	/**
	 **方法:敵人的移動
	 */
	public void move(int a, int b, Wall[] wall){
		AI_time1++;
		AI_time2++;
		uptime++;
		downtime++;
		lefttime++;
		righttime++;
		gameFlow++;
		
		//如果敵人沒有反抗能力
		if(alarm)
			alarmTime++;
		boolean changeMovement = false;

		//如果敵人不能移動,就將囚禁得時間不停增加
		if(cantGoAnyWhere)
			prisonTime++;

		//當敵人失去反抗能力后,速度降低
		if(alarm)
			speed = 1;
		else
			speed = 2;

		//失去反抗能力到指定時間后,恢復原態
		if(alarmTime >= 330){
			alarmTime = 0;
			alarm = false;
		}


		canMoveUp = true;
		canMoveDown = true;
		canMoveLeft = true;
		canMoveRight = true;

		Rectangle R;
		Rectangle UP = new Rectangle(xVPos - 10, yVPos - 10 - speed, 21, 21);
		Rectangle DOWN = new Rectangle(xVPos - 10, yVPos - 10 + speed, 21, 21);
		Rectangle LEFT = new Rectangle(xVPos - 10 - speed, yVPos - 10, 21, 21);
		Rectangle RIGHT = new Rectangle(xVPos - 10 + speed, yVPos - 10, 21, 21);

		for(int i = 0; i < wall.length; i++){
			R = new Rectangle(wall[i].getxPos() - 10, wall[i].getyPos() - 10, 21, 21);
			if(R.intersects(UP))
				canMoveUp = false;
			if(prisonTime < 231){
				//確定此 Rectangle R是否與指定 Rectangle UP 相交。如果兩個矩形的交集為非空,則它們是相交的。 
				//如果R與UP相交,則返回 true;否則返回 false。
				if(R.intersects(UP) && direction == 0){
					yPos = yVPos;
					changeMovement = true;
				}
			}

			if(!(ghost && (yVPos >= 189 && yVPos < 231 && xVPos == 210))){
				if(R.intersects(DOWN))
					canMoveDown = false;
				if(R.intersects(DOWN) && direction == 1){
					yPos = yVPos;
					changeMovement = true;
				}
			}

			if(R.intersects(LEFT))
				canMoveLeft = false;
			if(R.intersects(LEFT) && direction == 2){
				xPos = xVPos;
				changeMovement = true;
			}

			if(R.intersects(RIGHT))
				canMoveRight = false;
			if(R.intersects(RIGHT) && direction == 3){
				xPos = xVPos;
				changeMovement = true;
			}
		}

		interval-=speed;
		if(interval <=0)
			changeMovement = true;


		int u = (int)(Math.random()*4);
		if(canMoveUp && direction != 1 && AI_time1 > 10 && u == 0){
			direction = 0;
			xPos = xVPos;
			AI_time1 = 0;
		}
		if(canMoveDown && direction != 0 && AI_time1 > 10 && u == 1){
			direction = 1;
			xPos = xVPos;
			AI_time1 = 0;
		}
		if(canMoveLeft && direction != 3 && AI_time1 > 10 && u == 2){
			direction = 2;
			xPos = xVPos;
			AI_time1 = 0;
		}
		if(canMoveRight && direction != 2 && AI_time1 > 10 && u == 3){
			direction = 3;
			xPos = xVPos;
			AI_time1 = 0;
		}

		if(!alarm && !cantGoAnyWhere){
			if(AI_time2 > 99){
				if(canMoveUp && yPos > b && AI_time2 > 99){
					direction = 0;
					xPos = xVPos;
					AI_time2 = 0;
				}
				if(canMoveDown && yPos < b && AI_time2 > 99){
					direction = 1;
					xPos = xVPos;
					AI_time2 = 0;
				}
				if(canMoveLeft && xPos > a && AI_time2 > 99){
					direction = 2;
					yPos = yVPos;
					AI_time2 = 0;
				}
				if(canMoveRight && xPos < a && AI_time2 > 99){
					direction = 3;
					yPos = yVPos;
					AI_time2 = 0;
				}
			}
		}
		if(alarm){
			if(AI_time2 > 99){
				if(canMoveDown && yPos > b && AI_time2 > 99){
					direction = 1;
					xPos = xVPos;
					AI_time2 = 0;
				}
				if(canMoveUp && yPos < b && AI_time2 > 99){
					direction = 0;
					xPos = xVPos;
					AI_time2 = 0;
				}
				if(canMoveRight && xPos > a && AI_time2 > 99){
					direction = 3;
					yPos = yVPos;
					AI_time2 = 0;
				}
				if(canMoveLeft && xPos < a && AI_time2 > 99){
					direction = 2;
					yPos = yVPos;
					AI_time2 = 0;
				}
			}
		}
		if(ghost){
			a = 210;
			b = 189;
			speed = 4;
			alarm = false;
			alarmTime = 0;
			if(AI_time2 > 99){
				if(canMoveUp && yPos > b && AI_time2 > 99){
					direction = 0;
					xPos = xVPos;
					AI_time2 = 0;
				}
				if(canMoveDown && yPos < b && AI_time2 > 99){
					direction = 1;
					xPos = xVPos;
					AI_time2 = 0;
				}
				if(canMoveLeft && xPos > a && AI_time2 > 99){
					direction = 2;
					yPos = yVPos;
					AI_time2 = 0;
				}
				if(canMoveRight && xPos < a && AI_time2 > 99){
					direction = 3;
					yPos = yVPos;
					AI_time2 = 0;
				}
			}
		}

		if(changeMovement){
			for(;;){
				u = (int)(Math.random()*2);
				if(direction == 0 || direction == 1){
					if(u == 0){
						if(canMoveLeft)
							direction = 2;
						if(canMoveRight)
							direction = 3;
					}
					if(u == 1){
						if(canMoveRight)
							direction = 3;
						if(canMoveLeft)
							direction = 2;
					}
					AI_time1 = 0;
					break;
				}
				if(direction == 2 || direction == 3){
					if(u == 0){
						if(canMoveUp)
							direction = 0;
						if(canMoveDown)
							direction = 1;
					}
					if(u == 1){
						if(canMoveDown)
							direction = 1;
						if(canMoveUp)
							direction = 0;
					}
					if(cantGoAnyWhere){
						if(canMoveLeft)
							direction = 2;
						if(canMoveRight)
							direction = 3;
					}
					AI_time1 = 0;
					break;
				}
			}

			if(!alarm && !ghost && !cantGoAnyWhere){
				if(canMoveLeft && xPos > a && lefttime > 66){
					direction = 2;
					yPos = yVPos;
					AI_time2 = 0;
					lefttime = 0;
				}
				if(canMoveRight && xPos < a && righttime> 66){
					direction = 3;
					yPos = yVPos;
					AI_time2 = 0;
					righttime = 0;
				}
				if(canMoveUp && yPos > b && uptime > 66){
					direction = 0;
					xPos = xVPos;
					AI_time2 = 0;
					uptime = 0;
				}
				if(canMoveDown && yPos < b && downtime > 66){
					direction = 1;
					xPos = xVPos;
					AI_time2 = 0;
					downtime = 0;
				}
			}
			if(alarm && !ghost){
				if(canMoveRight && xPos > a && righttime > 66){
					direction = 3;
					yPos = yVPos;
					AI_time2 = 0;
					lefttime = 0;
				}
				if(canMoveLeft && xPos < a && lefttime> 66){
					direction = 2;
					yPos = yVPos;
					AI_time2 = 0;
					righttime = 0;
				}
				if(canMoveDown && yPos > b && downtime > 66){
					direction = 1;
					xPos = xVPos;
					AI_time2 = 0;
					uptime = 0;
				}
				if(canMoveUp && yPos < b && uptime > 66){
					direction = 0;
					xPos = xVPos;
					AI_time2 = 0;
					downtime = 0;
				}
			}
			if(ghost){
				a = 210;
				b = 189;
				if(canMoveLeft && xPos > a && lefttime > 66){
					direction = 2;
					yPos = yVPos;
					AI_time2 = 0;
					lefttime = 0;
				}
				if(canMoveRight && xPos < a && righttime> 66){
					direction = 3;
					yPos = yVPos;
					AI_time2 = 0;
					righttime = 0;
				}
				if(canMoveUp && yPos > b && uptime > 66){
					direction = 0;
					xPos = xVPos;
					AI_time2 = 0;
					uptime = 0;
				}
				if(canMoveDown && yPos < b && downtime > 66){
					direction = 1;
					xPos = xVPos;
					AI_time2 = 0;
					downtime = 0;
				}
			}
			interval = 63 + 21*((int)(Math.random()*10));
		}

		if(ghost){
			if(xVPos == 189 && yVPos == 441)
				direction = 0;
			if(xVPos == 231 && yVPos == 441)
				direction = 0;
			if(xVPos == 189 && yVPos == 399)
				direction = 2;
			if(xVPos == 231 && yVPos == 399)
				direction = 3;
			if(xVPos == 189 && yVPos == 357)
				direction = 0;
			if(xVPos == 231 && yVPos == 357)
				direction = 0;
			if(xVPos == 189 && yVPos == 315)
				direction = 2;
			if(xVPos == 231 && yVPos == 315)
				direction = 3;
			if(xVPos == 147 && yVPos == 315)
				direction = 0;
			if(xVPos == 273 && yVPos == 315)
				direction = 0;
			if(xVPos == 105 && yVPos == 231)
				direction = 3;
			if(xVPos == 315 && yVPos == 231)
				direction = 2;
			if(xVPos == 147 && yVPos == 105)
				direction = 1;
			if(xVPos == 273 && yVPos == 105)
				direction = 1;
			if(yVPos >= 189 && yVPos < 231 && xVPos == 210)
				direction = 1;
			if(xVPos == 210 && yVPos == 231){
				ghost = false;
				speed = 2;
				cantGoAnyWhere = true;
				prisonTime = 0;
			}
		}

		if(prisonTime > 231){
			if(yVPos > 189 && yVPos <= 231 && xVPos == 210){
				direction = 0;
				canMoveUp = true;
			}
			if(yVPos == 189){
				prisonTime = 0;
				cantGoAnyWhere = false;
			}
		}

		if(stop)
			speed = 0;
		if(direction == 0 && canMoveUp)
			yPos-=speed;
		if(direction == 1 && canMoveDown)
			yPos+=speed;
		if(direction == 2 && canMoveLeft)
			xPos-=speed;
		if(direction == 3 && canMoveRight)
			xPos+=speed;


		if(direction == 2 && xPos < 0)
			xPos = 420;
		if(direction == 3 && xPos > 420)
			xPos = 0;

		Enemy = new Rectangle(xPos -10, yPos - 10, 21, 21);

		a = (xPos - 10)/21;
		b = (xPos - 10)%21;
		if(b < 6)
			b = 0;
		if(b > 16)
			b = 21;
		if(b < 17 && b > 5)
			b = 11;
		xVPos = a*21 + b + 10;

		int c = (yPos - 10)/21;
		int d = (yPos - 10)%21;
		if(d < 6)
			d = 0;
		if(d > 16)
			d = 21;
		if(d < 17 && d > 5)
			d = 11;
		yVPos = c*21 + d + 10;
	}

	public void draw(Graphics g){
		if(Colour == 1)
			g.setColor(Color.red);
		if(Colour == 2)
			g.setColor(Color.cyan);
		if(Colour == 3)
			g.setColor(Color.pink);
		if(Colour == 4)
			g.setColor(Color.orange);
		
		//Polygon 類封裝了坐標空間中封閉的二維區域的描述。此區域以任意條線段為邊界,每條線段都是多邊形的一條邊
		Polygon Ghost = null;
		if(gameFlow% 16 > 8){
			int[] xPoints = {xPos - 5,
						xPos - 9,
						xPos - 9,
						xPos - 6,
						xPos - 3,
						xPos,
						xPos + 3,
						xPos + 6,
						xPos + 10,
						xPos + 10,
						xPos + 5,
					};
			int[] yPoints = new int[] {yPos - 9,
						yPos - 4,
						yPos + 9,
						yPos + 4,
						yPos + 9,
						yPos + 4,
						yPos + 9,
						yPos + 4,
						yPos + 9,
						yPos - 4,
						yPos - 9,
					};
			//初始化新的 Polygon。 
			//參數:xPoints為x坐標的數組;yPoints為y坐標的數組;xPoints.length為此Polygon中點的總數 
			Ghost = new Polygon (xPoints, yPoints, xPoints.length);
		}

		if(gameFlow% 16 < 9){
			int[] xPoints = {xPos - 5,
						xPos - 9,
						xPos - 9,
						xPos - 6,
						xPos,
						xPos + 6,
						xPos + 10,
						xPos + 10,
						xPos + 5,
					};
			int[] yPoints = new int[] {yPos - 9,
						yPos - 4,
						yPos + 9,
						yPos + 4,
						yPos + 9,
						yPos + 4,
						yPos + 9,
						yPos - 4,
						yPos - 9,
					};
			Ghost = new Polygon (xPoints, yPoints, xPoints.length);
		}
		
		if(!alarm && !ghost){
			//用圖形上下文的當前顏色填充由指定的Polygon對象定義的多邊形Ghost。
			g.fillPolygon(Ghost);
		}

		//如果敵人沒有失去反抗能力,則用藍色進行填充敵人的整體,用白色填充敵人的眼睛。
		if(!alarm || ghost){
			//填充敵人眼睛的白色部分
			g.setColor(Color.white);
			g.fillOval(xPos - 8, yPos - 5, 7, 8);
			g.fillOval(xPos + 2, yPos - 5, 7, 8);
			
			//填充敵人眼睛中的藍色十字部分
			g.setColor(Color.blue);
			if(direction == 0){
				//使用當前顏色填充外接指定矩形框的橢圓。
				g.fillOval(xPos - 6, yPos - 4, 3, 4);
				g.fillOval(xPos + 4, yPos - 4, 3, 4);
			}
			if(direction == 1){
				g.fillOval(xPos - 6, yPos - 2, 3, 4);
				g.fillOval(xPos + 4, yPos - 2, 3, 4);
			}
			if(direction == 2){
				g.fillOval(xPos - 7, yPos - 3, 3, 4);
				g.fillOval(xPos + 3, yPos - 3, 3, 4);
			}
			if(direction == 3){
				g.fillOval(xPos - 5, yPos - 3, 3, 4);
				g.fillOval(xPos + 5, yPos - 3, 3, 4);
			}
		}
		//如果敵人失去反抗能力
		if(alarm){
			g.setColor(Color.blue);
			
			//當敵人即將恢復攻擊能力時,將其顏色顯示為灰色
			if(alarmTime >= 231 && alarmTime%6 > 2)
				g.setColor(Color.lightGray);
			g.fillPolygon(Ghost);
			
			g.setColor(Color.white);
			g.fillOval(xPos - 6, yPos - 6, 5, 6);
			g.fillOval(xPos + 2, yPos - 6, 5, 6);
			
			//在此圖形上下文的坐標系統中,使用當前顏色(白色),
			//在點(xPos - 6, yPos + 3)和(xPos - 4, yPos + 1)之間畫一條線。 
			g.drawLine(xPos - 6, yPos + 3, xPos - 4, yPos + 1);
			g.drawLine(xPos - 4, yPos + 1, xPos - 2, yPos + 3);
			g.drawLine(xPos - 2, yPos + 3, xPos, yPos + 1);
			g.drawLine(xPos, yPos + 1, xPos + 2, yPos + 3);
			g.drawLine(xPos + 2, yPos + 3, xPos + 4, yPos + 1);
			g.drawLine(xPos + 4, yPos + 1, xPos + 6, yPos + 3);
		}
	}
	
	/**
	 **方法:設置敵人是否處于失去反抗能力的狀態
	 */
	public void Alarm(int a){
		if(a == 1)
			alarm = true;
		if(a == 2)
			alarm = false;
		alarmTime = 0;
	}

	public void Ghost(){
		ghost = true;
		alarmTime = 0;
	}

	public Rectangle getBorder(){
		return Enemy;
	}

	public int status(){
		int a = 0;
		if(alarm)
			a = 1;
		if(ghost)
			a = 2;
		return a;
	}

	public void stop(){
		stop = true;
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美精品第1页| 国产精品99久久久久| 日本精品免费观看高清观看| 亚洲精品菠萝久久久久久久| 99久久综合色| 亚洲午夜视频在线| 日韩欧美一区在线观看| 狠狠色丁香九九婷婷综合五月| 久久色在线观看| www.久久精品| 亚洲国产另类av| 久久夜色精品国产噜噜av| 99久久精品国产网站| 一区av在线播放| 欧美一区二区在线观看| 国产精品综合二区| 日韩毛片视频在线看| 在线不卡欧美精品一区二区三区| 狠狠久久亚洲欧美| 亚洲欧美日韩综合aⅴ视频| 欧美肥妇bbw| 成人精品在线视频观看| 三级久久三级久久| 国产精品嫩草99a| 欧美日韩高清在线| 国产成人免费视频一区| 一级精品视频在线观看宜春院 | 亚洲一区二区三区在线| 欧美zozo另类异族| 91成人网在线| 国产不卡高清在线观看视频| 亚洲高清不卡在线观看| 中文字幕欧美区| 欧美一级久久久久久久大片| 97精品国产97久久久久久久久久久久| 日韩黄色一级片| 亚洲免费观看视频| 国产亚洲va综合人人澡精品 | 蜜桃一区二区三区在线| 国产精品不卡在线观看| 日韩欧美国产综合一区| 色一情一乱一乱一91av| 国产精品一区二区在线观看不卡 | 亚洲同性同志一二三专区| 日韩欧美色综合| 欧美无人高清视频在线观看| 国产成人在线观看| 美女高潮久久久| 五月婷婷激情综合网| 中文字幕色av一区二区三区| 欧美tickling挠脚心丨vk| 在线免费精品视频| 99久久er热在这里只有精品66| 激情成人午夜视频| 蜜臀a∨国产成人精品| 亚洲国产欧美日韩另类综合| 亚洲三级小视频| 国产精品色哟哟网站| 26uuuu精品一区二区| 91精品国产一区二区三区| 日本电影欧美片| 99热这里都是精品| 大胆亚洲人体视频| 国产成人av电影免费在线观看| 经典三级视频一区| 精油按摩中文字幕久久| 奇米亚洲午夜久久精品| 日韩精品三区四区| 天堂成人国产精品一区| 性做久久久久久久久| 亚洲综合丁香婷婷六月香| 亚洲黄色在线视频| 亚洲欧美日韩在线播放| 亚洲黄色录像片| 一区二区在线观看视频在线观看| 亚洲视频一二区| 亚洲三级理论片| 亚洲综合丁香婷婷六月香| 一区二区三区四区中文字幕| 亚洲精品乱码久久久久久久久 | 欧美在线免费观看亚洲| 色婷婷综合久久久久中文一区二区 | 国产欧美视频在线观看| 欧美va在线播放| 久久综合九色综合欧美98| 久久久久久久国产精品影院| 久久丝袜美腿综合| 国产成人在线看| 国产视频一区二区在线观看| 色婷婷av一区二区三区大白胸 | 久久精品理论片| 久久超碰97人人做人人爱| 国产精品1024| 中文成人综合网| 国产精品三级在线观看| 精品日韩一区二区| 国产精品久线观看视频| 青娱乐精品视频| 日本二三区不卡| 中文字幕久久午夜不卡| 奇米精品一区二区三区四区| 91麻豆精品在线观看| 精品国产亚洲在线| 日本亚洲三级在线| 色综合久久综合网97色综合| 久久久亚洲午夜电影| 无吗不卡中文字幕| 一道本成人在线| 国产精品人妖ts系列视频| 青青草国产精品亚洲专区无| 欧美午夜精品一区二区蜜桃| 国产亚洲一二三区| 卡一卡二国产精品 | 精品婷婷伊人一区三区三| 国产精品美女久久久久久久久| 老司机精品视频在线| 欧美视频自拍偷拍| 亚洲欧美韩国综合色| 国产成人免费av在线| 欧美videossexotv100| 偷偷要91色婷婷| 欧美又粗又大又爽| 中文字幕人成不卡一区| 国产成人亚洲综合色影视| 日韩欧美123| 毛片av中文字幕一区二区| 欧美午夜精品一区二区三区| 亚洲精品乱码久久久久久久久| 成人免费黄色在线| 久久久午夜电影| 国产在线不卡一区| 欧美成人国产一区二区| 轻轻草成人在线| 日韩三级伦理片妻子的秘密按摩| 亚洲一本大道在线| 精品视频一区二区不卡| 亚洲高清在线精品| 欧美美女激情18p| 亚洲r级在线视频| 欧美精品一卡两卡| 丝袜诱惑亚洲看片| 欧美老年两性高潮| 日本中文一区二区三区| 欧美一区二区视频在线观看| 美腿丝袜亚洲综合| 久久综合久久综合久久综合| 韩日欧美一区二区三区| 久久久99精品免费观看| 国产成人在线影院| 最新国产の精品合集bt伙计| 99re在线精品| 亚洲自拍另类综合| 欧美老肥妇做.爰bbww视频| 日韩av中文在线观看| 日韩精品一区二区三区三区免费| 国产一区二区三区精品视频| 精品国产露脸精彩对白| a级高清视频欧美日韩| 国产精品高潮久久久久无| 欧美性受xxxx黑人xyx性爽| 亚洲线精品一区二区三区| 欧美成人精品福利| 国产精品18久久久久久久久| 亚洲特级片在线| 欧美高清一级片在线| 国内精品久久久久影院薰衣草| 欧美激情一区在线观看| 在线观看日韩国产| 精品亚洲成a人| 国产精品久99| 91麻豆精品国产自产在线| 九一久久久久久| 亚洲乱码国产乱码精品精98午夜 | 欧美国产一区二区在线观看| 91亚洲精品久久久蜜桃| 全部av―极品视觉盛宴亚洲| 久久精品无码一区二区三区| 色成人在线视频| 精品亚洲国内自在自线福利| 国产精品久久网站| 欧美一区二区日韩| 成人黄色av网站在线| 午夜成人免费视频| 欧美日韩亚洲丝袜制服| 日韩一区二区三区免费看 | 日韩高清不卡一区二区三区| 国产日韩精品一区二区三区在线| 91国产视频在线观看| 久久爱www久久做| 亚洲免费色视频| 欧美精品一区二区三区在线| 一本色道a无线码一区v| 精品一区二区三区免费播放| 亚洲欧洲日产国码二区| 欧美一区二区三区四区在线观看 | 久久久国际精品| 欧美日韩视频专区在线播放| 成人午夜又粗又硬又大| 日韩中文字幕不卡| 亚洲视频精选在线|