diff --git a/src/client/haxe/ru/m/tankz/render/RenderItem.hx b/src/client/haxe/ru/m/tankz/render/RenderItem.hx index 57c76ae..41f5239 100644 --- a/src/client/haxe/ru/m/tankz/render/RenderItem.hx +++ b/src/client/haxe/ru/m/tankz/render/RenderItem.hx @@ -1,5 +1,7 @@ package ru.m.tankz.render; +import ru.m.tankz.game.Game.TeamId; +import ru.m.tankz.config.Config.TankType; import ru.m.tankz.control.Control; import flash.display.Sprite; import ru.m.animate.Animate; @@ -155,10 +157,8 @@ class TankItem extends RenderItem { tankView.frames = getFrames().map(function(s) return Assets.getBitmapData(s)); } - private function getFrames():Array { - var team = value.playerId.team; - var group = value.config.group; - var index = value.playerId.index; + public static function getTankFrames(team:TeamId, index:Int, type:TankType, hits:Int=0):Array { + var group = type.group; if (team == 'radiant') { index = 0; } @@ -169,14 +169,18 @@ class TankItem extends RenderItem { group = 'player'; } if (team == 'bot') { - index = value.hits; + index = hits; } return [ - 'resources/images/tank/${group}/tank_${group.charAt(0)}${value.config.type}_${index}-0.png', - 'resources/images/tank/${group}/tank_${group.charAt(0)}${value.config.type}_${index}-1.png', + 'resources/images/tank/${group}/tank_${group.charAt(0)}${type.type}_${index}-0.png', + 'resources/images/tank/${group}/tank_${group.charAt(0)}${type.type}_${index}-1.png', ]; } + private function getFrames():Array { + return getTankFrames(value.playerId.team, value.playerId.index, value.config, value.hits); + } + override public function update():Void { super.update(); var t = value.config.type; diff --git a/src/editor/haxe/ru/m/tankz/editor/Editor.hx b/src/editor/haxe/ru/m/tankz/editor/Editor.hx index dedcee1..b33a33a 100644 --- a/src/editor/haxe/ru/m/tankz/editor/Editor.hx +++ b/src/editor/haxe/ru/m/tankz/editor/Editor.hx @@ -107,6 +107,8 @@ class Editor { private function setGameType(type:GameType):Void { config = ConfigBundle.get(type); + Provider.set(Config, config); + view.mapView.config = config; view.mapView.data = LevelBundle.empty(config); diff --git a/src/editor/haxe/ru/m/tankz/editor/MapEditView.hx b/src/editor/haxe/ru/m/tankz/editor/MapEditView.hx index 749f919..424c3a7 100644 --- a/src/editor/haxe/ru/m/tankz/editor/MapEditView.hx +++ b/src/editor/haxe/ru/m/tankz/editor/MapEditView.hx @@ -28,16 +28,27 @@ class SpawnPointItem extends BitmapItem { private var cellX:Int; private var cellY:Int; + private var src:String; - public function new(value:SpawnPoint, config:MapConfig) { + public function new(value:SpawnPoint, config:Config) { + src = getSrc(value, config); super(new SpawnPointEntity(value, new Rectangle( - value.x * config.cellWidth, - value.y * config.cellHeight, - config.cellWidth * 2, - config.cellHeight * 2 + value.x * config.map.cellWidth, + value.y * config.map.cellHeight, + config.map.cellWidth * 2, + config.map.cellHeight * 2 ))); } + public static function getSrc(value:SpawnPoint, config:Config):String { + var tankType = config.getTeam(value.team).tanks[0]; + return switch(value.type) { + case 'eagle': 'resources/images/eagle/eagle-0.png'; + case 'tank': TankItem.getTankFrames(value.team, value.index, tankType)[0]; + case x: 'resources/images/eagle/eagle-1.png'; + } + } + override public function update():Void { super.update(); if (cellX != value.point.x || cellY != value.point.y) { @@ -50,11 +61,7 @@ class SpawnPointItem extends BitmapItem { } override private function getImage():String { - return switch(value.point.type) { - case 'eagle': 'resources/images/eagle/eagle-0.png'; - case 'tank': 'resources/images/tank/bot/tank_b0_0-0.png'; - case x: 'resources/images/eagle/eagle-1.png'; - } + return src; } } @@ -186,7 +193,7 @@ class MapEditView extends SpriteView { for (point in config.points) { var key = '${point.team}:${point.type}:${point.index}'; if (!items.exists(key)) { - items[key] = new SpawnPointItem(point, config.map); + items[key] = new SpawnPointItem(point, config); spawnLayer.addChild(items[key].view); } } diff --git a/src/editor/haxe/ru/m/tankz/editor/SpawnPointView.hx b/src/editor/haxe/ru/m/tankz/editor/SpawnPointView.hx index e4f524c..fea3854 100644 --- a/src/editor/haxe/ru/m/tankz/editor/SpawnPointView.hx +++ b/src/editor/haxe/ru/m/tankz/editor/SpawnPointView.hx @@ -1,5 +1,7 @@ package ru.m.tankz.editor; +import haxework.provider.Provider; +import ru.m.tankz.editor.MapEditView.SpawnPointItem; import flash.display.Bitmap; import flash.display.Shape; import haxework.gui.list.ListView; @@ -38,11 +40,7 @@ class SpawnPointView extends SpriteView implements IListItemView { private function set_data(value:SpawnPoint):SpawnPoint { data = value; - var src = switch(value.type) { - case 'eagle': 'resources/images/eagle/eagle-0.png'; - case 'tank': 'resources/images/tank/bot/tank_b0_0-0.png'; - case x: 'resources/images/eagle/eagle-1.png'; - } + var src = SpawnPointItem.getSrc(value, Provider.get(Config)); imageView.bitmapData = Assets.getBitmapData(src); imageView.x = (width - imageView.width) / 2; imageView.y = (height - imageView.height) / 2;