[client] added any map item renders

This commit is contained in:
2018-02-13 14:44:04 +03:00
parent f68e5d160f
commit 05b6fe4a56
17 changed files with 77 additions and 39 deletions

View File

@@ -9,7 +9,7 @@ typedef TeamId = String;
typedef ControlType = String;
typedef BrickType = Int;
typedef BrickType = String;
typedef TankType = String;

View File

@@ -27,6 +27,7 @@ typedef MapConfig = {
typedef BrickConfig = {
var type:BrickType;
var index:Int;
var layer:Int;
var armor:Int;
}
@@ -97,7 +98,8 @@ class Config {
public var points(default, null):Array<SpawnPoint>;
public var bonuses(default, null):Array<BonusConfig>;
private var brickMap:Map<Int, BrickConfig>;
private var brickMap:Map<BrickType, BrickConfig>;
private var brickMapByIndex:Map<Int, BrickConfig>;
private var tankMap:Map<TankType, TankConfig>;
private var presetsMap:Map<PresetId, GamePreset>;
private var bonusMap:Map<BonusType, BonusConfig>;
@@ -125,8 +127,10 @@ class Config {
private function init() {
brickMap = new Map();
brickMapByIndex = new Map();
for (item in bricks) {
brickMap.set(item.type, item);
brickMapByIndex.set(item.index, item);
}
presetsMap = new Map();
for (preset in presets) {
@@ -142,10 +146,14 @@ class Config {
}
}
public function getBrick(type:Int):BrickConfig {
public function getBrick(type:BrickType):BrickConfig {
return brickMap.get(type);
}
public function getBrickByIndex(index:Int):BrickConfig {
return brickMapByIndex.get(index);
}
public function getPreset(id:PresetId):GamePreset {
return presetsMap.get(id);
}

View File

@@ -26,7 +26,7 @@ class LevelBundle {
for (line in ~/\s+/g.split(data)) {
for (c in line.split('')) {
if (c.length > 0) {
bricks.push(config.getBrick(Std.parseInt(c)));
bricks.push(config.getBrickByIndex(Std.parseInt(c)));
}
}
}
@@ -41,7 +41,7 @@ class LevelBundle {
} else {
var obj:LevelSource = Yaml.parse(data, Parser.options().useObjects());
return {
data: obj.data.split('').map(function(c) return config.getBrick(Std.parseInt(c))),
data: obj.data.split('').map(function(c) return config.getBrickByIndex(Std.parseInt(c))),
points: obj.points,
}
}

View File

@@ -24,8 +24,8 @@ class Team {
this.spawner = new Spawner(config, points);
}
public function trySpawn(player:PlayerId, spawn:Bool = false):Bool {
var player:Player = players[player.index];
public function trySpawn(playerId:PlayerId, spawn:Bool = false):Bool {
var player:Player = players[playerId.index];
var result = false;
if (player.life > -1) {
if (player.life > 0) {

View File

@@ -9,12 +9,6 @@ import ru.m.tankz.core.IKey;
class Brick implements IKey {
public static var BORDER:BrickConfig = {
type: -1,
layer: 2,
armor: -1,
}
public var cellX(default, null):Int;
public var cellY(default, null):Int;
public var key(get, null):String;