diff --git a/package.json b/package.json index 23a797d..8ed5999 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tankz", - "version": "0.6.0", + "version": "0.6.1", "private": true, "devDependencies": { "ansi-colors": "^1.0.1", diff --git a/src/client/haxe/ru/m/tankz/render/RenderItem.hx b/src/client/haxe/ru/m/tankz/render/RenderItem.hx index 70c577a..460e931 100644 --- a/src/client/haxe/ru/m/tankz/render/RenderItem.hx +++ b/src/client/haxe/ru/m/tankz/render/RenderItem.hx @@ -79,12 +79,25 @@ class BitmapItem extends RenderItem { class BrickItem extends BitmapItem { + private var type:BrickType; public function new(value:Brick) { super(value); redraw(); } + override public function update():Void { + super.update(); + var t = value.config.type; + if (t != type) { + type = t; + view.visible = t != 'none'; + redraw(); + } + } + + + override private function getImage():String { return 'resources/image/map/${value.config.type}.png'; } @@ -108,7 +121,6 @@ class BrickAnimateItem extends AnimateItem { class BrickBreakingItem extends RenderItem { - private var broken:Int; private var type:BrickType; diff --git a/src/client/resources/classic/config.yaml b/src/client/resources/classic/config.yaml index 6e2051b..bbc6ca8 100644 --- a/src/client/resources/classic/config.yaml +++ b/src/client/resources/classic/config.yaml @@ -38,7 +38,7 @@ presets: - id: human life: -1 players: - - {<<: *human, index: 0, color: 0xFC9838, life: 3} + - {<<: *human, index: 0, color: 0xF5C040, life: 3} - id: bot spawnInterval: 3000 life: 20 @@ -53,8 +53,8 @@ presets: - id: human life: -1 players: - - {<<: *human, index: 0, color: 0xFC9838, life: 3} - - {<<: *human, index: 1, color: 0x159D49, life: 3} + - {<<: *human, index: 0, color: 0xF5C040, life: 3} + - {<<: *human, index: 1, color: 0x15C040, life: 3} - id: bot spawnInterval: 3000 life: 20 diff --git a/src/client/resources/dota/config.yaml b/src/client/resources/dota/config.yaml index 5193237..13b41a4 100644 --- a/src/client/resources/dota/config.yaml +++ b/src/client/resources/dota/config.yaml @@ -1,5 +1,5 @@ game: - levels: 7 + levels: 8 friendlyFire: true map: @@ -20,11 +20,11 @@ bricks: team: radiant: &radiant id: radiant - color: 0xff5555 + color: 0xff4422 life: 20 dire: &dire id: dire - color: 0x5555ff + color: 0x2244ff life: 20 player: &player @@ -39,7 +39,7 @@ presets: teams: - <<: *radiant players: - - {<<: *player, index: 0, control: human, color: 0xff7777} + - {<<: *player, index: 0, control: human, color: 0xf055a0} - {<<: *player, index: 1} - {<<: *player, index: 2} - {<<: *player, index: 3} @@ -55,8 +55,8 @@ presets: teams: - <<: *radiant players: - - {<<: *player, index: 0, control: human, color: 0xff7777} - - {<<: *player, index: 1, control: human, color: 0xff7777} + - {<<: *player, index: 0, control: human, color: 0xf055a0} + - {<<: *player, index: 1, control: human, color: 0xf055a0} - {<<: *player, index: 2} - {<<: *player, index: 3} - {<<: *player, index: 4} @@ -71,14 +71,14 @@ presets: teams: - <<: *radiant players: - - {<<: *player, index: 0, control: human, color: 0xff7777} + - {<<: *player, index: 0, control: human, color: 0xf055a0} - {<<: *player, index: 1} - {<<: *player, index: 2} - {<<: *player, index: 3} - {<<: *player, index: 4} - <<: *dire players: - - {<<: *player, index: 0, control: human, color: 0x7777ff} + - {<<: *player, index: 0, control: human, color: 0xa055f0} - {<<: *player, index: 1} - {<<: *player, index: 2} - {<<: *player, index: 3} diff --git a/src/client/resources/dota/levels/level007.txt b/src/client/resources/dota/levels/level007.txt new file mode 100644 index 0000000..c8216b2 --- /dev/null +++ b/src/client/resources/dota/levels/level007.txt @@ -0,0 +1,2 @@ +data: "444455555555555555555555555555555555444444445555555555555555555555555555555544440044004444444400444444440044444444004400004400444444440044444444004444444400440000220000000000000000000000000000000022000022000000000000000000000000000000002200004400444444442244444444224444444400440000440044444444224444444422444444440044000011000033550000000000000000553300001100001100003355000000000000000055330000110000110000444444004444444400444444440011000011000044444400444444440044444444001100004400000000000055333355000000000000440000440000000000005533335500000000000044000000442244444400443333440044444422440000000044224444440044333344004444442244000000440000000000005533335500000000000044000044000000000000553333550000000000004400001100444444440044444444004444444400110000110044444444004444444400444444440011000011000033550000000000000000553300001100001100003355000000000000000055330000110000440044444444224444444422444444440044000044004444444422444444442244444444004400002200000000000000000000000000000000220000220000000000000000000000000000000022000044004444444400444444440044444440004400004400444444440044444444004444444000440044445555555555555555555555555555555544444444555555555555555555555555555555554444" +points: [{team: radiant, direction: right, x: 2, type: eagle, y: 14, index: -1}, {team: radiant, direction: right, x: 14, type: tank, y: 2, index: 0}, {team: radiant, direction: right, x: 6, type: tank, y: 8, index: 1}, {team: radiant, direction: right, x: 14, type: tank, y: 14, index: 2}, {team: radiant, direction: right, x: 6, type: tank, y: 20, index: 3}, {team: radiant, direction: right, x: 14, type: tank, y: 26, index: 4}, {team: dire, direction: right, x: 36, type: eagle, y: 14, index: -1}, {team: dire, direction: left, x: 24, type: tank, y: 2, index: 0}, {team: dire, direction: left, x: 32, type: tank, y: 8, index: 1}, {team: dire, direction: left, x: 24, type: tank, y: 14, index: 2}, {team: dire, direction: left, x: 32, type: tank, y: 20, index: 3}, {team: dire, direction: left, x: 24, type: tank, y: 26, index: 4}] diff --git a/src/common/haxe/ru/m/tankz/config/LevelBundle.hx b/src/common/haxe/ru/m/tankz/config/LevelBundle.hx index 02a1327..7a5f631 100644 --- a/src/common/haxe/ru/m/tankz/config/LevelBundle.hx +++ b/src/common/haxe/ru/m/tankz/config/LevelBundle.hx @@ -48,7 +48,7 @@ class LevelBundle { } public static function dumps(config:Config, level:LevelConfig):String { - var bricksStr = level.data.map(function(brick:BrickConfig) return Std.string(brick.type)).join(''); + var bricksStr = level.data.map(function(brick:BrickConfig) return Std.string(brick.index)).join(''); return Yaml.render({ data: bricksStr, points: level.points, diff --git a/src/editor/haxe/ru/m/tankz/editor/frame/LevelFrame.hx b/src/editor/haxe/ru/m/tankz/editor/frame/LevelFrame.hx index 5abd1c8..5beab49 100644 --- a/src/editor/haxe/ru/m/tankz/editor/frame/LevelFrame.hx +++ b/src/editor/haxe/ru/m/tankz/editor/frame/LevelFrame.hx @@ -11,7 +11,9 @@ import ru.m.tankz.config.Config; import ru.m.tankz.config.ConfigBundle; import ru.m.tankz.config.LevelBundle; import ru.m.tankz.editor.FileUtil; -import ru.m.tankz.editor.MapEditView.Brush; +import ru.m.tankz.editor.level.BrickView; +import ru.m.tankz.editor.level.MapEditView; +import ru.m.tankz.editor.level.SpawnPointView; import ru.m.tankz.game.ClassicGame; import ru.m.tankz.game.DotaGame; import ru.m.tankz.Type; diff --git a/src/editor/haxe/ru/m/tankz/editor/frame/LevelFrame.yaml b/src/editor/haxe/ru/m/tankz/editor/frame/LevelFrame.yaml index 44ea5bb..9b6083d 100644 --- a/src/editor/haxe/ru/m/tankz/editor/frame/LevelFrame.yaml +++ b/src/editor/haxe/ru/m/tankz/editor/frame/LevelFrame.yaml @@ -33,7 +33,7 @@ views: views: - id: spawnPointList $type: haxework.gui.list.VListView - factory: '@class:ru.m.tankz.editor.SpawnPointView' + factory: '@class:ru.m.tankz.editor.level.SpawnPointView' width: 56 pHeight: 100 scroll: @@ -47,11 +47,11 @@ views: color: 0x000000 alpha: 0.0 - id: mapView - $type: ru.m.tankz.editor.MapEditView + $type: ru.m.tankz.editor.level.MapEditView contentSize: true - id: brickList $type: haxework.gui.list.VListView - factory: '@class:ru.m.tankz.editor.BrickView' + factory: '@class:ru.m.tankz.editor.level.BrickView' width: 30 pHeight: 100 scroll: diff --git a/src/editor/haxe/ru/m/tankz/editor/frame/TankFrame.hx b/src/editor/haxe/ru/m/tankz/editor/frame/TankFrame.hx index 9b83615..e166e6c 100644 --- a/src/editor/haxe/ru/m/tankz/editor/frame/TankFrame.hx +++ b/src/editor/haxe/ru/m/tankz/editor/frame/TankFrame.hx @@ -1,22 +1,34 @@ package ru.m.tankz.editor.frame; -import haxework.gui.VGroupView; +import ru.m.draw.Color; +import ru.m.tankz.editor.tank.TankView; +import haxework.gui.InputView; +import haxework.gui.HGroupView; import haxework.gui.ViewBuilder; interface TankFrameLayout { - + var tank(default, null):TankView; + var colorR(default, null):InputView; + var colorG(default, null):InputView; + var colorB(default, null):InputView; } @:template('ru/m/tankz/editor/frame/TankFrame.yaml') -class TankFrame extends VGroupView implements ViewBuilder implements TankFrameLayout { +class TankFrame extends HGroupView implements ViewBuilder implements TankFrameLayout { public static inline var ID = 'tank'; public function init():Void { - + colorR.onKeyUp = this; + colorG.onKeyUp = this; + colorB.onKeyUp = this; } public function onShow():Void { + onKeyUp(null); + } + public function onKeyUp(text:String):Void { + tank.color = Color.fromString('#${colorR.text}${colorG.text}${colorB.text}'); } } diff --git a/src/editor/haxe/ru/m/tankz/editor/frame/TankFrame.yaml b/src/editor/haxe/ru/m/tankz/editor/frame/TankFrame.yaml index 77a920a..2a66369 100644 --- a/src/editor/haxe/ru/m/tankz/editor/frame/TankFrame.yaml +++ b/src/editor/haxe/ru/m/tankz/editor/frame/TankFrame.yaml @@ -1,3 +1,48 @@ -$type: haxework.gui.VGroupView +$type: haxework.gui.HGroupView pWidth: 100 -pHeight: 100 \ No newline at end of file +pHeight: 100 +views: + - $type: ru.m.tankz.editor.tank.TankView + contentSize: true + rightMargin: 20 + image: '@asset:image:resources/image/tank/bc-0.png' + color: '#ff4422' + - $type: ru.m.tankz.editor.tank.TankView + contentSize: true + rightMargin: 20 + image: '@asset:image:resources/image/tank/bc-0.png' + color: '#f055a0' + - $type: ru.m.tankz.editor.tank.TankView + contentSize: true + rightMargin: 20 + image: '@asset:image:resources/image/tank/bc-0.png' + color: '#2244ff' + - id: tank + $type: ru.m.tankz.editor.tank.TankView + contentSize: true + rightMargin: 20 + image: '@asset:image:resources/image/tank/bc-0.png' + - id: colorR + $type: haxework.gui.InputView + width: 30 + height: 20 + text: 'a0' + skin: + $type: haxework.gui.skin.ColorSkin + color: 0xffffff + - id: colorG + $type: haxework.gui.InputView + width: 30 + height: 20 + text: '55' + skin: + $type: haxework.gui.skin.ColorSkin + color: 0xffffff + - id: colorB + $type: haxework.gui.InputView + width: 30 + height: 20 + text: 'f0' + skin: + $type: haxework.gui.skin.ColorSkin + color: 0xffffff diff --git a/src/editor/haxe/ru/m/tankz/editor/BrickView.hx b/src/editor/haxe/ru/m/tankz/editor/level/BrickView.hx similarity index 97% rename from src/editor/haxe/ru/m/tankz/editor/BrickView.hx rename to src/editor/haxe/ru/m/tankz/editor/level/BrickView.hx index 970734a..4d09566 100644 --- a/src/editor/haxe/ru/m/tankz/editor/BrickView.hx +++ b/src/editor/haxe/ru/m/tankz/editor/level/BrickView.hx @@ -1,4 +1,4 @@ -package ru.m.tankz.editor; +package ru.m.tankz.editor.level; import flash.display.Bitmap; import flash.display.Shape; diff --git a/src/editor/haxe/ru/m/tankz/editor/MapEditView.hx b/src/editor/haxe/ru/m/tankz/editor/level/MapEditView.hx similarity index 99% rename from src/editor/haxe/ru/m/tankz/editor/MapEditView.hx rename to src/editor/haxe/ru/m/tankz/editor/level/MapEditView.hx index 8db75c5..5482ffc 100644 --- a/src/editor/haxe/ru/m/tankz/editor/MapEditView.hx +++ b/src/editor/haxe/ru/m/tankz/editor/level/MapEditView.hx @@ -1,17 +1,17 @@ -package ru.m.tankz.editor; +package ru.m.tankz.editor.level; -import ru.m.geom.Rectangle; -import ru.m.tankz.core.Entity; -import ru.m.geom.Point; -import flash.events.MouseEvent; -import ru.m.tankz.map.Brick; import flash.display.DisplayObjectContainer; import flash.display.Graphics; import flash.display.Sprite; -import ru.m.tankz.render.RenderItem; -import ru.m.tankz.config.Config; -import ru.m.tankz.map.LevelMap; +import flash.events.MouseEvent; import haxework.gui.SpriteView; +import ru.m.geom.Point; +import ru.m.geom.Rectangle; +import ru.m.tankz.config.Config; +import ru.m.tankz.core.Entity; +import ru.m.tankz.map.Brick; +import ru.m.tankz.map.LevelMap; +import ru.m.tankz.render.RenderItem; class SpawnPointEntity extends Entity { diff --git a/src/editor/haxe/ru/m/tankz/editor/SpawnPointView.hx b/src/editor/haxe/ru/m/tankz/editor/level/SpawnPointView.hx similarity index 95% rename from src/editor/haxe/ru/m/tankz/editor/SpawnPointView.hx rename to src/editor/haxe/ru/m/tankz/editor/level/SpawnPointView.hx index fea3854..5d37781 100644 --- a/src/editor/haxe/ru/m/tankz/editor/SpawnPointView.hx +++ b/src/editor/haxe/ru/m/tankz/editor/level/SpawnPointView.hx @@ -1,13 +1,13 @@ -package ru.m.tankz.editor; +package ru.m.tankz.editor.level; -import haxework.provider.Provider; -import ru.m.tankz.editor.MapEditView.SpawnPointItem; import flash.display.Bitmap; import flash.display.Shape; import haxework.gui.list.ListView; import haxework.gui.SpriteView; +import haxework.provider.Provider; import openfl.utils.Assets; import ru.m.tankz.config.Config; +import ru.m.tankz.editor.level.MapEditView; class SpawnPointView extends SpriteView implements IListItemView { diff --git a/src/editor/haxe/ru/m/tankz/editor/tank/TankView.hx b/src/editor/haxe/ru/m/tankz/editor/tank/TankView.hx new file mode 100644 index 0000000..1c90d02 --- /dev/null +++ b/src/editor/haxe/ru/m/tankz/editor/tank/TankView.hx @@ -0,0 +1,45 @@ +package ru.m.tankz.editor.tank; + +import ru.m.draw.BitmapUtil; +import ru.m.draw.Color; +import flash.display.BitmapData; +import flash.display.Bitmap; +import haxework.gui.View; + + +class TankView extends View { + + public var contentAsBitmap(get, null):Bitmap; + public var image(default, set):BitmapData; + public var color(default, set):Color; + + public function new() { + super(new Bitmap()); + } + + inline private function get_contentAsBitmap():Bitmap { + return cast content; + } + + inline private function get_image():BitmapData { + return contentAsBitmap.bitmapData; + } + + inline private function set_image(value:BitmapData):BitmapData { + image = value; + contentAsBitmap.bitmapData = BitmapUtil.colorize(image, color); + if (contentSize) { + width = image.width; + height = image.height; + } + return image; + } + + inline private function set_color(value:Color):Color { + color = value; + if (image != null) { + contentAsBitmap.bitmapData = BitmapUtil.colorize(image, color); + } + return color; + } +} \ No newline at end of file