diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 0904456..22c7feb 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -5,7 +5,7 @@ project_user: holop deploy_user: "{{ project_user }}" deploy_project: "{{ project_name }}" deploy_repo_url: "git@bitbucket.org:infernalgames/{{ project_name }}.git" -deploy_repo_version: staging +deploy_repo_version: master deploy_npm: yes service_name: "{{ project_name }}" diff --git a/src/client/haxe/ru/m/tankz/render/Render.hx b/src/client/haxe/ru/m/tankz/render/Render.hx index 2ade2d8..e502d1a 100755 --- a/src/client/haxe/ru/m/tankz/render/Render.hx +++ b/src/client/haxe/ru/m/tankz/render/Render.hx @@ -175,6 +175,14 @@ class Render extends SpriteView implements IRender { showScore(rect.center, shot.score); } } + case MOVE(TANK(id, position)) | MOVE(BULLET(id, position)): + if (items.exists(id)) { + var item = items[id]; + item.value.rect.x = position.x; + item.value.rect.y = position.y; + item.value.rect.direction = position.direction; + item.update(); + } case _: } } diff --git a/src/client/haxe/ru/m/tankz/storage/RecordStorage.hx b/src/client/haxe/ru/m/tankz/storage/RecordStorage.hx index d9d8235..31bcc90 100644 --- a/src/client/haxe/ru/m/tankz/storage/RecordStorage.hx +++ b/src/client/haxe/ru/m/tankz/storage/RecordStorage.hx @@ -24,6 +24,7 @@ import ru.m.tankz.game.record.GameRecord; @yield return read(id); } catch (error:Dynamic) { L.w("RecordStorage", 'read ', error); + delete(id); } } } diff --git a/src/client/haxe/ru/m/tankz/view/RecordFrame.hx b/src/client/haxe/ru/m/tankz/view/RecordFrame.hx index 793cdb0..308181c 100644 --- a/src/client/haxe/ru/m/tankz/view/RecordFrame.hx +++ b/src/client/haxe/ru/m/tankz/view/RecordFrame.hx @@ -1,7 +1,7 @@ package ru.m.tankz.view; import haxework.view.frame.FrameSwitcher; -import haxework.view.list.ListView.IListItemView; +import haxework.view.list.ListView; import haxework.view.list.VListView; import haxework.view.VGroupView; import ru.m.tankz.game.record.GameRecord; @@ -18,7 +18,7 @@ import ru.m.tankz.storage.RecordStorage; public function onShow():Void { var data = Lambda.array(recordStorage); - data.sort(function(a:GameRecord, b:GameRecord) return Std.int(a.date.getTime() - b.date.getTime())); + data.sort(function(a:GameRecord, b:GameRecord) return Std.int(b.date.getTime() - a.date.getTime())); this.data.data = data; } diff --git a/src/common/haxe/ru/m/tankz/engine/Engine.hx b/src/common/haxe/ru/m/tankz/engine/Engine.hx index 549e397..e8e91b4 100755 --- a/src/common/haxe/ru/m/tankz/engine/Engine.hx +++ b/src/common/haxe/ru/m/tankz/engine/Engine.hx @@ -114,6 +114,7 @@ import ru.m.tankz.map.LevelMap; var d = entity.rect.center.x - cell.rect.center.x; entity.rect.x += d / Math.abs(d); } + moveSignal.emit(entityType); } break; } diff --git a/src/common/haxe/ru/m/tankz/game/Game.hx b/src/common/haxe/ru/m/tankz/game/Game.hx index 8260c86..1148b25 100644 --- a/src/common/haxe/ru/m/tankz/game/Game.hx +++ b/src/common/haxe/ru/m/tankz/game/Game.hx @@ -1,6 +1,5 @@ package ru.m.tankz.game; -import haxe.Timer; import ru.m.geom.Point; import ru.m.tankz.bundle.IConfigBundle; import ru.m.tankz.config.Config; @@ -28,7 +27,6 @@ import ru.m.tankz.Type; public var state(default, null):GameState; private var builder:EntityBuilder; - private var timer:Timer; @:provide var configBundle:IConfigBundle; @@ -53,10 +51,6 @@ import ru.m.tankz.Type; } } - private function update():Void { - engine.update(); - } - private function applyPosition(entity:Entity, position:Position):Void { entity.rect.center = new Point(position.x, position.y); if (position.direction != null) { @@ -76,15 +70,9 @@ import ru.m.tankz.Type; switch event { case GameEvent.START(state): this.state = state; - timer = new Timer(10); - timer.run = update; case GameEvent.COMPLETE(state, winnerId): this.state = state; this.winner = winnerId; - if (timer != null) { - timer.stop(); - timer = null; - } case GameEvent.SPAWN(EAGLE(id, position, teamId)): var eagle = builder.buildEagle(id, teamId); applyPosition(eagle, position); @@ -133,10 +121,6 @@ import ru.m.tankz.Type; } public function dispose():Void { - if (timer != null) { - timer.stop(); - timer = null; - } gameEventSignal.dispose(); engine.dispose(); } diff --git a/src/common/haxe/ru/m/tankz/game/GameEvent.hx b/src/common/haxe/ru/m/tankz/game/GameEvent.hx index bd21650..3abafe6 100644 --- a/src/common/haxe/ru/m/tankz/game/GameEvent.hx +++ b/src/common/haxe/ru/m/tankz/game/GameEvent.hx @@ -36,6 +36,11 @@ enum DestroyEvent { CELL(cellX:Int, cellY:Int, shot:Shot); } +enum MoveEvent { + TANK(id:Int, position:Position); + BULLET(id:Int, position:Position); +} + enum ChangeEvent { PLAYER_SCORE(playerId:PlayerId, value:Int); PLAYER_LIFE(playerId:PlayerId, value:Int); @@ -46,6 +51,7 @@ enum ChangeEvent { enum GameEvent { START(state:GameState); SPAWN(event:SpawnEvent); + MOVE(event:MoveEvent); HIT(event:HitEvent); DESTROY(event:DestroyEvent); CHANGE(event:ChangeEvent); diff --git a/src/common/haxe/ru/m/tankz/game/GameRunner.hx b/src/common/haxe/ru/m/tankz/game/GameRunner.hx index 4a2ff68..5e21a5d 100644 --- a/src/common/haxe/ru/m/tankz/game/GameRunner.hx +++ b/src/common/haxe/ru/m/tankz/game/GameRunner.hx @@ -5,7 +5,6 @@ import haxe.Timer; import haxework.signal.Signal; import ru.m.geom.Line; import ru.m.geom.Point; -import ru.m.tankz.config.Config; import ru.m.tankz.control.Control; import ru.m.tankz.control.Controller; import ru.m.tankz.control.IControlFactory; @@ -26,6 +25,7 @@ class GameRunner implements EngineListener implements GameListener { private var game(default, null):IGame; private var gameEventSignal(get, null):Signal; private var entityId:Int; + private var timer:Timer; public function new(game:IGame) { this.game = game; @@ -38,7 +38,15 @@ class GameRunner implements EngineListener implements GameListener { return game.gameEventSignal; } + private function update():Void { + game.engine.update(); + } + public function dispose():Void { + if (timer != null) { + timer.stop(); + timer = null; + } game.disconnect(this); game.engine.disconnect(this); } @@ -188,6 +196,13 @@ class GameRunner implements EngineListener implements GameListener { } public function onMove(entity:EntityType):Void { + switch entity { + case TANK(tank): + gameEventSignal.emit(GameEvent.MOVE(TANK(tank.id, {x:tank.rect.x, y:tank.rect.y, direction:tank.rect.direction}))); + case BULLET(bullet): + gameEventSignal.emit(GameEvent.MOVE(BULLET(bullet.id, {x:bullet.rect.x, y:bullet.rect.y, direction:bullet.rect.direction}))); + case _: + } } public function onDestroy(entity:EntityType):Void { @@ -270,9 +285,13 @@ class GameRunner implements EngineListener implements GameListener { public function onGameEvent(event:GameEvent):Void { switch event { case GameEvent.START(_): - + timer = new Timer(10); + timer.run = update; case GameEvent.COMPLETE(_, _): - + if (timer != null) { + timer.stop(); + timer = null; + } case GameEvent.ACTION(tankId, SHOT): var tank:Tank = cast game.engine.entities.get(tankId); var player = game.getPlayer(tank.playerId);