[editor] update spwan view
This commit is contained in:
@@ -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<Tank, Sprite> {
|
||||
tankView.frames = getFrames().map(function(s) return Assets.getBitmapData(s));
|
||||
}
|
||||
|
||||
private function getFrames():Array<String> {
|
||||
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<String> {
|
||||
var group = type.group;
|
||||
if (team == 'radiant') {
|
||||
index = 0;
|
||||
}
|
||||
@@ -169,14 +169,18 @@ class TankItem extends RenderItem<Tank, Sprite> {
|
||||
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<String> {
|
||||
return getTankFrames(value.playerId.team, value.playerId.index, value.config, value.hits);
|
||||
}
|
||||
|
||||
override public function update():Void {
|
||||
super.update();
|
||||
var t = value.config.type;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -28,16 +28,27 @@ class SpawnPointItem extends BitmapItem<SpawnPointEntity> {
|
||||
|
||||
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<SpawnPointEntity> {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<SpawnPoint> {
|
||||
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user