📄 boss.java
字号:
import javax.microedition.lcdui.Graphics;
public abstract class Boss extends Actor{
public Boss(){
world = World.getInstance();
planeActor = BattlePlaneActor.getInstance();
}
public int getBulletInterval() {
return bulletInterval;
}
public void setBulletInterval(int bulletInterval) {
this.bulletInterval = bulletInterval;
}
// 死亡的时候爆炸的效果
public void bomb(int xPos, int yPos, int xSpeed, int ySpeed) {
if (bombTimes % 5 == 0) {
switch ((bombTimes / 5) - 1) {
case 0:
world.newBullet(7, xPos - (10 << 8), yPos - (48 << 8), xSpeed,
ySpeed);
break;
case 1:
world.newBullet(7, xPos + (16 << 8), yPos - (32 << 8), xSpeed,
ySpeed);
break;
case 2:
world.newBullet(7, xPos + (24 << 8), yPos - (8 << 8), xSpeed,
ySpeed);
break;
case 3:
world.newBullet(7, xPos, yPos + (32 << 8), xSpeed, ySpeed);
break;
case 4:
world.newBullet(7, xPos - (16 << 8), yPos + (24 << 8), xSpeed,
ySpeed);
break;
case 5:
world.newBullet(7, xPos + (8 << 8), yPos + (8 << 8), xSpeed,
ySpeed);
break;
}
}
if (bombTimes == 30) {
bombTimes = 0;
}
bombTimes++;
}
public void isCollide(){
isCollideWithBullet(world.getPlaneBulletPool());
isCollideWithBullet(world.getPlaneRocketPool());
isCollideWithBombBullet(world.getPlaneBombPool());
}
private void isCollideWithBullet(ObjectPool objectPool){
if(objectPool != null){
if (objectPool.getUseObjectNum() == 0) {
return;
}
Object[] bullets = objectPool.getFreeActor();
for (int idx = 0; idx < bullets.length; idx++) {
Bullet bullet = (Bullet) bullets[idx];
if (bullet.isNotUsed() == true) {
continue;
}
isCollideWithBoss(bullet);
if (isCollide == true) {
BattlePlaneActor.iScore += 10;
objectPool.releasUsed(bullet);
isCollide = false;
}
}
}
}
private void isCollideWithBombBullet(ObjectPool objectPool) {
if(objectPool != null){
if (objectPool.getUseObjectNum() == 0) {
return;
}
Object[] bullets = objectPool.getFreeActor();
for (int idx = 0; idx < bullets.length; idx++) {
Bullet bullet = (Bullet) bullets[idx];
if (bullet.isNotUsed() == true) {
continue;
}
isCollideWithBoss(bullet);
objectPool.releasUsed(bullet);
}
}
}
public abstract void isCollideWithBoss();
public void isCollideWithBoss(Bullet bullet){
}
public void dealAutoMove(){
}
public void changeWeaponState(int moveSpeed){
}
public void drawWeapon(Graphics graphics){
}
public void drawSecond(Graphics graphics, int x, int y) {
}
public void clean(){
}
public byte moveSpeed = 0; //BOSS移动的速度
public boolean isCollide = false; //是否碰撞
public byte bombTimes = 5; //爆炸间隔
public int bulletInterval; //子弹发射间隔
public World world;
public BattlePlaneActor planeActor;
public static int BOSS_STATE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -