[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

@@ -149,8 +149,8 @@ class Render extends SpriteView implements IRender {
entryLayer.addChild(item.view);
item.update();
playAnimate(item.rect.center, AnimateBundle.tankSpawn());
case SPAWN(BULLET(id, rect, playerId, piercing)):
var item = new BulletRenderItem(rect, piercing);
case SPAWN(BULLET(id, rect, playerId, skin)):
var item = new BulletRenderItem(rect, skin);
items.set(id, item);
entryLayer.addChild(item.view);
item.update();

View File

@@ -19,8 +19,7 @@ class RenderUtil {
return Assets.getBitmapData('resources/image/bonus/${type}.png');
}
public static function bulletImage(piercing:Int = 0):BitmapData {
var type = piercing > 1 ? 'piercing' : 'normal';
return Assets.getBitmapData('resources/image/bullet/${type}.png');
public static function bulletImage(skin:String):BitmapData {
return Assets.getBitmapData('resources/image/bullet/${skin}.png');
}
}

View File

@@ -3,19 +3,19 @@ package ru.m.tankz.render.item;
import ru.m.geom.Rectangle;
class BulletRenderItem extends BitmapRenderItem {
public var piercing(default, set):Int = -1;
public var skin(default, set):String;
public function new(rect:Rectangle, piercing:Int) {
public function new(rect:Rectangle, skin:String) {
super(rect);
this.piercing = piercing;
this.skin = skin;
move(rect.position);
}
private function set_piercing(value:Int):Int {
if (piercing != value) {
piercing = value;
image = RenderUtil.bulletImage(piercing);
private function set_skin(value:String):String {
if (skin != value) {
skin = value;
image = RenderUtil.bulletImage(skin);
}
return piercing;
return skin;
}
}

View File

@@ -11,7 +11,7 @@ import ru.m.tankz.control.Control;
class SettingsStorage extends SharedObjectStorage {
private static inline var VERSION = 4;
private static inline var VERSION = 4.1;
public function new() {
super('settings_${VERSION}');
@@ -38,6 +38,7 @@ class SettingsStorage extends SharedObjectStorage {
MOVE(Direction.RIGHT) => {device: device, action: DIRECTION(Direction.RIGHT)},
SHOT(0) => {device: device, action: KEY(0)},
SHOT(1) => {device: device, action: KEY(1)},
SHOT(2) => {device: device, action: KEY(2)},
];
}
@@ -64,6 +65,7 @@ class SettingsStorage extends SharedObjectStorage {
MOVE(Direction.RIGHT) => {device: KEYBOARD, action: KEY(Keyboard.D)},
SHOT(0) => {device: KEYBOARD, action: KEY(Keyboard.SPACE)},
SHOT(1) => {device: KEYBOARD, action: KEY(Keyboard.Q)},
SHOT(2) => {device: KEYBOARD, action: KEY(Keyboard.E)},
],
1 => [
MOVE(Direction.TOP) => {device: KEYBOARD, action: KEY(Keyboard.UP)},
@@ -71,7 +73,8 @@ class SettingsStorage extends SharedObjectStorage {
MOVE(Direction.BOTTOM) => {device: KEYBOARD, action: KEY(Keyboard.DOWN)},
MOVE(Direction.RIGHT) => {device: KEYBOARD, action: KEY(Keyboard.RIGHT)},
SHOT(0) => {device: KEYBOARD, action: KEY(Keyboard.NUMPAD_0)},
SHOT(1) => {device: KEYBOARD, action: KEY(Keyboard.NUMPAD_DECIMAL)},
SHOT(1) => {device: KEYBOARD, action: KEY(Keyboard.NUMPAD_1)},
SHOT(3) => {device: KEYBOARD, action: KEY(Keyboard.NUMPAD_2)},
],
];
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

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