[client] bullet skins
This commit is contained in:
@@ -149,8 +149,8 @@ class Render extends SpriteView implements IRender {
|
|||||||
entryLayer.addChild(item.view);
|
entryLayer.addChild(item.view);
|
||||||
item.update();
|
item.update();
|
||||||
playAnimate(item.rect.center, AnimateBundle.tankSpawn());
|
playAnimate(item.rect.center, AnimateBundle.tankSpawn());
|
||||||
case SPAWN(BULLET(id, rect, playerId, piercing)):
|
case SPAWN(BULLET(id, rect, playerId, skin)):
|
||||||
var item = new BulletRenderItem(rect, piercing);
|
var item = new BulletRenderItem(rect, skin);
|
||||||
items.set(id, item);
|
items.set(id, item);
|
||||||
entryLayer.addChild(item.view);
|
entryLayer.addChild(item.view);
|
||||||
item.update();
|
item.update();
|
||||||
|
|||||||
@@ -19,8 +19,7 @@ class RenderUtil {
|
|||||||
return Assets.getBitmapData('resources/image/bonus/${type}.png');
|
return Assets.getBitmapData('resources/image/bonus/${type}.png');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function bulletImage(piercing:Int = 0):BitmapData {
|
public static function bulletImage(skin:String):BitmapData {
|
||||||
var type = piercing > 1 ? 'piercing' : 'normal';
|
return Assets.getBitmapData('resources/image/bullet/${skin}.png');
|
||||||
return Assets.getBitmapData('resources/image/bullet/${type}.png');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,19 +3,19 @@ package ru.m.tankz.render.item;
|
|||||||
import ru.m.geom.Rectangle;
|
import ru.m.geom.Rectangle;
|
||||||
|
|
||||||
class BulletRenderItem extends BitmapRenderItem {
|
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);
|
super(rect);
|
||||||
this.piercing = piercing;
|
this.skin = skin;
|
||||||
move(rect.position);
|
move(rect.position);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function set_piercing(value:Int):Int {
|
private function set_skin(value:String):String {
|
||||||
if (piercing != value) {
|
if (skin != value) {
|
||||||
piercing = value;
|
skin = value;
|
||||||
image = RenderUtil.bulletImage(piercing);
|
image = RenderUtil.bulletImage(skin);
|
||||||
}
|
}
|
||||||
return piercing;
|
return skin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import ru.m.tankz.control.Control;
|
|||||||
|
|
||||||
class SettingsStorage extends SharedObjectStorage {
|
class SettingsStorage extends SharedObjectStorage {
|
||||||
|
|
||||||
private static inline var VERSION = 4;
|
private static inline var VERSION = 4.1;
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
super('settings_${VERSION}');
|
super('settings_${VERSION}');
|
||||||
@@ -38,6 +38,7 @@ class SettingsStorage extends SharedObjectStorage {
|
|||||||
MOVE(Direction.RIGHT) => {device: device, action: DIRECTION(Direction.RIGHT)},
|
MOVE(Direction.RIGHT) => {device: device, action: DIRECTION(Direction.RIGHT)},
|
||||||
SHOT(0) => {device: device, action: KEY(0)},
|
SHOT(0) => {device: device, action: KEY(0)},
|
||||||
SHOT(1) => {device: device, action: KEY(1)},
|
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)},
|
MOVE(Direction.RIGHT) => {device: KEYBOARD, action: KEY(Keyboard.D)},
|
||||||
SHOT(0) => {device: KEYBOARD, action: KEY(Keyboard.SPACE)},
|
SHOT(0) => {device: KEYBOARD, action: KEY(Keyboard.SPACE)},
|
||||||
SHOT(1) => {device: KEYBOARD, action: KEY(Keyboard.Q)},
|
SHOT(1) => {device: KEYBOARD, action: KEY(Keyboard.Q)},
|
||||||
|
SHOT(2) => {device: KEYBOARD, action: KEY(Keyboard.E)},
|
||||||
],
|
],
|
||||||
1 => [
|
1 => [
|
||||||
MOVE(Direction.TOP) => {device: KEYBOARD, action: KEY(Keyboard.UP)},
|
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.BOTTOM) => {device: KEYBOARD, action: KEY(Keyboard.DOWN)},
|
||||||
MOVE(Direction.RIGHT) => {device: KEYBOARD, action: KEY(Keyboard.RIGHT)},
|
MOVE(Direction.RIGHT) => {device: KEYBOARD, action: KEY(Keyboard.RIGHT)},
|
||||||
SHOT(0) => {device: KEYBOARD, action: KEY(Keyboard.NUMPAD_0)},
|
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)},
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
src/client/resources/image/bullet/mine.png
Normal file
BIN
src/client/resources/image/bullet/mine.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
BIN
src/client/resources/image/bullet/rocket.png
Normal file
BIN
src/client/resources/image/bullet/rocket.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
@@ -47,6 +47,7 @@ typedef BulletConfig = {
|
|||||||
var speed:Float;
|
var speed:Float;
|
||||||
var piercing:Int;
|
var piercing:Int;
|
||||||
var layer:Int;
|
var layer:Int;
|
||||||
|
var skin:String;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef WeaponConfig = {
|
typedef WeaponConfig = {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class Weapon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function get_available():Bool {
|
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 {
|
public function use():Void {
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class EventUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function buildBulletSpawn(bullet:Bullet):GameEvent {
|
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 {
|
public static function buildMove(entity:Entity):GameEvent {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ enum SpawnEvent {
|
|||||||
BRICK(bricks:Array<BrickInfo>);
|
BRICK(bricks:Array<BrickInfo>);
|
||||||
EAGLE(id:Int, rect:Rectangle, teamId:TeamId);
|
EAGLE(id:Int, rect:Rectangle, teamId:TeamId);
|
||||||
TANK(id:Int, rect:Rectangle, playerId:PlayerId, info:TankInfo);
|
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);
|
BONUS(id:Int, rect:Rectangle, type:BonusType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ class GameRunner extends Game implements EngineListener {
|
|||||||
tank.rect.lean(cell.rect);
|
tank.rect.lean(cell.rect);
|
||||||
emitTankMove(tank);
|
emitTankMove(tank);
|
||||||
case [BULLET(bullet), BULLET(other_bullet)]:
|
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(bullet.id)));
|
||||||
gameEventSignal.emit(DESTROY(BULLET(other_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)));
|
gameEventSignal.emit(DESTROY(BULLET(bullet.id)));
|
||||||
case [TANK(tank), BONUS(bonus)]:
|
case [TANK(tank), BONUS(bonus)]:
|
||||||
gameEventSignal.emit(DESTROY(BONUS(bonus.id, {tankId: tank.id, score: bonus.config.score})));
|
gameEventSignal.emit(DESTROY(BONUS(bonus.id, {tankId: tank.id, score: bonus.config.score})));
|
||||||
case [BULLET(bullet), TANK(tank)]/* | [TANK(tank), BULLET(bullet)]*/:
|
case [BULLET(bullet), TANK(tank)] | [TANK(tank), BULLET(bullet)]:
|
||||||
if (bullet.tankId == tank.id || (!config.game.friendlyFire && tank.playerId.team == bullet.playerId.team)) {
|
if (bullet.playerId == tank.playerId || (!config.game.friendlyFire && tank.playerId.team == bullet.playerId.team)) {
|
||||||
// Nothing
|
// Nothing
|
||||||
} else {
|
} else {
|
||||||
if (!tank.protect) {
|
if (!tank.protect) {
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ bullet: &bullet
|
|||||||
speed: 0
|
speed: 0
|
||||||
piercing: 1
|
piercing: 1
|
||||||
layer: 2
|
layer: 2
|
||||||
|
skin: normal
|
||||||
|
|
||||||
tanks:
|
tanks:
|
||||||
- type: human0
|
- type: human0
|
||||||
@@ -99,7 +100,7 @@ tanks:
|
|||||||
speed: 2.9
|
speed: 2.9
|
||||||
skin: pd
|
skin: pd
|
||||||
weapons:
|
weapons:
|
||||||
- bullet: {<<: *bullet, speed: 9.0, piercing: 3}
|
- bullet: {<<: *bullet, speed: 9.0, piercing: 3, skin: piercing}
|
||||||
queue: 2
|
queue: 2
|
||||||
count: -1
|
count: -1
|
||||||
|
|
||||||
|
|||||||
@@ -78,11 +78,14 @@ tanks:
|
|||||||
score: 100
|
score: 100
|
||||||
skin: pc
|
skin: pc
|
||||||
weapons:
|
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
|
queue: 2
|
||||||
count: -1
|
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
|
queue: 1
|
||||||
count: 3
|
count: 3
|
||||||
|
- bullet: {width: 20, height: 20, speed: 0.0, piercing: 1, layer: 0, skin: mine}
|
||||||
|
queue: -1
|
||||||
|
count: 3
|
||||||
|
|
||||||
bonuses: []
|
bonuses: []
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ bullet: &bullet
|
|||||||
speed: 0
|
speed: 0
|
||||||
piercing: 1
|
piercing: 1
|
||||||
layer: 2
|
layer: 2
|
||||||
|
skin: normal
|
||||||
|
|
||||||
tanks:
|
tanks:
|
||||||
- type: slow
|
- type: slow
|
||||||
|
|||||||
Reference in New Issue
Block a user