diff --git a/gulpfile.js b/gulpfile.js index b62604d..f12ab13 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -120,7 +120,7 @@ const editor = new Project( height: 850, }, flags: [ - 'dev_layout', + //'dev_layout', ] }) ).bind(module, gulp); diff --git a/src/client/haxe/ru/m/tankz/control/HumanControl.hx b/src/client/haxe/ru/m/tankz/control/HumanControl.hx index 51cd858..eb743c0 100644 --- a/src/client/haxe/ru/m/tankz/control/HumanControl.hx +++ b/src/client/haxe/ru/m/tankz/control/HumanControl.hx @@ -34,6 +34,10 @@ class HumanControl extends Control { Lib.current.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); Lib.current.stage.removeEventListener(KeyboardEvent.KEY_UP, onKeyUp); moveQueue = []; + if (shotTimer != null) { + shotTimer.stop(); + shotTimer = null; + } } private function onKeyDown(event:KeyboardEvent):Void { diff --git a/src/common/haxe/ru/m/tankz/engine/Ticker.hx b/src/common/haxe/ru/m/tankz/engine/Ticker.hx index 6adcb6e..aaf60f4 100644 --- a/src/common/haxe/ru/m/tankz/engine/Ticker.hx +++ b/src/common/haxe/ru/m/tankz/engine/Ticker.hx @@ -1,6 +1,7 @@ package ru.m.tankz.engine; typedef Action = { + var id:Int; var time:Int; var action:Void->Void; } @@ -12,6 +13,7 @@ class Ticker implements ITicker { private var passed:Int; private var last_tick:Int; private var actions:Array; + private var actionId = 0; private static var TIME = Timer.stamp(); @@ -58,17 +60,23 @@ class Ticker implements ITicker { var action = it.next(); var i = 0; while (action != null && time >= action.time) { - action.action(); i++; action = it.next(); } if (i > 0) { + var timeActions = actions.slice(0, i); actions = actions.slice(i); + for (action in timeActions) { + //L.d("Ticker", 'action: ${action.id} ${action.time} on ${time}'); + action.action(); + } } } - public function emit(action:Void->Void, delay:Int):Void { - actions.push({action:action, time:time+delay}); + public function emit(fun:Void->Void, delay:Int):Void { + var action:Action = {action:fun, time:time+delay, id:++actionId}; + //L.d("Ticker", 'emit: ${action.id} ${action.time}'); + actions.push(action); actions.sort(function(a, b) return a.time - b.time); } } diff --git a/src/common/haxe/ru/m/tankz/util/LevelUtil.hx b/src/common/haxe/ru/m/tankz/util/LevelUtil.hx index 4caeca2..5474891 100644 --- a/src/common/haxe/ru/m/tankz/util/LevelUtil.hx +++ b/src/common/haxe/ru/m/tankz/util/LevelUtil.hx @@ -60,7 +60,8 @@ class LevelUtil { public static function empty(size:GridSize, filler:BrickConfig):LevelConfig { return { - data: [for (i in 0...size.width * size.height) filler] + data: [for (i in 0...size.width * size.height) filler], + size: size, } } } diff --git a/src/common/resources/death/levels/level001.txt b/src/common/resources/death/levels/level001.txt index 27b84c1..0765bda 100644 --- a/src/common/resources/death/levels/level001.txt +++ b/src/common/resources/death/levels/level001.txt @@ -1,4 +1,4 @@ -name: test -size: {width: 36, height: 23} -points: [{direction: right, x: 0, index: 0, team: alpha, y: 0, type: tank}, {direction: right, x: 11, index: 0, team: beta, y: 0, type: tank}, {direction: right, x: 19, index: 0, team: gamma, y: 0, type: tank}, {direction: right, x: 0, index: 0, team: delta, y: 10, type: tank}, {direction: right, x: 15, index: 0, team: epsilon, y: 10, type: tank}, {direction: right, x: 7, index: 0, team: zeta, y: 7, type: tank}, {direction: right, x: 2, index: 0, team: eta, y: 6, type: tank}, {direction: right, x: 5, index: 0, team: theta, y: 2, type: tank}] -data: "0000000000000000000000000000000000000000000000000220000000000000000005222210000000000000445512220000000000044005500000000000004411115000000000000440000000000000000044000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" +data: "002555520000255552000025555200002555520000255552000025555200002255220000225522000022552200000055000000005500000000550000111155111111115511111111551111111155111111115511111111551111555533555555553355555555335555555444455555544445555554444555555533555555553355555555335555111155111111115511111111551111111155111111115511111111551111000055000000005500000000550000002255220000225522000022552200002555520000255552000025555200002555520000255552000025555200" +points: [{direction: right, index: 0, y: 0, team: alpha, x: 0, type: tank}, {direction: right, index: 0, y: 0, team: beta, x: 9, type: tank}, {direction: right, index: 0, y: 0, team: gamma, x: 19, type: tank}, {direction: right, index: 0, y: 0, team: delta, x: 28, type: tank}, {direction: right, index: 0, y: 13, team: epsilon, x: 0, type: tank}, {direction: right, index: 0, y: 13, team: zeta, x: 9, type: tank}, {direction: right, index: 0, y: 13, team: eta, x: 19, type: tank}, {direction: right, index: 0, y: 13, team: theta, x: 28, type: tank}] +name: Test map size +size: {width: 30, height: 15} diff --git a/src/editor/haxe/ru/m/tankz/editor/frame/LevelFrame.hx b/src/editor/haxe/ru/m/tankz/editor/frame/LevelFrame.hx index 0863304..f333e38 100644 --- a/src/editor/haxe/ru/m/tankz/editor/frame/LevelFrame.hx +++ b/src/editor/haxe/ru/m/tankz/editor/frame/LevelFrame.hx @@ -89,15 +89,16 @@ import ru.m.tankz.util.LevelUtil; FileUtil.browse().then(function(content:FileContent) { fileNameLabel.text = content.name; var data = LevelUtil.loads(config, content.content); + mapView.gridSize = data.size; mapView.data = data; levelName.text = data.name; - /*if (data.size != null) { + if (data.size != null) { widthInput.text = Std.string(data.size.width); heightInput.text = Std.string(data.size.height); } else { widthInput.text = ""; heightInput.text = ""; - }*/ + } }); case 'saveButton': L.d(TAG, 'SAVE'); diff --git a/src/editor/haxe/ru/m/tankz/editor/level/MapEditView.hx b/src/editor/haxe/ru/m/tankz/editor/level/MapEditView.hx index fa1e7d7..5596484 100644 --- a/src/editor/haxe/ru/m/tankz/editor/level/MapEditView.hx +++ b/src/editor/haxe/ru/m/tankz/editor/level/MapEditView.hx @@ -113,9 +113,8 @@ enum Brush { private function set_data(value:LevelConfig):LevelConfig { reset(); pointEntities = new Map(); - map = new LevelMap(config.map); + map = new LevelMap(config.map, gridSize); map.setData(value.data); - gridSize = value.size; gameEventSignal.emit(EventUtil.buildBricksSpawn(map)); for (point in config.points) { switch point.type {