?? bullet.java
字號:
if(direction_num == 1)
foe_bullet[i][8]=5;
if(direction_num ==2)
foe_bullet[i][8]=2;
break;
case 3://向左下方發
bullet_direction = 1;
if(direction_num ==0)
foe_bullet[i][8] = 4;
if(direction_num == 1)
foe_bullet[i][8]=1;
if(direction_num ==2)
foe_bullet[i][8]=5;
break;
case 4://向右下方發
bullet_direction = 2;
if(direction_num ==0)
foe_bullet[i][8] = 5;
if(direction_num == 1)
foe_bullet[i][8]=2;
if(direction_num ==2)
foe_bullet[i][8]=3;
break;
}
foe_bullet[i][3] = foe_speed * arc_num_x[bullet_direction*3+direction_num]/10000;//X方向速度
foe_bullet[i][2] = foe_speed * arc_num_y[bullet_direction*3+direction_num]/10000;//Y方向速度
direction_num++;
}else{//其它精靈的攻擊
switch(foe_face_direction){//根據精靈當前的面向來確定箭支發出的方向!
case 3://向左下發
foe_bullet[i][3] = (-1) * foe_speed * 7071/10000;//X方向速度
foe_bullet[i][2] = foe_speed * 7071/10000;//Y方向速度
foe_bullet[i][8] = 1;
break;
case 1://向上發
foe_bullet[i][3] = 0;
foe_bullet[i][2] = (-1)*foe_speed;
foe_bullet[i][8] = 6;
break;
case 4://向右下發
foe_bullet[i][3] = foe_speed * 7071/10000;
foe_bullet[i][2] = foe_speed * 7071/10000;
foe_bullet[i][8] = 2;
break;
case 2://向下發
foe_bullet[i][3] = 0;
foe_bullet[i][2] = foe_speed;
foe_bullet[i][8] = 5;
break;
}
}
try{
foe_bullet[i][13] = arrow_attack_area[(play_bullet[i][8]+5)*4];
foe_bullet[i][14] = arrow_attack_area[(play_bullet[i][8]+5)*4+1];
foe_bullet[i][9] = arrow_attack_area[(play_bullet[i][8]+5)*4+2];
foe_bullet[i][10] = arrow_attack_area[(play_bullet[i][8]+5)*4+3];
foe_bullet[i][7] = 1;//標志此只箭已經發射出去!
}catch(ArrayIndexOutOfBoundsException e){
System.out.println("play_bullet[i][8]+5====="+play_bullet[i][8]+5);
System.out.println(e.toString());
e.printStackTrace();
}
}
}
}
/**
*更新精靈子彈的坐標
*@parameter yview 為當前視圖的最上邊Y坐標.bullet_range 為此類種類型的精靈的射程.bullet_sort 精靈的類型
*bow_sort 子彈的類型
*/
public void update_foe_bullet_point(int yview,int bow_sort){//,int bullet_range,int bullet_sort
for(int i = 0 ; i<FOE_BULLET_NUM;i++){
if(foe_bullet[i][4] == 1 && foe_bullet[i][7] == 1){
int temX = (foe_bullet[i][0] - foe_bullet[i][5]);
int temY = (foe_bullet[i][1] - foe_bullet[i][6]);
//System.out.println("精靈的類型=="+foe_bullet[i][11]);
switch(foe_bullet[i][11]){//這里可以用foe_bullet[i][11]來代替精靈的類型
case 1://雕騎兵
case 6://Boss
if((temX * temX + temY * temY) > (foe_bullet[i][12] * foe_bullet[i][12]) || foe_bullet[i][0] < 0 || foe_bullet[i][0] > 176 || foe_bullet[i][1] < yview || foe_bullet[i][1] > yview + 208){
foe_bullet[i][4] = 0;
foe_bullet[i][7] = 0;
foe_bullet[i][8] = 0;
foe_bullet[i][11] = 0;
foe_bullet[i][12] = 0;
}
break;
case 2://弓騎兵
if((temX * temX + temY * temY) > (foe_bullet[i][12] * foe_bullet[i][12]) || foe_bullet[i][0] < 0 || foe_bullet[i][0] > 176 || foe_bullet[i][1] < yview || foe_bullet[i][1] > yview + 208){
foe_bullet[i][4] = 0;
foe_bullet[i][7] = 0;
foe_bullet[i][8] = 0;
foe_bullet[i][11] = 0;
foe_bullet[i][12] = 0;
}
break;
case 3://千騎長
case 11://兵營
if((temX * temX + temY * temY) > (foe_bullet[i][12] * foe_bullet[i][12]) || foe_bullet[i][0] < 0 || foe_bullet[i][0] > 176 || foe_bullet[i][1] < yview || foe_bullet[i][1] > yview + 208){
foe_bullet[i][4] = 0;
foe_bullet[i][7] = 0;
foe_bullet[i][8] = 0;
foe_bullet[i][11] = 0;
foe_bullet[i][12] = 0;
}
break;
case 4://弩步兵
if((temX * temX + temY * temY) > (foe_bullet[i][12] * foe_bullet[i][12]) || foe_bullet[i][0] < 0 || foe_bullet[i][0] > 176 || foe_bullet[i][1] < yview || foe_bullet[i][1] > yview + 208){
foe_bullet[i][4] = 0;
foe_bullet[i][7] = 0;
foe_bullet[i][8] = 0;
foe_bullet[i][11] = 0;
foe_bullet[i][12] = 0;
}
break;
}
//System.out.println("foe_bullet[i][3]==="+foe_bullet[i][3]);
if(foe_bullet[i][11] == bow_sort){
foe_bullet[i][0] +=foe_bullet[i][3];
foe_bullet[i][1] +=foe_bullet[i][2];
}
/*int temX = (foe_bullet[i][0] - foe_bullet[i][5]);
int temY = (foe_bullet[i][1] - foe_bullet[i][6]);
if((temX * temX + temY * temY) > (bullet_range * bullet_range) || foe_bullet[i][0] < 0 || foe_bullet[i][0] > 176 || foe_bullet[i][1] < yview || foe_bullet[i][1] > yview + 208){
foe_bullet[i][4] = 0;
foe_bullet[i][7] = 0;
foe_bullet[i][8] = 0;
}*/
}
}
}
/**
*畫精靈的子彈
*@parameter
*foe_bow_sort 弓箭的類型
*/
public void draw_foe_bullet(Graphics g, int yview,int foe_bow_sort){
for(int i=0;i<FOE_BULLET_NUM;i++){
if(foe_bullet[i][4] == 1 && foe_bullet[i][7]==1){
X = arrowimgdata[(foe_bullet[i][8]+8)*4];
Y = arrowimgdata[(foe_bullet[i][8]+8)*4+1];
w1 = arrowimgdata[(foe_bullet[i][8]+8)*4+2];
h1 = arrowimgdata[(foe_bullet[i][8]+8)*4+3];
// if(foe_bullet[i][9] == 0 || foe_bullet[i][10] == 0){//賦值,保存圖片的寬和高
// foe_bullet[i][9] = w1;
// foe_bullet[i][10] = h1;
// }
if(foe_bullet[i][11] == foe_bow_sort){
try{
g.setClip(foe_bullet[i][0],foe_bullet[i][1],w1,h1);//畫小圖片
g.drawImage(FlyGenCavans.Game_Arrow,foe_bullet[i][0]-X,foe_bullet[i][1]-Y,Graphics.LEFT|Graphics.TOP);//畫大圖片
g.setClip(0, 0, 176, 208);
}catch (Exception e) {}
}
}
}
}
/**
*檢測敵人對玩家造成傷害
*@parameter
*Hero hero 被攻擊的玩家
*/
public void check_attack_hero(Hero hero){
boolean tem_hide = false;
for(int i=0;i<PLAY_BULLET_NUM;i++){
if(foe_bullet[i][4] == 1 && foe_bullet[i][7]==1){
if(MapTool.isIntersectingRect(foe_bullet[i][0]+foe_bullet[i][13], foe_bullet[i][1]+foe_bullet[i][14], foe_bullet[i][9], foe_bullet[i][10], hero.getX(), hero.getY(), hero.getWidth(), hero.getHeight())){
if(hero.hero_property[19]>0){
hero.hero_property[19]-=foe_bullet[i][15];
}else
hero.hero_property[0]-=foe_bullet[i][15];
tem_hide = true;
}
if(hero.hero_property[9]==1 && hero.hero_property[22] == 0 && MapTool.isIntersectingRect(foe_bullet[i][0]+foe_bullet[i][13], foe_bullet[i][1]+foe_bullet[i][14], foe_bullet[i][9], foe_bullet[i][10], hero.hero_servant.getX(), hero.hero_servant.getY(), hero.hero_servant.getWidth(), hero.hero_servant.getHeight())){
tem_hide = true;
hero.hero_servant.hero_servant_property[0]-=foe_bullet[i][15];
}
if(tem_hide){
foe_bullet[i][4] = 0;
foe_bullet[i][7] = 0;
foe_bullet[i][8] = 0;
foe_bullet[i][9] = 0;
foe_bullet[i][10] = 0;
foe_bullet[i][11] = 0;
foe_bullet[i][13] = 0;
foe_bullet[i][14] = 0;
foe_bullet[i][15] = 0;
}
// if(hero_play.hero_property[1]!=1 || play_bullet[i][11]==2){
}
}
}
protected int w1, h1; //當前動作圖像的寬,高
protected int X,Y;//當前人物圖象在大圖片的位置
//protected int currently_x, currently_y; //當前所處位置,y是腳底的坐標
public static final short[] arrowimgdata ={//x,y,w,h
0,6,15,15,//一般弓箭
15,4,5,20,
20,6,15,15,//穿心箭
35,4,22,22,
57,0,5,30,
62,4,22,22,//火箭
84,3,23,24,
107,0,8,30,
115,3,23,24,//敵人弓箭
138,7,15,15,
153,7,15,15,
168,12,20,7,
188,12,20,7,
208,5,5,20,
213,5,5,20
};
public static final short[] arrow_attack_area ={
0,0,5,5,//一般弓箭的攻擊范圍
0,0,5,5,
10,0,5,5,
0,0,7,7,//穿心箭的攻擊范圍
0,0,5,7,
15,0,7,7,
0,9,6,6,//敵人弓箭的攻擊范圍
9,9,6,6,
13,0,7,7,
0,0,7,7,
0,14,5,6,
0,0,5,6
};
//http://www.comicfans.net/
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -