[editor] custom map size fix
This commit is contained in:
@@ -120,7 +120,7 @@ const editor = new Project(
|
|||||||
height: 850,
|
height: 850,
|
||||||
},
|
},
|
||||||
flags: [
|
flags: [
|
||||||
'dev_layout',
|
//'dev_layout',
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
).bind(module, gulp);
|
).bind(module, gulp);
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ class HumanControl extends Control {
|
|||||||
Lib.current.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
|
Lib.current.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
|
||||||
Lib.current.stage.removeEventListener(KeyboardEvent.KEY_UP, onKeyUp);
|
Lib.current.stage.removeEventListener(KeyboardEvent.KEY_UP, onKeyUp);
|
||||||
moveQueue = [];
|
moveQueue = [];
|
||||||
|
if (shotTimer != null) {
|
||||||
|
shotTimer.stop();
|
||||||
|
shotTimer = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function onKeyDown(event:KeyboardEvent):Void {
|
private function onKeyDown(event:KeyboardEvent):Void {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package ru.m.tankz.engine;
|
package ru.m.tankz.engine;
|
||||||
|
|
||||||
typedef Action = {
|
typedef Action = {
|
||||||
|
var id:Int;
|
||||||
var time:Int;
|
var time:Int;
|
||||||
var action:Void->Void;
|
var action:Void->Void;
|
||||||
}
|
}
|
||||||
@@ -12,6 +13,7 @@ class Ticker implements ITicker {
|
|||||||
private var passed:Int;
|
private var passed:Int;
|
||||||
private var last_tick:Int;
|
private var last_tick:Int;
|
||||||
private var actions:Array<Action>;
|
private var actions:Array<Action>;
|
||||||
|
private var actionId = 0;
|
||||||
|
|
||||||
private static var TIME = Timer.stamp();
|
private static var TIME = Timer.stamp();
|
||||||
|
|
||||||
@@ -58,17 +60,23 @@ class Ticker implements ITicker {
|
|||||||
var action = it.next();
|
var action = it.next();
|
||||||
var i = 0;
|
var i = 0;
|
||||||
while (action != null && time >= action.time) {
|
while (action != null && time >= action.time) {
|
||||||
action.action();
|
|
||||||
i++;
|
i++;
|
||||||
action = it.next();
|
action = it.next();
|
||||||
}
|
}
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
|
var timeActions = actions.slice(0, i);
|
||||||
actions = actions.slice(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 {
|
public function emit(fun:Void->Void, delay:Int):Void {
|
||||||
actions.push({action:action, time:time+delay});
|
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);
|
actions.sort(function(a, b) return a.time - b.time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,8 @@ class LevelUtil {
|
|||||||
|
|
||||||
public static function empty(size:GridSize, filler:BrickConfig):LevelConfig {
|
public static function empty(size:GridSize, filler:BrickConfig):LevelConfig {
|
||||||
return {
|
return {
|
||||||
data: [for (i in 0...size.width * size.height) filler]
|
data: [for (i in 0...size.width * size.height) filler],
|
||||||
|
size: size,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name: test
|
data: "002555520000255552000025555200002555520000255552000025555200002255220000225522000022552200000055000000005500000000550000111155111111115511111111551111111155111111115511111111551111555533555555553355555555335555555444455555544445555554444555555533555555553355555555335555111155111111115511111111551111111155111111115511111111551111000055000000005500000000550000002255220000225522000022552200002555520000255552000025555200002555520000255552000025555200"
|
||||||
size: {width: 36, height: 23}
|
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}]
|
||||||
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}]
|
name: Test map size
|
||||||
data: "0000000000000000000000000000000000000000000000000220000000000000000005222210000000000000445512220000000000044005500000000000004411115000000000000440000000000000000044000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
size: {width: 30, height: 15}
|
||||||
|
|||||||
@@ -89,15 +89,16 @@ import ru.m.tankz.util.LevelUtil;
|
|||||||
FileUtil.browse().then(function(content:FileContent) {
|
FileUtil.browse().then(function(content:FileContent) {
|
||||||
fileNameLabel.text = content.name;
|
fileNameLabel.text = content.name;
|
||||||
var data = LevelUtil.loads(config, content.content);
|
var data = LevelUtil.loads(config, content.content);
|
||||||
|
mapView.gridSize = data.size;
|
||||||
mapView.data = data;
|
mapView.data = data;
|
||||||
levelName.text = data.name;
|
levelName.text = data.name;
|
||||||
/*if (data.size != null) {
|
if (data.size != null) {
|
||||||
widthInput.text = Std.string(data.size.width);
|
widthInput.text = Std.string(data.size.width);
|
||||||
heightInput.text = Std.string(data.size.height);
|
heightInput.text = Std.string(data.size.height);
|
||||||
} else {
|
} else {
|
||||||
widthInput.text = "";
|
widthInput.text = "";
|
||||||
heightInput.text = "";
|
heightInput.text = "";
|
||||||
}*/
|
}
|
||||||
});
|
});
|
||||||
case 'saveButton':
|
case 'saveButton':
|
||||||
L.d(TAG, 'SAVE');
|
L.d(TAG, 'SAVE');
|
||||||
|
|||||||
@@ -113,9 +113,8 @@ enum Brush {
|
|||||||
private function set_data(value:LevelConfig):LevelConfig {
|
private function set_data(value:LevelConfig):LevelConfig {
|
||||||
reset();
|
reset();
|
||||||
pointEntities = new Map();
|
pointEntities = new Map();
|
||||||
map = new LevelMap(config.map);
|
map = new LevelMap(config.map, gridSize);
|
||||||
map.setData(value.data);
|
map.setData(value.data);
|
||||||
gridSize = value.size;
|
|
||||||
gameEventSignal.emit(EventUtil.buildBricksSpawn(map));
|
gameEventSignal.emit(EventUtil.buildBricksSpawn(map));
|
||||||
for (point in config.points) {
|
for (point in config.points) {
|
||||||
switch point.type {
|
switch point.type {
|
||||||
|
|||||||
Reference in New Issue
Block a user