[editor] tanks colors
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "tankz",
|
||||
"version": "0.8.6",
|
||||
"version": "0.8.7",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"dateformat": "^3.0.3",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package ru.m.tankz.render;
|
||||
|
||||
import haxework.view.utils.BitmapUtil;
|
||||
import flash.display.Bitmap;
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.Shape;
|
||||
@@ -253,6 +254,14 @@ class EagleItem extends BitmapItem<Eagle> {
|
||||
var suffix = value.death ? '-death' : value.protect.active ? '-protected' : '';
|
||||
return 'resources/image/eagle/eagle${suffix}.png';
|
||||
}
|
||||
|
||||
override public function redraw():Void {
|
||||
var image = Assets.getBitmapData(getImage());
|
||||
if (!value.color.zero) {
|
||||
image = BitmapUtil.colorize(image, value.color);
|
||||
}
|
||||
view.bitmapData = image;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package ru.m.tankz.view;
|
||||
|
||||
import haxework.view.frame.FrameSwitcher;
|
||||
import haxework.view.ButtonView;
|
||||
import haxework.view.VGroupView;
|
||||
|
||||
@:template class SettingsFrame extends VGroupView {
|
||||
@@ -10,9 +9,7 @@ import haxework.view.VGroupView;
|
||||
|
||||
@:provide var frameSwitcher:FrameSwitcher;
|
||||
|
||||
@:view var close:ButtonView;
|
||||
|
||||
public function onPress(_):Void {
|
||||
public function close():Void {
|
||||
frameSwitcher.change(StartFrame.ID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,4 +19,4 @@ views:
|
||||
- id: close
|
||||
$type: haxework.view.ButtonView
|
||||
skinId: button.close
|
||||
+onPress: $this:onPress
|
||||
+onPress: $code:close()
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package ru.m.tankz.core;
|
||||
|
||||
import ru.m.tankz.config.Config.EagleConfig;
|
||||
import haxework.color.Color;
|
||||
import ru.m.geom.Rectangle;
|
||||
import ru.m.tankz.config.Config;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
class Eagle extends Entity {
|
||||
|
||||
public var team(default, null):TeamId;
|
||||
public var config(default, null):EagleConfig;
|
||||
public var color(default, default):Color;
|
||||
public var death(default, default):Bool;
|
||||
public var protect(default, null):Modificator;
|
||||
|
||||
|
||||
@@ -139,6 +139,7 @@ class Game {
|
||||
var eaglePoint = team.spawner.getPoint('eagle');
|
||||
if (eaglePoint != null) {
|
||||
var eagle = new Eagle(team.id, team.config.eagle);
|
||||
eagle.color = config.getColor(new PlayerId(eagle.team, -1));
|
||||
team.eagleId = eagle.id;
|
||||
applyPoint(eagle, eaglePoint);
|
||||
engine.spawn(eagle);
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
points: [{y: 0, team: alpha, x: 0, direction: right, type: tank, index: 0}, {y: 0, team: beta, x: 6, direction: right, type: tank, index: 0}, {y: 0, team: gamma, x: 12, direction: right, type: tank, index: 0}, {y: 0, team: delta, x: 18, direction: right, type: tank, index: 0}, {y: 18, team: epsilon, x: 0, direction: right, type: tank, index: 0}, {y: 18, team: zeta, x: 6, direction: right, type: tank, index: 0}, {y: 18, team: eta, x: 12, direction: right, type: tank, index: 0}, {y: 18, team: theta, x: 18, direction: right, type: tank, index: 0}]
|
||||
data: "0004400004400004400000044000044000044000555555555555555555550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000555555555555555555550004400004400004400000044000044000044000"
|
||||
points: [{y: 0, type: tank, direction: right, x: 0, team: alpha, index: 0}, {y: 0, type: tank, direction: right, x: 6, team: beta, index: 0}, {y: 0, type: tank, direction: right, x: 12, team: gamma, index: 0}, {y: 0, type: tank, direction: right, x: 18, team: delta, index: 0}, {y: 18, type: tank, direction: right, x: 0, team: epsilon, index: 0}, {y: 18, type: tank, direction: right, x: 6, team: zeta, index: 0}, {y: 18, type: tank, direction: right, x: 12, team: eta, index: 0}, {y: 18, type: tank, direction: right, x: 18, team: theta, index: 0}]
|
||||
data: "0004400004400004400000044000044000044000555555555555555555550000000000000000000002520000022000002520055503330550333055500252035502205530252000000352000025300000000000000110000000000525252011110252525005252520111102525250000000000110000000000000035200002530000002520355022055302520055503330550333055500252000002200000252000000000000000000000555555555555555555550004400004400004400000044000044000044000"
|
||||
|
||||
@@ -61,12 +61,12 @@ class Editor {
|
||||
|
||||
Style.register();
|
||||
|
||||
view = new EditorView();
|
||||
Root.bind(view);
|
||||
|
||||
Provider.setFactory(IConfigBundle, ConfigBundle);
|
||||
Provider.setFactory(ILevelBundle, LevelBundle);
|
||||
|
||||
view = new EditorView();
|
||||
Root.bind(view);
|
||||
|
||||
view.switcher.change(LevelFrame.ID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,12 +53,16 @@ import ru.m.tankz.util.LevelUtil;
|
||||
resetSelected();
|
||||
item.selected = true;
|
||||
});
|
||||
}
|
||||
|
||||
public function onShow():Void {
|
||||
setGameType(ClassicGame.TYPE);
|
||||
}
|
||||
|
||||
/*public function onShow():Void {
|
||||
if (config == null) {
|
||||
setGameType(ClassicGame.TYPE);
|
||||
}
|
||||
}*/
|
||||
|
||||
private function setGameType(type:GameType):Void {
|
||||
config = configBundle.get(type);
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ layout.vAlign: top
|
||||
layout.hAlign: center
|
||||
views:
|
||||
- $type: haxework.view.HGroupView
|
||||
layout.margin: 5
|
||||
views:
|
||||
- $type: haxework.view.ButtonView
|
||||
skinId: button.simple
|
||||
@@ -43,6 +44,7 @@ views:
|
||||
margin: 5
|
||||
factory: $code:ru.m.tankz.editor.level.BrickView.factory
|
||||
- $type: haxework.view.HGroupView
|
||||
layout.margin: 5
|
||||
views:
|
||||
- id: openButton
|
||||
$type: haxework.view.ButtonView
|
||||
|
||||
@@ -13,7 +13,7 @@ import haxework.view.VGroupView;
|
||||
@:view("color") var colorLabel(default, null):InputView;
|
||||
private var color(default, set):Color;
|
||||
|
||||
public function onShow():Void {
|
||||
public function init():Void {
|
||||
color = 0x00ff00;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package ru.m.tankz.editor.level;
|
||||
|
||||
import haxework.color.Color;
|
||||
import flash.display.Shape;
|
||||
import haxework.view.ImageView;
|
||||
import openfl.utils.Assets;
|
||||
@@ -33,10 +34,15 @@ class BrushView<D> extends ImageView {
|
||||
return null;
|
||||
}
|
||||
|
||||
private function resolveColor(value:D):Color {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function set_data(value:D):D {
|
||||
data = value;
|
||||
var src = resolveSrc(value);
|
||||
image = Assets.getBitmapData(src);
|
||||
color = resolveColor(value);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package ru.m.tankz.editor.level;
|
||||
|
||||
import openfl.Assets;
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.Graphics;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.MouseEvent;
|
||||
import haxework.color.Color;
|
||||
import haxework.view.SpriteView;
|
||||
import haxework.view.utils.BitmapUtil;
|
||||
import openfl.Assets;
|
||||
import ru.m.geom.Point;
|
||||
import ru.m.geom.Rectangle;
|
||||
import ru.m.tankz.config.Config;
|
||||
@@ -13,6 +15,7 @@ import ru.m.tankz.core.Entity;
|
||||
import ru.m.tankz.map.Brick;
|
||||
import ru.m.tankz.map.LevelMap;
|
||||
import ru.m.tankz.render.RenderItem;
|
||||
import ru.m.tankz.Type.PlayerId;
|
||||
|
||||
class SpawnPointEntity extends Entity {
|
||||
|
||||
@@ -29,6 +32,7 @@ class SpawnPointItem extends BitmapItem<SpawnPointEntity> {
|
||||
private var cellX:Int = -1;
|
||||
private var cellY:Int = -1;
|
||||
private var src:String;
|
||||
private var color:Color;
|
||||
|
||||
public function new(value:SpawnPoint, config:Config) {
|
||||
src = getSrc(value, config);
|
||||
@@ -38,19 +42,14 @@ class SpawnPointItem extends BitmapItem<SpawnPointEntity> {
|
||||
config.map.cellWidth * 2,
|
||||
config.map.cellHeight * 2
|
||||
)));
|
||||
color = config.getColor(new PlayerId(value.team, value.index));
|
||||
}
|
||||
|
||||
public static function getSrc(value:SpawnPoint, config:Config):String {
|
||||
var preset:GamePreset = config.presets[config.presets.length - 1];
|
||||
var tankConfig:TankConfig = null;
|
||||
if (value.type == 'tank') {
|
||||
var team:TeamConfig = Lambda.find(preset.teams, function(t) return t.id == value.team);
|
||||
var player:PlayerConfig = null;
|
||||
if (value.index > 0) {
|
||||
player = Lambda.find(team.players, function(p) return p.index == value.index);
|
||||
} else {
|
||||
player = team.players[0];
|
||||
}
|
||||
var player = config.getPlayer(new PlayerId(value.team, value.index < 0 ? 0 : value.index));
|
||||
var tankType = player.tanks[0];
|
||||
tankConfig = config.getTank(tankType.type);
|
||||
}
|
||||
@@ -63,8 +62,8 @@ class SpawnPointItem extends BitmapItem<SpawnPointEntity> {
|
||||
|
||||
override public function update():Void {
|
||||
super.update();
|
||||
var image = Assets.getBitmapData(getImage());
|
||||
if (cellX != value.point.x || cellY != value.point.y) {
|
||||
var image = Assets.getBitmapData(getImage());
|
||||
cellX = value.point.x;
|
||||
cellY = value.point.y;
|
||||
value.rect.x = cellX * (value.rect.width / 2) + (value.rect.width - image.width) / 2;
|
||||
@@ -73,6 +72,14 @@ class SpawnPointItem extends BitmapItem<SpawnPointEntity> {
|
||||
}
|
||||
}
|
||||
|
||||
override public function redraw():Void {
|
||||
var image = Assets.getBitmapData(getImage());
|
||||
if (!color.zero) {
|
||||
image = BitmapUtil.colorize(image, color);
|
||||
}
|
||||
view.bitmapData = image;
|
||||
}
|
||||
|
||||
override private function getImage():String {
|
||||
return src;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
package ru.m.tankz.editor.level;
|
||||
|
||||
import haxework.color.Color;
|
||||
import haxework.provider.Provider;
|
||||
import ru.m.tankz.config.Config;
|
||||
import ru.m.tankz.editor.level.MapEditView;
|
||||
import ru.m.tankz.Type.PlayerId;
|
||||
|
||||
class SpawnPointView extends BrushView<SpawnPoint> {
|
||||
|
||||
@:provide var config:Config;
|
||||
|
||||
override private function resolveColor(value:SpawnPoint):Color {
|
||||
return config.getColor(new PlayerId(value.team, value.index));
|
||||
}
|
||||
|
||||
override private function resolveSrc(value:SpawnPoint):String {
|
||||
return SpawnPointItem.getSrc(value, Provider.get(Config));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user