[editor] custom map size fix
This commit is contained in:
@@ -120,7 +120,7 @@ const editor = new Project(
|
||||
height: 850,
|
||||
},
|
||||
flags: [
|
||||
'dev_layout',
|
||||
//'dev_layout',
|
||||
]
|
||||
})
|
||||
).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_UP, onKeyUp);
|
||||
moveQueue = [];
|
||||
if (shotTimer != null) {
|
||||
shotTimer.stop();
|
||||
shotTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function onKeyDown(event:KeyboardEvent):Void {
|
||||
|
||||
@@ -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<Action>;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user