[client] render: fixes

This commit is contained in:
2019-10-03 17:25:52 +03:00
parent 757bc87426
commit 71087286b2
9 changed files with 46 additions and 18 deletions

View File

@@ -7,7 +7,6 @@
* import in game * import in game
* save imported in local storage * save imported in local storage
* database * database
* cache
* improve bots * improve bots
* A star * A star
* game config validate * game config validate
@@ -21,4 +20,3 @@
* fix: * fix:
* ice brick fix * ice brick fix
* shot delay * shot delay
* boat in tank state

View File

@@ -5,5 +5,6 @@
"SSH": { "SSH": {
"PrivateKey": null, "PrivateKey": null,
"Passphrase": null "Passphrase": null
} },
"Develop": false
} }

View File

@@ -34,7 +34,7 @@ const config = new Project.Config({
pack: 'ru.m.tankz', pack: 'ru.m.tankz',
author: 'shmyga <shmyga.z@gmail.com>', author: 'shmyga <shmyga.z@gmail.com>',
company: 'MegaLoMania', company: 'MegaLoMania',
version: packageInfo.version, version: packageInfo.version + (Config.Develop ? '-SNAPSHOT' : ''),
}, },
libs: packageInfo.haxeDependencies, libs: packageInfo.haxeDependencies,
sources: [ sources: [

View File

@@ -1,6 +1,6 @@
{ {
"name": "tankz", "name": "tankz",
"version": "0.17.3", "version": "0.17.4",
"private": true, "private": true,
"devDependencies": { "devDependencies": {
"dateformat": "^3.0.3", "dateformat": "^3.0.3",

View File

@@ -22,4 +22,8 @@ class RenderUtil {
public static function bulletImage(skin:String):BitmapData { public static function bulletImage(skin:String):BitmapData {
return Assets.getBitmapData('resources/image/bullet/${skin}.png'); return Assets.getBitmapData('resources/image/bullet/${skin}.png');
} }
public static function brickImage(type:BrickType, frame:Int = 0):BitmapData {
return Assets.getBitmapData('resources/image/map/${type}${frame > 0 ? ("-" + frame) : ""}.png');
}
} }

View File

@@ -14,14 +14,14 @@ class BrickBitmapBundle {
data = new Map(); data = new Map();
} }
private function resolve(type:BrickType, cells:Array<GridPoint>):BitmapData { private function resolve(type:BrickType, cells:Array<GridPoint>, frame:Int):BitmapData {
return switch cells.length { return switch cells.length {
case 0: case 0:
null; null;
case 4: case 4:
type == "none" ? null : Assets.getBitmapData('resources/image/map/${type}.png'); type == "none" ? null : RenderUtil.brickImage(type, frame);
case _: case _:
var image = Assets.getBitmapData('resources/image/map/${type}.png'); var image = RenderUtil.brickImage(type, frame);
var result = new BitmapData(image.width, image.height, true, 0x00000000); var result = new BitmapData(image.width, image.height, true, 0x00000000);
for (point in cells) { for (point in cells) {
var rect = new flash.geom.Rectangle( var rect = new flash.geom.Rectangle(
@@ -35,10 +35,10 @@ class BrickBitmapBundle {
} }
} }
public function get(type:BrickType, cells:Array<GridPoint>):BitmapData { public function get(type:BrickType, cells:Array<GridPoint>, frame:Int = 0):BitmapData {
var key:String = '${type}_${cells.map(function(point) return point.toString()).join(",")}'; var key:String = '${type}_${cells.map(function(point) return point.toString()).join(",")}_${frame}';
if (!data.exists(key)) { if (!data.exists(key)) {
data.set(key, resolve(type, cells)); data.set(key, resolve(type, cells, frame));
} }
return data.get(key); return data.get(key);
} }
@@ -52,6 +52,10 @@ class BrickRenderItem extends BitmapRenderItem {
private var cells:Array<GridPoint>; private var cells:Array<GridPoint>;
private var frames:Int;
private var currentFrame:Int;
private var ticks:Int;
private static function buildCells():Array<GridPoint> { private static function buildCells():Array<GridPoint> {
return [ return [
new GridPoint(0, 0), new GridPoint(0, 0),
@@ -64,6 +68,9 @@ class BrickRenderItem extends BitmapRenderItem {
public function new(rect:Rectangle, type:BrickType) { public function new(rect:Rectangle, type:BrickType) {
super(rect); super(rect);
cells = buildCells(); cells = buildCells();
this.frames = 1;
this.currentFrame = 0;
this.ticks = 0;
this.type = type; this.type = type;
move(rect.position); move(rect.position);
} }
@@ -71,6 +78,10 @@ class BrickRenderItem extends BitmapRenderItem {
private function set_type(value:BrickType):BrickType { private function set_type(value:BrickType):BrickType {
if (type != value) { if (type != value) {
type = value; type = value;
frames = switch type {
case "water": 2;
case _: 1;
}
cells = buildCells(); cells = buildCells();
redraw(); redraw();
} }
@@ -88,6 +99,20 @@ class BrickRenderItem extends BitmapRenderItem {
} }
public function redraw():Void { public function redraw():Void {
image = bundle.get(type, cells); image = bundle.get(type, cells, currentFrame);
}
override public function update():Void {
super.update();
if (frames > 1) {
if (++ticks >= 30) {
ticks = 0;
currentFrame++;
if (currentFrame >= frames) {
currentFrame = 0;
}
redraw();
}
}
} }
} }

View File

@@ -40,11 +40,11 @@ class TankRenderItem extends BitmapRenderItem {
protectView = AnimateBundle.tankProtect(); protectView = AnimateBundle.tankProtect();
protectView.visible = false; protectView.visible = false;
container.addChild(protectView); container.addChild(protectView);
nameView = buildNameView();
container.addChild(nameView);
boatView = buildBoatView(); boatView = buildBoatView();
boatView.visible = false; boatView.visible = false;
container.addChild(boatView); container.addChild(boatView);
nameView = buildNameView();
container.addChild(nameView);
move(rect.position); move(rect.position);
} }
@@ -60,8 +60,8 @@ class TankRenderItem extends BitmapRenderItem {
private function buildBoatView():Shape { private function buildBoatView():Shape {
var result = new Shape(); var result = new Shape();
result.graphics.lineStyle(4, Color.fromString("green")); result.graphics.lineStyle(4, Color.fromString("green"), 0.8);
result.graphics.drawRoundRect(0, 0, rect.width, rect.height, 10, 10); result.graphics.drawRoundRect(-1, -1, rect.width + 2, rect.height + 2, 10, 10);
return result; return result;
} }
@@ -164,7 +164,7 @@ class TankRenderItem extends BitmapRenderItem {
super.update(); super.update();
if (moves) { if (moves) {
frame++; frame++;
if (frame > images.length - 1) { if (frame >= images.length) {
frame = 0; frame = 0;
} }
bitmap.bitmapData = images[frame]; bitmap.bitmapData = images[frame];

View File

@@ -33,7 +33,6 @@ abstract Version(Array<Int>) {
@:op(A < B) static function lt(a:Version, b:Version):Bool return a.compare(b) < 0; @:op(A < B) static function lt(a:Version, b:Version):Bool return a.compare(b) < 0;
@:from public static function fromString(value:String):Version { @:from public static function fromString(value:String):Version {
trace("!fromString", value);
var r = ~/(\d+)\.(\d+)\.(\d+)(-SNAPSHOT)?/; var r = ~/(\d+)\.(\d+)\.(\d+)(-SNAPSHOT)?/;
return if (r.match(value)) { return if (r.match(value)) {
new Version( new Version(

View File

@@ -52,6 +52,7 @@ class EntityBuilder {
tank.hits = info.hits; tank.hits = info.hits;
tank.name = info.name; tank.name = info.name;
tank.bonus = info.bonus; tank.bonus = info.bonus;
tank.boat = info.boat;
return tank; return tank;
} }