diff --git a/WORK.md b/WORK.md index eaba624..baa9473 100644 --- a/WORK.md +++ b/WORK.md @@ -1,46 +1,62 @@ * build * gulp 100% + * linux 100% + * deb-package 100% + * windows 0% + * exe-package 0% (inno setup) * deploy * capistrano 100% * ui - * login frame - * select person frame (autoselect) - * game mode frame (single, start server, find server) - * game frame + * auth frame 0% + * select game frame 30% (classic 1/2 player, dota singe/coop/vs) + * select level frame 10% + * game frame 50% * engine - * config 90% - * map 80% - * tanks 30% - * bullets 30% - * boxes 0% - * map changes 50% + * config 100% + * map 100% + * tanks 100% + * bullets 100% + * boxes 100% + * map changes 100% * bonuses 0% - * eagle 0% + * eagle 100% * game * classic - * state 0% - * bot 5% + * state 50% + * bot 50% * player: 50% + * dota + * state 50% + * bot 10% + * player 0% + +* state + * score 0% + * save/load 0% + * export/import 0% * render * map 100% * tanks 100% * bullet 100% - * calc redraw 20% + * calc redraw 50% * animations - * tank spawn - * bullet boom - * tank boom - * bonuses - * html5 + * tank spawn 0% + * tank move 100% + * map water 0% + * bullet boom 90% + * tank boom 90% + * bonuses 0% + * html5 50% * proto - + ... -* webapp - * angular app 0% - * google analytics 0% \ No newline at end of file +* editor + * open 0% + * edit 0% + * save 0% \ No newline at end of file diff --git a/src/client/haxe/ru/m/tankz/render/Render.hx b/src/client/haxe/ru/m/tankz/render/Render.hx index afb0726..37625ce 100755 --- a/src/client/haxe/ru/m/tankz/render/Render.hx +++ b/src/client/haxe/ru/m/tankz/render/Render.hx @@ -101,6 +101,7 @@ class Render extends SpriteView implements EngineListener { items.set(tank.key, item); entryLayer.addChild(item.view); item.update(); + playTankSpawn(tank.rect.center); case EntityType.BULLET(bullet): var item = new BulletItem(bullet); items.set(bullet.key, item); @@ -143,6 +144,21 @@ class Render extends SpriteView implements EngineListener { } } + private function playTankSpawn(point:Point):Void { + var arr = [ + 0, 1, 2, 3, 3, 4, 5, 5, 6 + ]; + var frames = [for (i in arr) Assets.getBitmapData('resources/images/tank/appear/appear-${i}.png')]; + var animate = new OnceAnimate(frames); + animate.x = point.x - animate.width / 2; + animate.y = point.y - animate.height / 2; + upperLayer.addChild(animate); + animate.play().then(function(animate) { + upperLayer.removeChild(animate); + animate.dispose(); + }); + } + private function playBulletBoom(point:Point):Void { var arr = [ 0, 1, 1, 0, 0, 1 diff --git a/src/common/haxe/ru/m/tankz/bot/BotControl.hx b/src/common/haxe/ru/m/tankz/bot/BotControl.hx index 1f592ab..b57d05b 100644 --- a/src/common/haxe/ru/m/tankz/bot/BotControl.hx +++ b/src/common/haxe/ru/m/tankz/bot/BotControl.hx @@ -10,8 +10,8 @@ class BotControl extends Control { public static var TYPE(default, never):ControlType = 'bot'; private var shotTimer:Timer; + private var turnRandomTimer:Timer; private var turnTimer:Timer; - private var turnDelayTimer:Timer; public function new(index:Int) { super({type:TYPE, index:index}); @@ -33,9 +33,9 @@ class BotControl extends Control { shotTimer = new Timer(1000); shotTimer.run = shot; } - if (turnTimer == null) { - turnTimer = new Timer(2000); - turnTimer.run = turn; + if (turnRandomTimer == null) { + turnRandomTimer = new Timer(2000); + turnRandomTimer.run = turn; } } @@ -44,9 +44,9 @@ class BotControl extends Control { shotTimer.stop(); shotTimer = null; } - if (turnTimer != null) { - turnTimer.stop(); - turnTimer = null; + if (turnRandomTimer != null) { + turnRandomTimer.stop(); + turnRandomTimer = null; } } @@ -55,17 +55,16 @@ class BotControl extends Control { } public function turnAfter(delay:Int):Void { - if (turnDelayTimer == null) { - turnDelayTimer = new Timer(delay); - turnDelayTimer.run = function() { - turnDelayTimer.stop(); - turnDelayTimer = null; - turn(); - } + if (turnTimer == null) { + turnTimer = Timer.delay(turn, delay); } } public function turn():Void { + if (turnTimer != null) { + turnTimer.stop(); + turnTimer = null; + } action(TankAction.MOVE(randomDirection())); } diff --git a/src/common/haxe/ru/m/tankz/game/Game.hx b/src/common/haxe/ru/m/tankz/game/Game.hx index bbe7229..680149e 100644 --- a/src/common/haxe/ru/m/tankz/game/Game.hx +++ b/src/common/haxe/ru/m/tankz/game/Game.hx @@ -119,8 +119,8 @@ class Game implements EngineListener { if (trySpawn(task.playerId, true)) { var tank = buildTank(task.playerId, task.point); var player:Player = getPlayer(task.playerId); - engine.spawn(tank); player.tankId = tank.id; + Timer.delay(function() engine.spawn(tank), 500); } else if (!isTeamAlive(task.playerId.team)) { state.teams[task.playerId.team].lose = true; complete(); @@ -135,12 +135,10 @@ class Game implements EngineListener { player.control.dispose(); } } - var timer = new Timer(5000); - timer.run = function() { - timer.stop(); + Timer.delay(function() { deferred.resolve(state); stream.end(); - } + }, 5000); } public function setControl(playerId:PlayerId, control:Control):Void { @@ -159,7 +157,11 @@ class Game implements EngineListener { public function onSpawn(entity:EntityType):Void { - + switch (entity) { + case EntityType.TANK(tank): + getPlayer(tank.playerId).control.start(); + case x: + } } public function onCollision(entity:EntityType, with:EntityType):Void { @@ -210,7 +212,8 @@ class Game implements EngineListener { public function onDestroy(entity:EntityType):Void { switch (entity) { case EntityType.TANK(tank): - getPlayer(tank.playerId).tankId = 0; + getPlayer(tank.playerId).control.stop(); + getPlayer(tank.playerId).tankId = 0; //ToDo: ? var respawn:Bool = trySpawn(tank.playerId); if (respawn) { spawners.get(tank.playerId.team).push(tank.playerId); diff --git a/src/common/haxe/ru/m/tankz/game/Player.hx b/src/common/haxe/ru/m/tankz/game/Player.hx index af78f4e..3f4cd41 100644 --- a/src/common/haxe/ru/m/tankz/game/Player.hx +++ b/src/common/haxe/ru/m/tankz/game/Player.hx @@ -19,11 +19,6 @@ class Player { tankId = value; if (control != null) { control.tankId = tankId; - if (tankId != 0) { - control.start(); - } else { - control.stop(); - } } return tankId; } @@ -33,9 +28,6 @@ class Player { control = value; if (control != null) { control.tankId = tankId; - if (tankId != 0) { - control.start(); - } } return control; }