parent
ee1a314d2a
commit
bbd1a0eb5d
@ -0,0 +1,22 @@
|
||||
package com.msb;/**
|
||||
* @Author bingor
|
||||
* @Date 2022/10/8 11:21
|
||||
* @Description: com.msb
|
||||
* @Version: 1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
*@ClassName DefaultFireStrategy
|
||||
*@Description TODO
|
||||
*@Author bingor
|
||||
*@Date 2022/10/8 11:21
|
||||
*@Version 3.0
|
||||
*/
|
||||
public class DefaultFireStrategy implements FireStrategy {
|
||||
@Override
|
||||
public void fire(Tank tank) {
|
||||
int bX = tank.getX() + Tank.WIDTH/2 - Bullet.WIDTH/2;
|
||||
int bY = tank.getY()+Tank.HEIGHT/2-Bullet.HEIGHT/2;
|
||||
new Bullet(bX, bY, tank.getDir(), tank.getGroup(), tank.getTankFrame());
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.msb;
|
||||
|
||||
/**
|
||||
* @Author bingor
|
||||
* @Date 2022/10/8 11:21
|
||||
* @Description: com.msb
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface FireStrategy {
|
||||
public void fire(Tank tank);
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.msb;/**
|
||||
* @Author bingor
|
||||
* @Date 2022/10/8 11:21
|
||||
* @Description: com.msb
|
||||
* @Version: 1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
*@ClassName DefaultFireStrategy
|
||||
*@Description TODO
|
||||
*@Author bingor
|
||||
*@Date 2022/10/8 11:21
|
||||
*@Version 3.0
|
||||
*/
|
||||
public class FourFireStrategy implements FireStrategy {
|
||||
@Override
|
||||
public void fire(Tank tank) {
|
||||
int bX = tank.getX() + Tank.WIDTH/2 - Bullet.WIDTH/2;
|
||||
int bY = tank.getY()+Tank.HEIGHT/2-Bullet.HEIGHT/2;
|
||||
for (DirEnum value : DirEnum.values()) {
|
||||
new Bullet(bX, bY, value, tank.getGroup(), tank.getTankFrame());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue