[client] bullet skins

This commit is contained in:
2019-08-14 18:00:56 +03:00
parent 636be8611f
commit c0496f2e7c
14 changed files with 32 additions and 24 deletions

View File

@@ -47,6 +47,7 @@ typedef BulletConfig = {
var speed:Float;
var piercing:Int;
var layer:Int;
var skin:String;
}
typedef WeaponConfig = {

View File

@@ -16,7 +16,7 @@ class Weapon {
}
private function get_available():Bool {
return (count < 0 || count > 0) && queue < config.queue;
return (count < 0 || count > 0) && (config.queue < 0 || queue < config.queue);
}
public function use():Void {

View File

@@ -50,7 +50,7 @@ class EventUtil {
}
public static function buildBulletSpawn(bullet:Bullet):GameEvent {
return SPAWN(BULLET(bullet.id, bullet.rect.clone(), bullet.playerId, bullet.config.piercing));
return SPAWN(BULLET(bullet.id, bullet.rect.clone(), bullet.playerId, bullet.config.skin));
}
public static function buildMove(entity:Entity):GameEvent {

View File

@@ -39,7 +39,7 @@ enum SpawnEvent {
BRICK(bricks:Array<BrickInfo>);
EAGLE(id:Int, rect:Rectangle, teamId:TeamId);
TANK(id:Int, rect:Rectangle, playerId:PlayerId, info:TankInfo);
BULLET(id:Int, rect:Rectangle, playerId:PlayerId, piercing:Int);
BULLET(id:Int, rect:Rectangle, playerId:PlayerId, skin:String);
BONUS(id:Int, rect:Rectangle, type:BonusType);
}

View File

@@ -156,7 +156,7 @@ class GameRunner extends Game implements EngineListener {
tank.rect.lean(cell.rect);
emitTankMove(tank);
case [BULLET(bullet), BULLET(other_bullet)]:
if (bullet.playerId != other_bullet.playerId) {
if (bullet.playerId != other_bullet.playerId && bullet.layer > 0 && other_bullet.layer > 0) {
gameEventSignal.emit(DESTROY(BULLET(bullet.id)));
gameEventSignal.emit(DESTROY(BULLET(other_bullet.id)));
}
@@ -166,8 +166,8 @@ class GameRunner extends Game implements EngineListener {
gameEventSignal.emit(DESTROY(BULLET(bullet.id)));
case [TANK(tank), BONUS(bonus)]:
gameEventSignal.emit(DESTROY(BONUS(bonus.id, {tankId: tank.id, score: bonus.config.score})));
case [BULLET(bullet), TANK(tank)]/* | [TANK(tank), BULLET(bullet)]*/:
if (bullet.tankId == tank.id || (!config.game.friendlyFire && tank.playerId.team == bullet.playerId.team)) {
case [BULLET(bullet), TANK(tank)] | [TANK(tank), BULLET(bullet)]:
if (bullet.playerId == tank.playerId || (!config.game.friendlyFire && tank.playerId.team == bullet.playerId.team)) {
// Nothing
} else {
if (!tank.protect) {

View File

@@ -55,6 +55,7 @@ bullet: &bullet
speed: 0
piercing: 1
layer: 2
skin: normal
tanks:
- type: human0
@@ -99,7 +100,7 @@ tanks:
speed: 2.9
skin: pd
weapons:
- bullet: {<<: *bullet, speed: 9.0, piercing: 3}
- bullet: {<<: *bullet, speed: 9.0, piercing: 3, skin: piercing}
queue: 2
count: -1

View File

@@ -78,11 +78,14 @@ tanks:
score: 100
skin: pc
weapons:
- bullet: {width: 12, height: 12, speed: 12.0, piercing: 1, layer: 2}
- bullet: {width: 12, height: 12, speed: 12.0, piercing: 1, layer: 2, skin: normal}
queue: 2
count: -1
- bullet: {width: 16, height: 16, speed: 4.0, piercing: 4, layer: 4}
- bullet: {width: 16, height: 16, speed: 4.0, piercing: 4, layer: 4, skin: rocket}
queue: 1
count: 3
- bullet: {width: 20, height: 20, speed: 0.0, piercing: 1, layer: 0, skin: mine}
queue: -1
count: 3
bonuses: []

View File

@@ -83,6 +83,7 @@ bullet: &bullet
speed: 0
piercing: 1
layer: 2
skin: normal
tanks:
- type: slow