Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 79039ae79e | |||
| 1ae84cf5a8 | |||
| 032fa0c0ad | |||
| 1f8b43ba5d | |||
| 4fc0ae103e | |||
| bd86412d83 | |||
| 592e59e01f | |||
| 05b6fe4a56 | |||
| f68e5d160f | |||
| d279d52b09 | |||
| a1ed498bf5 | |||
| 41c5610f9a | |||
| 5c57454998 | |||
| a7effef412 | |||
| dd1014e230 | |||
| 89ac9fd225 | |||
| 3096fba7c5 | |||
| baf696a3e1 | |||
| 5daf4fafc7 |
29
WORK.md
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
* ui
|
* ui
|
||||||
* auth frame 0%
|
* auth frame 0%
|
||||||
* select game frame 30% (classic 1/2 player, dota singe/coop/vs)
|
* select game frame 100% (classic 1/2 player, dota singe/coop/vs)
|
||||||
* select level frame 10%
|
* select level frame 10%
|
||||||
* game frame 50%
|
* game frame 50%
|
||||||
|
|
||||||
@@ -21,21 +21,29 @@
|
|||||||
* bullets 100%
|
* bullets 100%
|
||||||
* boxes 100%
|
* boxes 100%
|
||||||
* map changes 100%
|
* map changes 100%
|
||||||
* bonuses 0%
|
* bonuses 100%
|
||||||
* eagle 100%
|
* eagle 100%
|
||||||
|
|
||||||
* game
|
* game
|
||||||
* classic
|
* classic
|
||||||
* state 50%
|
* state 50%
|
||||||
* bot 50%
|
* bot 50%
|
||||||
* player: 50%
|
* human 100%
|
||||||
* dota
|
* dota
|
||||||
* state 50%
|
* state 50%
|
||||||
* bot 10%
|
* bot 10%
|
||||||
* player 0%
|
* human 100%
|
||||||
|
|
||||||
|
* bonus
|
||||||
|
* star 50%
|
||||||
|
* grenade 0%
|
||||||
|
* helm 0%
|
||||||
|
* clock 0%
|
||||||
|
* shovel 0%
|
||||||
|
|
||||||
* state
|
* state
|
||||||
* score 0%
|
* score 0%
|
||||||
|
* human tank 0%
|
||||||
* save/load 0%
|
* save/load 0%
|
||||||
* export/import 0%
|
* export/import 0%
|
||||||
|
|
||||||
@@ -47,16 +55,19 @@
|
|||||||
* animations
|
* animations
|
||||||
* tank spawn 0%
|
* tank spawn 0%
|
||||||
* tank move 100%
|
* tank move 100%
|
||||||
* map water 0%
|
* map water 100%
|
||||||
* bullet boom 90%
|
* bullet boom 90%
|
||||||
* tank boom 90%
|
* tank boom 90%
|
||||||
* bonuses 0%
|
* bonuses 100%
|
||||||
* html5 50%
|
* html5 50%
|
||||||
|
|
||||||
* proto
|
* proto
|
||||||
...
|
...
|
||||||
|
|
||||||
* editor
|
* editor
|
||||||
* open 0%
|
* level
|
||||||
* edit 0%
|
* open 100%
|
||||||
* save 0%
|
* edit 50%
|
||||||
|
* save 100%
|
||||||
|
* tank
|
||||||
|
* color 10%
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tankz",
|
"name": "tankz",
|
||||||
"version": "0.5.0",
|
"version": "0.6.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"ansi-colors": "^1.0.1",
|
"ansi-colors": "^1.0.1",
|
||||||
@@ -37,6 +37,7 @@
|
|||||||
"protohx": "0.4.6",
|
"protohx": "0.4.6",
|
||||||
"yaml": "1.3.0",
|
"yaml": "1.3.0",
|
||||||
"haxework": "git@bitbucket.org:shmyga/haxework.git",
|
"haxework": "git@bitbucket.org:shmyga/haxework.git",
|
||||||
"orm": "2.1.0"
|
"orm": "2.1.0",
|
||||||
|
"yield": "1.1.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
<haxelib name="protohx" version="0.4.6"/>
|
<haxelib name="protohx" version="0.4.6"/>
|
||||||
<haxelib name="haxework" version="git"/>
|
<haxelib name="haxework" version="git"/>
|
||||||
<haxelib name="yaml" version="1.3.0"/>
|
<haxelib name="yaml" version="1.3.0"/>
|
||||||
|
<haxelib name="yield" version="1.1.2"/>
|
||||||
<window fps="30"/>
|
<window fps="30"/>
|
||||||
<window width="1024" height="768" unless="html5"/>
|
<window width="1024" height="768" unless="html5"/>
|
||||||
<haxeflag name="-D" value="swf-gpu"/>
|
<haxeflag name="-D" value="swf-gpu"/>
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"pWidth": 100, "pHeight": 100,
|
|
||||||
"views": [
|
|
||||||
{
|
|
||||||
"id": "state", "@type": "haxework.gui.LabelView", "@style": "label",
|
|
||||||
"pWidth": 100, "height": 20
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "render", "@type": "ru.m.tankz.render.Render",
|
|
||||||
"contentSize": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
{
|
|
||||||
"pWidth": 100, "pHeight": 100,
|
|
||||||
"views": [
|
|
||||||
{
|
|
||||||
"id":"levels", "@type":"haxework.gui.list.VListView<Int>",
|
|
||||||
"factory": "@class:ru.m.tankz.view.frames.list.LevelView",
|
|
||||||
"pWidth":100,
|
|
||||||
"pHeight":100,
|
|
||||||
"paddings":10,
|
|
||||||
"scroll":{
|
|
||||||
"@type":"haxework.gui.list.VScrollView",
|
|
||||||
"width":10, "pHeight":100,
|
|
||||||
"skin":{"@type":"haxework.gui.list.VScrollSkin"}
|
|
||||||
},
|
|
||||||
"skin": {
|
|
||||||
"@type": "haxework.gui.skin.ColorSkin",
|
|
||||||
"color": "0x000000", "alpha": 0.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
{
|
|
||||||
"pWidth": 100, "pHeight": 100,
|
|
||||||
"views": [
|
|
||||||
{
|
|
||||||
"@type": "haxework.gui.ImageView",
|
|
||||||
"image": "@asset:image:resources/images/logo/logo.png",
|
|
||||||
"contentSize": true, "bottomMargin": 15
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"@type": "haxework.gui.LabelView", "@style": "label",
|
|
||||||
"fontSize": 20, "topMargin": 15,
|
|
||||||
"contentSize": true,
|
|
||||||
"text": "Classic"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "classic_1p",
|
|
||||||
"@type": "haxework.gui.ButtonView",
|
|
||||||
"text": "1 Player",
|
|
||||||
"@style": "button"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "classic_2p",
|
|
||||||
"@type": "haxework.gui.ButtonView",
|
|
||||||
"text": "2 Player",
|
|
||||||
"@style": "button"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"@type": "haxework.gui.LabelView", "@style": "label",
|
|
||||||
"fontSize": 20, "topMargin": 15,
|
|
||||||
"contentSize": true,
|
|
||||||
"text": "DotA"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "dota_1p",
|
|
||||||
"@type": "haxework.gui.ButtonView",
|
|
||||||
"text": "1 Player",
|
|
||||||
"@style": "button"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "dota_2p_coop",
|
|
||||||
"@type": "haxework.gui.ButtonView",
|
|
||||||
"text": "2 COOP",
|
|
||||||
"@style": "button"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "dota_2p_vs",
|
|
||||||
"@type": "haxework.gui.ButtonView",
|
|
||||||
"text": "2 VS",
|
|
||||||
"@style": "button"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
{
|
|
||||||
"@type": "haxework.gui.VGroupView",
|
|
||||||
"pWidth": 100, "pHeight": 100,
|
|
||||||
"views": [
|
|
||||||
{
|
|
||||||
"id": "switcher", "@type": "haxework.gui.frame.FrameSwitcher",
|
|
||||||
"pWidth": 100, "pHeight": 100,
|
|
||||||
"skin": {
|
|
||||||
"@type": "haxework.gui.skin.BitmapSkin",
|
|
||||||
"image": "@asset:image:resources/images/background.png",
|
|
||||||
"fillType": "REPEAT"
|
|
||||||
},
|
|
||||||
"views": [
|
|
||||||
{
|
|
||||||
"id": "start",
|
|
||||||
"@type": "ru.m.tankz.view.frames.StartFrame"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "level",
|
|
||||||
"@type": "ru.m.tankz.view.frames.LevelFrame"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "game",
|
|
||||||
"@type": "ru.m.tankz.view.frames.GameFrame"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"@type": "haxework.gui.LabelView",
|
|
||||||
"inLayout": false,
|
|
||||||
"contentSize": true,
|
|
||||||
"vAlign": "BOTTOM",
|
|
||||||
"hAlign": "RIGHT",
|
|
||||||
"text": "@res:text:version",
|
|
||||||
"@style": "label"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"level": {
|
|
||||||
"width": 440, "height": 44,
|
|
||||||
"margins": 5,
|
|
||||||
"views": [
|
|
||||||
{
|
|
||||||
"id": "label",
|
|
||||||
"@type": "haxework.gui.LabelView",
|
|
||||||
"pWidth": 100, "pHeight": 100, "text": "",
|
|
||||||
"@style": "label"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"skin": {
|
|
||||||
"@type": "haxework.gui.skin.ColorSkin",
|
|
||||||
"color": "0x000000", "alpha": 0.2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
{
|
|
||||||
"button": {
|
|
||||||
"width":250, "height":60,
|
|
||||||
"skin": {
|
|
||||||
"@type": "haxework.gui.skin.ButtonBitmapSkin",
|
|
||||||
"upImage": "@asset:image:resources/images/control/button_normal.png",
|
|
||||||
"downImage": "@asset:image:resources/images/control/button_down.png",
|
|
||||||
"overImage": "@asset:image:resources/images/control/button_over.png",
|
|
||||||
"fillType": "NINEPATH"
|
|
||||||
},
|
|
||||||
"fontFamily":"@res:text:font", "fontEmbed":true, "fontColor":"0xE7E0BB", "fontSize":20
|
|
||||||
},
|
|
||||||
|
|
||||||
"label": {
|
|
||||||
"fontColor": "0xffffff",
|
|
||||||
"fontEmbed": false,
|
|
||||||
"fontFamily": "@res:text:fontName",
|
|
||||||
"fontSize": 16,
|
|
||||||
"shadowColor": "0x000000"
|
|
||||||
},
|
|
||||||
|
|
||||||
"input": {
|
|
||||||
"fontColor": "0xffffff",
|
|
||||||
"fontEmbed": false,
|
|
||||||
"fontFamily": "@res:text:fontName",
|
|
||||||
"fontSize": 16,
|
|
||||||
"shadowColor": "0x000000",
|
|
||||||
"skin": {
|
|
||||||
"@type": "haxework.gui.skin.ColorSkin",
|
|
||||||
"color": "0x000000"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -26,8 +26,6 @@ class Animate extends Bitmap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static var a = new BitmapData(1, 1);
|
|
||||||
|
|
||||||
public var playing(default, set):Bool;
|
public var playing(default, set):Bool;
|
||||||
public var frames(default, set):Array<BitmapData>;
|
public var frames(default, set):Array<BitmapData>;
|
||||||
private var index:Int;
|
private var index:Int;
|
||||||
|
|||||||
17
src/client/haxe/ru/m/draw/BitmapUtil.hx
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package ru.m.draw;
|
||||||
|
|
||||||
|
import flash.geom.ColorTransform;
|
||||||
|
import flash.geom.Rectangle;
|
||||||
|
import flash.display.BitmapData;
|
||||||
|
|
||||||
|
|
||||||
|
class BitmapUtil {
|
||||||
|
|
||||||
|
public static function colorize(data: BitmapData, color: Color):BitmapData {
|
||||||
|
if (color.zero) return data;
|
||||||
|
var result = data.clone();
|
||||||
|
var transform = new ColorTransform(color.red / 255, color.green / 255, color.blue / 255, 1, 0, 0, 0, 0);
|
||||||
|
result.colorTransform(new Rectangle(0, 0, result.width, result.height), transform);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
47
src/client/haxe/ru/m/draw/Color.hx
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
package ru.m.draw;
|
||||||
|
|
||||||
|
abstract Color(Int) {
|
||||||
|
public var alpha(get, never):Int;
|
||||||
|
public var red(get, never):Int;
|
||||||
|
public var green(get, never):Int;
|
||||||
|
public var blue(get, never):Int;
|
||||||
|
public var zero(get, never):Bool;
|
||||||
|
|
||||||
|
public inline function new(value:Int) {
|
||||||
|
this = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private inline function get_alpha():Int {
|
||||||
|
return (this >> 24) & 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
private inline function get_red():Int {
|
||||||
|
return (this >> 16) & 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
private inline function get_green():Int {
|
||||||
|
return (this >> 8) & 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
private inline function get_blue():Int {
|
||||||
|
return this & 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
private inline function get_zero():Bool {
|
||||||
|
return this == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@:from
|
||||||
|
static public inline function fromInt(value:Int):Color {
|
||||||
|
return new Color(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@:from
|
||||||
|
static public inline function fromString(value:String):Color {
|
||||||
|
return new Color(Std.parseInt('0x${value.split('#').pop()}'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toString():String {
|
||||||
|
return 'Color(${red},${green},${blue})';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,34 +1,37 @@
|
|||||||
package ru.m.tankz;
|
package ru.m.tankz;
|
||||||
|
|
||||||
|
import flash.events.KeyboardEvent;
|
||||||
|
import flash.text.Font;
|
||||||
|
import flash.ui.Keyboard;
|
||||||
|
import haxework.gui.ButtonView;
|
||||||
|
import haxework.gui.frame.IFrameSwitcher;
|
||||||
|
import haxework.gui.Root;
|
||||||
|
import haxework.gui.VGroupView;
|
||||||
|
import haxework.gui.ViewBuilder;
|
||||||
|
import haxework.log.TraceLogger;
|
||||||
|
import haxework.provider.Provider;
|
||||||
|
import haxework.resources.IResources;
|
||||||
|
import haxework.resources.Resources;
|
||||||
|
import ru.m.connect.IConnection;
|
||||||
|
import ru.m.tankz.frame.StartFrame;
|
||||||
import ru.m.tankz.game.ClassicGame;
|
import ru.m.tankz.game.ClassicGame;
|
||||||
import ru.m.tankz.game.DotaGame;
|
import ru.m.tankz.game.DotaGame;
|
||||||
import ru.m.tankz.game.Game;
|
import ru.m.tankz.game.Game;
|
||||||
import flash.ui.Keyboard;
|
|
||||||
import flash.events.KeyboardEvent;
|
|
||||||
import flash.text.Font;
|
|
||||||
import ru.m.tankz.view.frames.StartFrame;
|
|
||||||
import haxework.log.SocketLogger;
|
|
||||||
import haxework.resources.Resources;
|
|
||||||
import haxework.resources.IResources;
|
|
||||||
import haxework.gui.VGroupView;
|
|
||||||
import haxework.gui.ViewBuilder;
|
|
||||||
import haxework.gui.ButtonView;
|
|
||||||
import ru.m.tankz.PacketBuilder;
|
import ru.m.tankz.PacketBuilder;
|
||||||
import haxework.log.JSLogger;
|
#if flash import haxework.log.JSLogger; #end
|
||||||
import haxework.gui.frame.IFrameSwitcher;
|
#if debug import haxework.log.SocketLogger; #end
|
||||||
import haxework.provider.Provider;
|
|
||||||
import haxework.gui.frame.FrameSwitcher;
|
|
||||||
import haxework.gui.Root;
|
|
||||||
import openfl.Assets;
|
|
||||||
import ru.m.connect.IConnection;
|
|
||||||
import haxework.log.TraceLogger;
|
|
||||||
|
|
||||||
@:template("layout/main.json", "layout/styles.json")
|
|
||||||
class MainView extends VGroupView implements ViewBuilder {}
|
interface ClientViewLayout {
|
||||||
|
var switcher(default, null):IFrameSwitcher;
|
||||||
|
}
|
||||||
|
|
||||||
|
@:template('ru/m/tankz/Client.yaml', 'ru/m/tankz/Style.yaml')
|
||||||
|
class ClientView extends VGroupView implements ClientViewLayout implements ViewBuilder {}
|
||||||
|
|
||||||
class Client implements IConnectionHandler {
|
class Client implements IConnectionHandler {
|
||||||
|
|
||||||
private static inline var TAG = "Tankz";
|
private static inline var TAG = 'Tankz';
|
||||||
|
|
||||||
public static function main() {
|
public static function main() {
|
||||||
L.push(new TraceLogger());
|
L.push(new TraceLogger());
|
||||||
@@ -39,31 +42,31 @@ class Client implements IConnectionHandler {
|
|||||||
L.push(new SocketLogger());
|
L.push(new SocketLogger());
|
||||||
#end
|
#end
|
||||||
Const.init();
|
Const.init();
|
||||||
L.d(TAG, "Debug: " + Const.DEBUG);
|
L.d(TAG, 'Debug: ${Const.DEBUG}');
|
||||||
L.i(TAG, "Version: " + Const.VERSION);
|
L.i(TAG, 'Version: ${Const.VERSION}');
|
||||||
L.i(TAG, "Build: " + Const.BUILD);
|
L.i(TAG, 'Build: ${Const.BUILD}');
|
||||||
new Client();
|
new Client();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private var view:MainView;
|
private var view:ClientView;
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
Provider.setFactory(IResources, Resources);
|
Provider.setFactory(IResources, Resources);
|
||||||
|
|
||||||
var font:Font = Font.enumerateFonts()[0];
|
var font:Font = Font.enumerateFonts()[0];
|
||||||
Provider.get(IResources).text.put("font", "Bookman Old Style");
|
Provider.get(IResources).text.put('font', 'Bookman Old Style');
|
||||||
Provider.get(IResources).text.put("version", 'v${Const.VERSION} b${Const.BUILD}');
|
Provider.get(IResources).text.put('version', 'v${Const.VERSION} b${Const.BUILD}');
|
||||||
|
|
||||||
Provider.set(IPacketBuilder, new PacketBuilder());
|
Provider.set(IPacketBuilder, new PacketBuilder());
|
||||||
#if flash
|
#if flash
|
||||||
Provider.set(IConnection, new ru.m.connect.flash.FlashConnection("localhost", 5001));
|
Provider.set(IConnection, new ru.m.connect.flash.FlashConnection('localhost', 5001));
|
||||||
#elseif html5
|
#elseif html5
|
||||||
Provider.set(IConnection, new ru.m.connect.js.JsConnection("localhost", 5001));
|
Provider.set(IConnection, new ru.m.connect.js.JsConnection('localhost', 5001));
|
||||||
#end
|
#end
|
||||||
|
|
||||||
//Provider.get(IConnection).handler.addListener(this);
|
//Provider.get(IConnection).handler.addListener(this);
|
||||||
view = new MainView();
|
view = new ClientView();
|
||||||
Provider.set(IFrameSwitcher, view.switcher);
|
Provider.set(IFrameSwitcher, view.switcher);
|
||||||
Root.bind(view);
|
Root.bind(view);
|
||||||
view.content.stage.stageFocusRect = false;
|
view.content.stage.stageFocusRect = false;
|
||||||
@@ -82,7 +85,7 @@ class Client implements IConnectionHandler {
|
|||||||
|
|
||||||
public function onPress(view:ButtonView):Void {
|
public function onPress(view:ButtonView):Void {
|
||||||
switch (view.id) {
|
switch (view.id) {
|
||||||
case "logout":
|
case 'logout':
|
||||||
Provider.get(IConnection).disconnect();
|
Provider.get(IConnection).disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,7 +97,7 @@ class Client implements IConnectionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onError(error:Dynamic):Void {
|
public function onError(error:Dynamic):Void {
|
||||||
L.e(TAG, "", error);
|
L.e(TAG, '', error);
|
||||||
//view.switcher.change(AuthFrame.ID);
|
//view.switcher.change(AuthFrame.ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
27
src/client/haxe/ru/m/tankz/Client.yaml
Executable file
@@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
$type: haxework.gui.VGroupView
|
||||||
|
pWidth: 100
|
||||||
|
pHeight: 100
|
||||||
|
views:
|
||||||
|
- id: switcher
|
||||||
|
$type: haxework.gui.frame.FrameSwitcher
|
||||||
|
pWidth: 100
|
||||||
|
pHeight: 100
|
||||||
|
skin:
|
||||||
|
$type: haxework.gui.skin.BitmapSkin
|
||||||
|
image: "@asset:image:resources/images/background.png"
|
||||||
|
fillType: REPEAT
|
||||||
|
views:
|
||||||
|
- id: start
|
||||||
|
$type: ru.m.tankz.frame.StartFrame
|
||||||
|
- id: level
|
||||||
|
$type: ru.m.tankz.frame.LevelFrame
|
||||||
|
- id: game
|
||||||
|
$type: ru.m.tankz.frame.GameFrame
|
||||||
|
- $type: haxework.gui.LabelView
|
||||||
|
$style: label
|
||||||
|
inLayout: false
|
||||||
|
contentSize: true
|
||||||
|
vAlign: BOTTOM
|
||||||
|
hAlign: RIGHT
|
||||||
|
text: "@res:text:version"
|
||||||
21
src/client/haxe/ru/m/tankz/Style.yaml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
button:
|
||||||
|
width: 250
|
||||||
|
height: 60
|
||||||
|
skin:
|
||||||
|
$type: haxework.gui.skin.ButtonBitmapSkin
|
||||||
|
upImage: "@asset:image:resources/images/control/button_normal.png"
|
||||||
|
downImage: "@asset:image:resources/images/control/button_down.png"
|
||||||
|
overImage: "@asset:image:resources/images/control/button_over.png"
|
||||||
|
fillType: NINEPATH
|
||||||
|
fontFamily: "@res:text:font"
|
||||||
|
fontEmbed: true
|
||||||
|
fontColor: "#E7E0BB"
|
||||||
|
fontSize: 20
|
||||||
|
|
||||||
|
label:
|
||||||
|
fontColor: "#ffffff"
|
||||||
|
fontEmbed: false
|
||||||
|
fontFamily: Courirer New
|
||||||
|
fontSize: 16
|
||||||
|
shadowColor: 0x000000
|
||||||
@@ -1,18 +1,17 @@
|
|||||||
package ru.m.tankz.control;
|
package ru.m.tankz.control;
|
||||||
|
|
||||||
import ru.m.tankz.game.Game;
|
|
||||||
import ru.m.tankz.control.Control;
|
|
||||||
import haxe.Timer;
|
|
||||||
import ru.m.geom.Direction;
|
|
||||||
import flash.events.FocusEvent;
|
import flash.events.FocusEvent;
|
||||||
import flash.ui.Keyboard;
|
|
||||||
import flash.events.KeyboardEvent;
|
import flash.events.KeyboardEvent;
|
||||||
import flash.Lib;
|
import flash.Lib;
|
||||||
|
import flash.ui.Keyboard;
|
||||||
|
import haxe.Timer;
|
||||||
|
import ru.m.geom.Direction;
|
||||||
|
import ru.m.tankz.control.Control;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
|
||||||
typedef KeyBinding = Map<Int, TankAction>;
|
typedef KeyBinding = Map<Int, TankAction>;
|
||||||
|
|
||||||
|
|
||||||
class HumanControl extends Control {
|
class HumanControl extends Control {
|
||||||
|
|
||||||
private var keyBinding:KeyBinding;
|
private var keyBinding:KeyBinding;
|
||||||
@@ -44,7 +43,7 @@ class HumanControl extends Control {
|
|||||||
case _:
|
case _:
|
||||||
}
|
}
|
||||||
if (event.keyCode == Keyboard.U) {
|
if (event.keyCode == Keyboard.U) {
|
||||||
action(TankAction.LEVEL_UP(1));
|
action(TankAction.UPGRADE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
package ru.m.tankz.view.frames;
|
package ru.m.tankz.frame;
|
||||||
|
|
||||||
import haxe.ds.Option;
|
|
||||||
import haxe.ds.Option;
|
|
||||||
import flash.events.Event;
|
import flash.events.Event;
|
||||||
|
import haxe.ds.Option;
|
||||||
import haxe.Timer;
|
import haxe.Timer;
|
||||||
import haxework.gui.frame.IFrameSwitcher;
|
import haxework.gui.frame.IFrameSwitcher;
|
||||||
import haxework.gui.LabelView;
|
import haxework.gui.LabelView;
|
||||||
@@ -22,8 +21,7 @@ interface GameFrameLayout {
|
|||||||
var render(default, null):Render;
|
var render(default, null):Render;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@:template("ru/m/tankz/frame/GameFrame.yaml", "ru/m/tankz/Style.yaml")
|
||||||
@:template("layout/frames/game.json", "layout/styles.json")
|
|
||||||
class GameFrame extends VGroupView implements ViewBuilder implements IPacketHandler implements GameFrameLayout {
|
class GameFrame extends VGroupView implements ViewBuilder implements IPacketHandler implements GameFrameLayout {
|
||||||
|
|
||||||
private static inline var TAG = "GameFrame";
|
private static inline var TAG = "GameFrame";
|
||||||
@@ -51,7 +49,7 @@ class GameFrame extends VGroupView implements ViewBuilder implements IPacketHand
|
|||||||
render.draw(game.engine);
|
render.draw(game.engine);
|
||||||
timer = new Timer(10);
|
timer = new Timer(10);
|
||||||
timer.run = updateEngine;
|
timer.run = updateEngine;
|
||||||
state.text = stateString(s);
|
state.text = stateString(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function stop():Void {
|
private function stop():Void {
|
||||||
@@ -68,20 +66,18 @@ class GameFrame extends VGroupView implements ViewBuilder implements IPacketHand
|
|||||||
render.reset();
|
render.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function stateString(state:GameState):String {
|
private function stateString(game:Game):String {
|
||||||
var result:Array<String> = [];
|
var result:Array<String> = [];
|
||||||
result.push('Level: ${state.level}');
|
result.push('Level: ${game.state.level}');
|
||||||
for (teamId in state.teams.keys()) {
|
for (team in game.teams) {
|
||||||
var ts:TeamState = state.teams[teamId];
|
if (game.state.loser == team.id) {
|
||||||
if (ts.lose) {
|
result.push('${team.id}: LOSE');
|
||||||
result.push('${teamId}: LOSE');
|
} else if (team.life > -1) {
|
||||||
} else if (ts.life > -1) {
|
result.push('${team.id}: ${team.life}');
|
||||||
result.push('${teamId}: ${ts.life}');
|
|
||||||
} else {
|
} else {
|
||||||
for (index in ts.players.keys()) {
|
for (player in team.players) {
|
||||||
var ps:PlayerState = ts.players[index];
|
if (player.life > -1) {
|
||||||
if (ps.life > -1) {
|
result.push('${player.id.team}${player.id.index}: ${player.life}');
|
||||||
result.push('${teamId}${index}: ${ps.life}');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,14 +86,14 @@ class GameFrame extends VGroupView implements ViewBuilder implements IPacketHand
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function onGameStateChange(s:GameState):GameState {
|
private function onGameStateChange(s:GameState):GameState {
|
||||||
state.text = stateString(s);
|
state.text = stateString(game);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function onGameComplete(result:Option<GameState>):Void {
|
private function onGameComplete(result:Option<GameState>):Void {
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case Option.Some(s):
|
case Option.Some(s):
|
||||||
state.text = stateString(s);
|
state.text = stateString(game);
|
||||||
case Option.None:
|
case Option.None:
|
||||||
}
|
}
|
||||||
switch (game.next()) {
|
switch (game.next()) {
|
||||||
12
src/client/haxe/ru/m/tankz/frame/GameFrame.yaml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
pWidth: 100
|
||||||
|
pHeight: 100
|
||||||
|
views:
|
||||||
|
- id: state
|
||||||
|
$type: haxework.gui.LabelView
|
||||||
|
$style: label
|
||||||
|
pWidth: 100
|
||||||
|
height: 20
|
||||||
|
- id: render
|
||||||
|
$type: ru.m.tankz.render.Render
|
||||||
|
contentSize: true
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package ru.m.tankz.view.frames;
|
package ru.m.tankz.frame;
|
||||||
|
|
||||||
import ru.m.tankz.config.ConfigBundle;
|
import ru.m.tankz.config.ConfigBundle;
|
||||||
import haxework.gui.frame.IFrameSwitcher;
|
import haxework.gui.frame.IFrameSwitcher;
|
||||||
@@ -14,7 +14,7 @@ interface LevelFrameLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@:template("layout/frames/level.json", "layout/styles.json")
|
@:template("ru/m/tankz/frame/LevelFrame.yaml", "ru/m/tankz/Style.yaml")
|
||||||
class LevelFrame extends VGroupView implements ViewBuilder implements LevelFrameLayout {
|
class LevelFrame extends VGroupView implements ViewBuilder implements LevelFrameLayout {
|
||||||
public static inline var ID = "level";
|
public static inline var ID = "level";
|
||||||
|
|
||||||
20
src/client/haxe/ru/m/tankz/frame/LevelFrame.yaml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
pWidth: 100
|
||||||
|
pHeight: 100
|
||||||
|
views:
|
||||||
|
- id: levels
|
||||||
|
$type: haxework.gui.list.VListView<Int>
|
||||||
|
factory: "@class:ru.m.tankz.frame.level.LevelView"
|
||||||
|
pWidth: 100
|
||||||
|
pHeight: 100
|
||||||
|
paddings: 10
|
||||||
|
scroll:
|
||||||
|
$type: haxework.gui.list.VScrollView
|
||||||
|
width: 10
|
||||||
|
pHeight: 100
|
||||||
|
skin:
|
||||||
|
$type: haxework.gui.list.VScrollSkin
|
||||||
|
skin:
|
||||||
|
$type: haxework.gui.skin.ColorSkin
|
||||||
|
color: "#000000"
|
||||||
|
alpha: 0
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
package ru.m.tankz.view.frames;
|
package ru.m.tankz.frame;
|
||||||
|
|
||||||
import ru.m.tankz.game.Game;
|
import haxework.gui.ButtonView;
|
||||||
import ru.m.tankz.game.GameState;
|
import haxework.gui.frame.IFrameSwitcher;
|
||||||
|
import haxework.gui.VGroupView;
|
||||||
|
import haxework.gui.ViewBuilder;
|
||||||
|
import haxework.provider.Provider;
|
||||||
import ru.m.tankz.game.ClassicGame;
|
import ru.m.tankz.game.ClassicGame;
|
||||||
import ru.m.tankz.game.DotaGame;
|
import ru.m.tankz.game.DotaGame;
|
||||||
import haxework.gui.frame.IFrameSwitcher;
|
import ru.m.tankz.game.GameState;
|
||||||
import haxework.provider.Provider;
|
import ru.m.tankz.Type;
|
||||||
import haxework.gui.ButtonView;
|
|
||||||
import haxework.gui.ViewBuilder;
|
|
||||||
import haxework.gui.VGroupView;
|
|
||||||
|
|
||||||
|
|
||||||
interface StartFrameLayout {
|
interface StartFrameLayout {
|
||||||
@@ -19,8 +19,7 @@ interface StartFrameLayout {
|
|||||||
var dota_2p_vs(default, null):ButtonView;
|
var dota_2p_vs(default, null):ButtonView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@:template("ru/m/tankz/frame/StartFrame.yaml", "ru/m/tankz/Style.yaml")
|
||||||
@:template("layout/frames/start.json", "layout/styles.json")
|
|
||||||
class StartFrame extends VGroupView implements ViewBuilder implements StartFrameLayout {
|
class StartFrame extends VGroupView implements ViewBuilder implements StartFrameLayout {
|
||||||
|
|
||||||
public static inline var ID = "start";
|
public static inline var ID = "start";
|
||||||
@@ -48,14 +47,8 @@ class StartFrame extends VGroupView implements ViewBuilder implements StartFrame
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function startGame(type:GameType, mode:GameMode):Void {
|
private function startGame(type:GameType, presetId:PresetId):Void {
|
||||||
switch (type) {
|
Provider.set(GameState, new GameState(type, presetId));
|
||||||
case ClassicGame.TYPE:
|
|
||||||
Provider.set(GameState, ClassicGame.buildState(0, mode));
|
|
||||||
Provider.get(IFrameSwitcher).change(LevelFrame.ID);
|
Provider.get(IFrameSwitcher).change(LevelFrame.ID);
|
||||||
case DotaGame.TYPE:
|
|
||||||
Provider.set(GameState, DotaGame.buildState(0, mode));
|
|
||||||
Provider.get(IFrameSwitcher).change(LevelFrame.ID);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
40
src/client/haxe/ru/m/tankz/frame/StartFrame.yaml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
---
|
||||||
|
pWidth: 100
|
||||||
|
pHeight: 100
|
||||||
|
views:
|
||||||
|
- $type: haxework.gui.ImageView
|
||||||
|
image: "@asset:image:resources/images/logo/logo.png"
|
||||||
|
contentSize: true
|
||||||
|
bottomMargin: 15
|
||||||
|
- $type: haxework.gui.LabelView
|
||||||
|
$style: label
|
||||||
|
fontSize: 20
|
||||||
|
topMargin: 15
|
||||||
|
contentSize: true
|
||||||
|
text: Classic
|
||||||
|
- id: classic_1p
|
||||||
|
$type: haxework.gui.ButtonView
|
||||||
|
text: 1 Player
|
||||||
|
$style: button
|
||||||
|
- id: classic_2p
|
||||||
|
$type: haxework.gui.ButtonView
|
||||||
|
text: 2 Player
|
||||||
|
$style: button
|
||||||
|
- $type: haxework.gui.LabelView
|
||||||
|
$style: label
|
||||||
|
fontSize: 20
|
||||||
|
topMargin: 15
|
||||||
|
contentSize: true
|
||||||
|
text: DotA
|
||||||
|
- id: dota_1p
|
||||||
|
$type: haxework.gui.ButtonView
|
||||||
|
text: 1 Player
|
||||||
|
$style: button
|
||||||
|
- id: dota_2p_coop
|
||||||
|
$type: haxework.gui.ButtonView
|
||||||
|
text: 2 COOP
|
||||||
|
$style: button
|
||||||
|
- id: dota_2p_vs
|
||||||
|
$type: haxework.gui.ButtonView
|
||||||
|
text: 2 VS
|
||||||
|
$style: button
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package ru.m.tankz.view.frames.list;
|
package ru.m.tankz.frame.level;
|
||||||
|
|
||||||
import haxework.gui.ViewBuilder;
|
import haxework.gui.ViewBuilder;
|
||||||
import haxework.gui.HGroupView;
|
import haxework.gui.HGroupView;
|
||||||
@@ -10,7 +10,7 @@ interface LevelViewLayout {
|
|||||||
var label(default, null):LabelView;
|
var label(default, null):LabelView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@:template("layout/other.json@level", "layout/styles.json")
|
@:template("ru/m/tankz/frame/level/LevelView.yaml", "ru/m/tankz/Style.yaml")
|
||||||
class LevelView extends HGroupView implements ViewBuilder implements IListItemView<Int> implements LevelViewLayout {
|
class LevelView extends HGroupView implements ViewBuilder implements IListItemView<Int> implements LevelViewLayout {
|
||||||
|
|
||||||
public var item_index(default, default):Int;
|
public var item_index(default, default):Int;
|
||||||
15
src/client/haxe/ru/m/tankz/frame/level/LevelView.yaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
width: 440
|
||||||
|
height: 44
|
||||||
|
margins: 5
|
||||||
|
views:
|
||||||
|
- id: label
|
||||||
|
$type: haxework.gui.LabelView
|
||||||
|
$style: label
|
||||||
|
pWidth: 100
|
||||||
|
pHeight: 100
|
||||||
|
text: ""
|
||||||
|
skin:
|
||||||
|
$type: haxework.gui.skin.ColorSkin
|
||||||
|
color: "#000000"
|
||||||
|
alpha: 0.2
|
||||||
@@ -54,13 +54,21 @@ class Render extends SpriteView implements EngineListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function draw(game:Engine):Void {
|
public function draw(game:Engine):Void {
|
||||||
for (brick in game.map.bricks) if (brick.config.type > 0) {
|
for (brick in game.map.bricks) if (brick.config.index > 0) {
|
||||||
if (!items.exists(brick.key)) {
|
if (!items.exists(brick.key)) {
|
||||||
items[brick.key] = new BrickItem(brick);
|
var item:RenderItem<Dynamic, Dynamic> = switch(brick.config.type) {
|
||||||
|
case 'ace' | 'bush': new BrickItem(brick);
|
||||||
|
case 'water': new BrickAnimateItem(brick);
|
||||||
|
case 'armor' | 'brick': new BrickBreakingItem(brick);
|
||||||
|
case x: null;
|
||||||
|
};
|
||||||
|
if (item != null) {
|
||||||
|
items[brick.key] = item;
|
||||||
if (brick.config.layer > 2) {
|
if (brick.config.layer > 2) {
|
||||||
upLayer.addChild(items[brick.key].view);
|
upLayer.addChild(item.view);
|
||||||
} else {
|
} else {
|
||||||
groundLayer.addChild(items[brick.key].view);
|
groundLayer.addChild(item.view);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,16 +116,25 @@ class Render extends SpriteView implements EngineListener {
|
|||||||
items.set(eagle.key, item);
|
items.set(eagle.key, item);
|
||||||
entryLayer.addChild(item.view);
|
entryLayer.addChild(item.view);
|
||||||
item.update();
|
item.update();
|
||||||
|
case EntityType.BONUS(bonus):
|
||||||
|
var item = new BonusItem(bonus);
|
||||||
|
items.set(bonus.key, item);
|
||||||
|
entryLayer.addChild(item.view);
|
||||||
|
item.update();
|
||||||
case _:
|
case _:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onCollision(entity:EntityType, with:EntityType):Void {
|
public function onCollision(entity:EntityType, with:EntityType):Void {
|
||||||
|
switch [entity, with] {
|
||||||
|
case [EntityType.BULLET(_), EntityType.EAGLE(eagle)]:
|
||||||
|
playTankBoom(eagle.rect.center);
|
||||||
|
case _:
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onDestroy(entity:EntityType):Void {
|
public function onDestroy(entity:EntityType):Void {
|
||||||
switch(entity) {
|
switch entity {
|
||||||
case EntityType.TANK(tank):
|
case EntityType.TANK(tank):
|
||||||
if (items.exists(tank.key)) {
|
if (items.exists(tank.key)) {
|
||||||
entryLayer.removeChild(items.get(tank.key).view);
|
entryLayer.removeChild(items.get(tank.key).view);
|
||||||
@@ -130,11 +147,10 @@ class Render extends SpriteView implements EngineListener {
|
|||||||
items.remove(bullet.key);
|
items.remove(bullet.key);
|
||||||
playBulletBoom(bullet.rect.center.add(new Point(bullet.rect.width * bullet.rect.direction.x, bullet.rect.height * bullet.rect.direction.y)));
|
playBulletBoom(bullet.rect.center.add(new Point(bullet.rect.width * bullet.rect.direction.x, bullet.rect.height * bullet.rect.direction.y)));
|
||||||
}
|
}
|
||||||
case EntityType.EAGLE(eagle):
|
case EntityType.BONUS(bonus):
|
||||||
if (items.exists(eagle.key)) {
|
if (items.exists(bonus.key)) {
|
||||||
cast(items.get(eagle.key), EagleItem).destoyed = true;
|
entryLayer.removeChild(items.get(bonus.key).view);
|
||||||
items.get(eagle.key).redraw();
|
items.remove(bonus.key);
|
||||||
playTankBoom(eagle.rect.center);
|
|
||||||
}
|
}
|
||||||
case _:
|
case _:
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,28 @@
|
|||||||
package ru.m.tankz.render;
|
package ru.m.tankz.render;
|
||||||
|
|
||||||
import ru.m.tankz.control.Control;
|
import ru.m.tankz.Type.BrickType;
|
||||||
import flash.display.Sprite;
|
import openfl.display.BitmapData;
|
||||||
import ru.m.animate.Animate;
|
import ru.m.draw.Color;
|
||||||
import ru.m.tankz.core.Eagle;
|
import ru.m.tankz.core.Bonus;
|
||||||
|
import flash.display.Bitmap;
|
||||||
import flash.display.DisplayObject;
|
import flash.display.DisplayObject;
|
||||||
import flash.display.Shape;
|
import flash.display.Shape;
|
||||||
|
import flash.display.Sprite;
|
||||||
|
import openfl.Assets;
|
||||||
|
import ru.m.animate.Animate;
|
||||||
|
import ru.m.draw.BitmapUtil;
|
||||||
import ru.m.geom.Direction;
|
import ru.m.geom.Direction;
|
||||||
import ru.m.geom.Rectangle;
|
import ru.m.geom.Rectangle;
|
||||||
import ru.m.tankz.core.Bullet;
|
import ru.m.tankz.core.Bullet;
|
||||||
import ru.m.tankz.map.Brick;
|
import ru.m.tankz.core.Eagle;
|
||||||
import openfl.Assets;
|
|
||||||
import ru.m.tankz.core.Tank;
|
import ru.m.tankz.core.Tank;
|
||||||
import flash.display.Bitmap;
|
import ru.m.tankz.map.Brick;
|
||||||
|
|
||||||
|
|
||||||
typedef TRectangle = {
|
typedef TRectangle = {
|
||||||
var rect(default, null):Rectangle;
|
var rect(default, null):Rectangle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class RenderItem<T:TRectangle, D:DisplayObject> {
|
class RenderItem<T:TRectangle, D:DisplayObject> {
|
||||||
|
|
||||||
public var value(default, null):T;
|
public var value(default, null):T;
|
||||||
@@ -75,10 +78,51 @@ class BitmapItem<T:TRectangle> extends RenderItem<T, Bitmap> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class BrickItem extends RenderItem<Brick, Shape> {
|
class BrickItem extends BitmapItem<Brick> {
|
||||||
|
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';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class BrickAnimateItem extends AnimateItem<Brick> {
|
||||||
|
|
||||||
|
public function new(value:Brick) {
|
||||||
|
super(value);
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
override public function redraw():Void {
|
||||||
|
var frame0 = Assets.getBitmapData('resources/image/map/${value.config.type}-0.png');
|
||||||
|
var frame1 = Assets.getBitmapData('resources/image/map/${value.config.type}-1.png');
|
||||||
|
view.frames = [for (i in 0...15) frame0].concat([for (i in 0...15) frame1]);
|
||||||
|
view.playing = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class BrickBreakingItem extends RenderItem<Brick, Shape> {
|
||||||
private var broken:Int;
|
private var broken:Int;
|
||||||
private var type:Int;
|
private var type:BrickType;
|
||||||
|
|
||||||
public function new(value:Brick) {
|
public function new(value:Brick) {
|
||||||
super(value);
|
super(value);
|
||||||
@@ -91,7 +135,7 @@ class BrickItem extends RenderItem<Brick, Shape> {
|
|||||||
var g = view.graphics;
|
var g = view.graphics;
|
||||||
g.clear();
|
g.clear();
|
||||||
if (value.destroyed) return;
|
if (value.destroyed) return;
|
||||||
if (value.config.type > 0) {
|
if (value.config.index > 0) {
|
||||||
g.beginBitmapFill(image);
|
g.beginBitmapFill(image);
|
||||||
g.drawRect(0, 0, value.rect.width, value.rect.height);
|
g.drawRect(0, 0, value.rect.width, value.rect.height);
|
||||||
for (c in value.cells) {
|
for (c in value.cells) {
|
||||||
@@ -116,7 +160,20 @@ class BrickItem extends RenderItem<Brick, Shape> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function getImage():String {
|
private function getImage():String {
|
||||||
return 'resources/images/map/map_${value.config.type}.png';
|
return 'resources/image/map/${value.config.type}.png';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class AnimateItem<T:TRectangle> extends RenderItem<T, Animate> {
|
||||||
|
|
||||||
|
public function new(value:T) {
|
||||||
|
super(value);
|
||||||
|
view = new Animate();
|
||||||
|
}
|
||||||
|
|
||||||
|
override public function dispose():Void {
|
||||||
|
view.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,68 +182,64 @@ class TankItem extends RenderItem<Tank, Sprite> {
|
|||||||
|
|
||||||
private var type:String;
|
private var type:String;
|
||||||
private var hits:Int;
|
private var hits:Int;
|
||||||
|
private var protected:Bool;
|
||||||
|
private var frozen:Bool;
|
||||||
|
|
||||||
private var tankView:Animate;
|
private var tankView:Animate;
|
||||||
|
private var protectView:Animate;
|
||||||
|
|
||||||
public function new(value:Tank) {
|
public function new(value:Tank) {
|
||||||
super(value);
|
super(value);
|
||||||
view = new Sprite();
|
view = new Sprite();
|
||||||
if (value.playerId.type == Control.HUMAN) {
|
|
||||||
view.addChild(buildHumanMarkView(value));
|
|
||||||
}
|
|
||||||
tankView = new Animate();
|
tankView = new Animate();
|
||||||
view.addChild(tankView);
|
view.addChild(tankView);
|
||||||
|
protectView = new Animate(
|
||||||
|
[for (i in 0...5) Assets.getBitmapData('resources/images/tank/protect/protect-0.png')].concat(
|
||||||
|
[for (i in 0...5) Assets.getBitmapData('resources/images/tank/protect/protect-1.png')])
|
||||||
|
);
|
||||||
|
protectView.visible = false;
|
||||||
|
view.addChild(protectView);
|
||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function buildHumanMarkView(tank:Tank):DisplayObject {
|
|
||||||
var view = new Shape();
|
|
||||||
view.graphics.beginFill(0x00aa00);
|
|
||||||
view.graphics.lineStyle(2, 0x00ff00);
|
|
||||||
view.graphics.drawCircle(0, 0, 23);
|
|
||||||
view.graphics.endFill();
|
|
||||||
view.x = tank.rect.width / 2;
|
|
||||||
view.y = tank.rect.height / 2;
|
|
||||||
view.alpha = 0.2;
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
override public function redraw():Void {
|
override public function redraw():Void {
|
||||||
tankView.frames = getFrames().map(function(s) return Assets.getBitmapData(s));
|
var colors:Array<Color> = [value.color, value.bonus ? 0xff00aa : value.color];
|
||||||
|
var frames = [for (frame in getFrames()) BitmapUtil.colorize(Assets.getBitmapData(frame), colors.shift())];
|
||||||
|
tankView.frames = [
|
||||||
|
frames[0], frames[0], frames[0],
|
||||||
|
frames[1], frames[1], frames[1],
|
||||||
|
];
|
||||||
|
if (value.protect.active) {
|
||||||
|
protectView.x = (tankView.frames[0].width - protectView.frames[0].width) / 2;
|
||||||
|
protectView.y = (tankView.frames[0].height - protectView.frames[0].height) / 2;
|
||||||
|
protectView.playing = true;
|
||||||
|
protectView.visible = true;
|
||||||
|
} else {
|
||||||
|
protectView.playing = false;
|
||||||
|
protectView.visible = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getFrames():Array<String> {
|
private function getFrames():Array<String> {
|
||||||
var team = value.playerId.team;
|
var frame0 = 'resources/image/tank/${value.config.skin}-0.png';
|
||||||
var group = value.config.group;
|
var frame1 = 'resources/image/tank/${value.config.skin}-1.png';
|
||||||
var index = value.playerId.index;
|
return [frame1, frame0];
|
||||||
if (team == 'radiant') {
|
|
||||||
index = 0;
|
|
||||||
}
|
|
||||||
if (team == 'dire') {
|
|
||||||
index = 1;
|
|
||||||
}
|
|
||||||
if (team == 'human' || team == 'radiant' || team == 'dire') {
|
|
||||||
group = 'player';
|
|
||||||
}
|
|
||||||
if (team == 'bot') {
|
|
||||||
index = value.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',
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override public function update():Void {
|
override public function update():Void {
|
||||||
super.update();
|
super.update();
|
||||||
var t = value.config.type;
|
var t = value.config.type;
|
||||||
var h = value.hits;
|
var h = value.hits;
|
||||||
if (t != this.type || h != this.hits) {
|
var p = value.protect.active;
|
||||||
|
var f = value.freezing.active;
|
||||||
|
if (t != type || h != hits || p != protected || f != frozen) {
|
||||||
this.type = t;
|
this.type = t;
|
||||||
this.hits = h;
|
this.hits = h;
|
||||||
|
this.protected = p;
|
||||||
|
this.frozen = f;
|
||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
tankView.playing = (value.mx !=0 || value.my != 0);
|
tankView.playing = !value.freezing.active && (value.mx !=0 || value.my != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
override public function dispose():Void {
|
override public function dispose():Void {
|
||||||
@@ -208,9 +261,34 @@ class BulletItem extends BitmapItem<Bullet> {
|
|||||||
|
|
||||||
class EagleItem extends BitmapItem<Eagle> {
|
class EagleItem extends BitmapItem<Eagle> {
|
||||||
|
|
||||||
public var destoyed(default, default):Bool;
|
private var death:Bool;
|
||||||
|
|
||||||
|
override public function update():Void {
|
||||||
|
super.update();
|
||||||
|
var d = value.death;
|
||||||
|
if (d != death) {
|
||||||
|
death = d;
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override private function getImage():String {
|
override private function getImage():String {
|
||||||
return 'resources/images/eagle/eagle-${destoyed ? 1 : 0}.png';
|
return 'resources/image/eagle/eagle${value.death ? '-death' : ''}.png';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class BonusItem extends AnimateItem<Bonus> {
|
||||||
|
|
||||||
|
public function new(value:Bonus) {
|
||||||
|
super(value);
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
override public function redraw():Void {
|
||||||
|
var image = Assets.getBitmapData('resources/image/bonus/${value.bonusType}.png');
|
||||||
|
var empty = new BitmapData(image.width, image.height, true, 0x00000000);
|
||||||
|
view.frames = [for (i in 0...15) image].concat([for (i in 0...15) empty]);
|
||||||
|
view.playing = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,34 +9,70 @@ map:
|
|||||||
gridHeight: 26
|
gridHeight: 26
|
||||||
|
|
||||||
bricks:
|
bricks:
|
||||||
- {type: -1, layer: 2, armor: -1} # border
|
- {type: border, index: -1, layer: 2, armor: -1}
|
||||||
- {type: 0, layer: 0, armor: 0} # none
|
- {type: none, index: 0, layer: 0, armor: 0}
|
||||||
- {type: 1, layer: 0, armor: 0} # ace
|
- {type: ace, index: 1, layer: 0, armor: 0}
|
||||||
- {type: 2, layer: 3, armor: 0} # bush
|
- {type: bush, index: 2, layer: 3, armor: 0}
|
||||||
- {type: 3, layer: 1, armor: 0} # water
|
- {type: water, index: 3, layer: 1, armor: 0}
|
||||||
- {type: 4, layer: 2, armor: 2} # armor
|
- {type: armor, index: 4, layer: 2, armor: 2}
|
||||||
- {type: 5, layer: 2, armor: 1} # brick
|
- {type: brick, index: 5, layer: 2, armor: 1}
|
||||||
|
|
||||||
teams:
|
player:
|
||||||
- id: human
|
human: &human
|
||||||
spawnInterval: 0
|
control: human
|
||||||
|
life: 3
|
||||||
tanks:
|
tanks:
|
||||||
- {group: human, type: 0, rate: 1}
|
- {type: human0, rate: 1, protect: 5}
|
||||||
|
bot: &bot
|
||||||
|
control: bot
|
||||||
|
life: -1
|
||||||
|
tanks:
|
||||||
|
- {type: bot0, rate: 0.25, bonus: 0.25}
|
||||||
|
- {type: bot1, rate: 0.25, bonus: 0.25}
|
||||||
|
- {type: bot2, rate: 0.25, bonus: 0.25}
|
||||||
|
- {type: bot3, rate: 0.25, bonus: 0.25}
|
||||||
|
|
||||||
|
presets:
|
||||||
|
- id: player1
|
||||||
|
teams:
|
||||||
|
- id: human
|
||||||
|
life: -1
|
||||||
|
players:
|
||||||
|
- {<<: *human, index: 0, color: 0xF5C040, life: 3}
|
||||||
- id: bot
|
- id: bot
|
||||||
spawnInterval: 3000
|
spawnInterval: 3000
|
||||||
tanks:
|
life: 20
|
||||||
- {group: bot, type: 0, rate: 0.5}
|
players:
|
||||||
- {group: bot, type: 1, rate: 0.5}
|
- {<<: *bot, index: 0}
|
||||||
- {group: bot, type: 2, rate: 0.5}
|
- {<<: *bot, index: 1}
|
||||||
- {group: bot, type: 3, rate: 0.5}
|
- {<<: *bot, index: 2}
|
||||||
|
- {<<: *bot, index: 3}
|
||||||
|
|
||||||
|
- id: player2
|
||||||
|
teams:
|
||||||
|
- id: human
|
||||||
|
life: -1
|
||||||
|
players:
|
||||||
|
- {<<: *human, index: 0, color: 0xF5C040, life: 3}
|
||||||
|
- {<<: *human, index: 1, color: 0x15C040, life: 3}
|
||||||
|
- id: bot
|
||||||
|
spawnInterval: 3000
|
||||||
|
life: 20
|
||||||
|
players:
|
||||||
|
- {<<: *bot, index: 0}
|
||||||
|
- {<<: *bot, index: 1}
|
||||||
|
- {<<: *bot, index: 2}
|
||||||
|
- {<<: *bot, index: 3}
|
||||||
|
- {<<: *bot, index: 4}
|
||||||
|
- {<<: *bot, index: 5}
|
||||||
|
|
||||||
points:
|
points:
|
||||||
- {team: human, type: eagle, index: -1, direction: right, x: 12, y: 24}
|
- {team: human, type: eagle, index: -1, direction: right, x: 12, y: 24}
|
||||||
- {team: human, type: tank, index: 0, direction: top, x: 8, y: 24}
|
- {team: human, type: tank, index: 0, direction: top, x: 8, y: 24}
|
||||||
- {team: human, type: tank, index: 1, direction: top, x: 16, y: 24}
|
- {team: human, type: tank, index: 1, direction: top, x: 16, y: 24}
|
||||||
- {team: bot, type: tank, index: -1, direction: bottom, x: 0, y: 0}
|
- {team: bot, type: tank, index: -1, direction: bottom, x: 0, y: 0}
|
||||||
- {team: bot, type: tank, index: -1, direction: bottom, x: 12, y: 0}
|
- {team: bot, type: tank, index: -2, direction: bottom, x: 12, y: 0}
|
||||||
- {team: bot, type: tank, index: -1, direction: bottom, x: 24, y: 0}
|
- {team: bot, type: tank, index: -3, direction: bottom, x: 24, y: 0}
|
||||||
|
|
||||||
bullet: &bullet
|
bullet: &bullet
|
||||||
width: 12
|
width: 12
|
||||||
@@ -45,8 +81,8 @@ bullet: &bullet
|
|||||||
piercing: 1
|
piercing: 1
|
||||||
|
|
||||||
tanks:
|
tanks:
|
||||||
human:
|
- type: human0
|
||||||
- type: 0
|
upgrade: human1
|
||||||
width: 36
|
width: 36
|
||||||
height: 36
|
height: 36
|
||||||
speed: 2.5
|
speed: 2.5
|
||||||
@@ -54,8 +90,10 @@ tanks:
|
|||||||
<<: *bullet
|
<<: *bullet
|
||||||
speed: 8.0
|
speed: 8.0
|
||||||
bullets: 1
|
bullets: 1
|
||||||
|
skin: pa
|
||||||
|
|
||||||
- type: 1
|
- type: human1
|
||||||
|
upgrade: human2
|
||||||
width: 40
|
width: 40
|
||||||
height: 36
|
height: 36
|
||||||
speed: 3.0
|
speed: 3.0
|
||||||
@@ -63,8 +101,10 @@ tanks:
|
|||||||
<<: *bullet
|
<<: *bullet
|
||||||
speed: 8.5
|
speed: 8.5
|
||||||
bullets: 1
|
bullets: 1
|
||||||
|
skin: pb
|
||||||
|
|
||||||
- type: 2
|
- type: human2
|
||||||
|
upgrade: human3
|
||||||
width: 40
|
width: 40
|
||||||
height: 36
|
height: 36
|
||||||
speed: 3.0
|
speed: 3.0
|
||||||
@@ -72,8 +112,10 @@ tanks:
|
|||||||
<<: *bullet
|
<<: *bullet
|
||||||
speed: 9.0
|
speed: 9.0
|
||||||
bullets: 2
|
bullets: 2
|
||||||
|
skin: pc
|
||||||
|
|
||||||
- type: 3
|
- type: human3
|
||||||
|
upgrade: human3
|
||||||
width: 42
|
width: 42
|
||||||
height: 38
|
height: 38
|
||||||
speed: 2.9
|
speed: 2.9
|
||||||
@@ -82,9 +124,10 @@ tanks:
|
|||||||
speed: 9.0
|
speed: 9.0
|
||||||
piercing: 3
|
piercing: 3
|
||||||
bullets: 2
|
bullets: 2
|
||||||
|
hits: 1
|
||||||
|
skin: pd
|
||||||
|
|
||||||
bot:
|
- type: bot0
|
||||||
- type: 0
|
|
||||||
width: 38
|
width: 38
|
||||||
height: 36
|
height: 36
|
||||||
speed: 2.0
|
speed: 2.0
|
||||||
@@ -93,8 +136,9 @@ tanks:
|
|||||||
speed: 7.0
|
speed: 7.0
|
||||||
bullets: 1
|
bullets: 1
|
||||||
score: 100
|
score: 100
|
||||||
|
skin: ba
|
||||||
|
|
||||||
- type: 1
|
- type: bot1
|
||||||
width: 40
|
width: 40
|
||||||
height: 36
|
height: 36
|
||||||
speed: 4.0
|
speed: 4.0
|
||||||
@@ -103,8 +147,9 @@ tanks:
|
|||||||
speed: 7.0
|
speed: 7.0
|
||||||
bullets: 1
|
bullets: 1
|
||||||
score: 200
|
score: 200
|
||||||
|
skin: bb
|
||||||
|
|
||||||
- type: 2
|
- type: bot2
|
||||||
width: 38
|
width: 38
|
||||||
height: 36
|
height: 36
|
||||||
speed: 2.0
|
speed: 2.0
|
||||||
@@ -113,8 +158,9 @@ tanks:
|
|||||||
speed: 9.0
|
speed: 9.0
|
||||||
bullets: 1
|
bullets: 1
|
||||||
score: 300
|
score: 300
|
||||||
|
skin: bc
|
||||||
|
|
||||||
- type: 3
|
- type: bot3
|
||||||
width: 40
|
width: 40
|
||||||
height: 36
|
height: 36
|
||||||
speed: 1.8
|
speed: 1.8
|
||||||
@@ -124,3 +170,12 @@ tanks:
|
|||||||
bullets: 1
|
bullets: 1
|
||||||
score: 400
|
score: 400
|
||||||
hits: 3
|
hits: 3
|
||||||
|
skin: bd
|
||||||
|
|
||||||
|
bonuses:
|
||||||
|
- {type: clock}
|
||||||
|
- {type: grenade}
|
||||||
|
- {type: helmet}
|
||||||
|
- {type: life}
|
||||||
|
- {type: shovel}
|
||||||
|
- {type: star}
|
||||||
|
|||||||
@@ -1,95 +0,0 @@
|
|||||||
[keyboard]
|
|
||||||
reset = 27 ;Escape
|
|
||||||
pause = 80 ;P
|
|
||||||
|
|
||||||
[player0]
|
|
||||||
key_left = 37 ;Left
|
|
||||||
key_up = 38 ;Up
|
|
||||||
key_right = 39 ;Rigth
|
|
||||||
key_down = 40 ;Down
|
|
||||||
key_shot = 96 ;Num0
|
|
||||||
|
|
||||||
[player1]
|
|
||||||
key_left = 65 ;A
|
|
||||||
key_up = 87 ;W
|
|
||||||
key_right = 68 ;D
|
|
||||||
key_down = 83 ;S
|
|
||||||
key_shot = 32 ;Space
|
|
||||||
|
|
||||||
[bonus]
|
|
||||||
score = 500
|
|
||||||
freeztime = 10
|
|
||||||
eagletime = 20
|
|
||||||
protecttime = 15
|
|
||||||
|
|
||||||
[bots]
|
|
||||||
count = 20 ;количество ботов на уровне
|
|
||||||
respawntime = 2.5 ;задержка между появлением ботов в секундах
|
|
||||||
shotdelay = 1.0 ;задержка между выстрелами
|
|
||||||
turndelay = 0.3 ;задержка перед поворотом при столкновении
|
|
||||||
rndturndelay = 2.0 ;задержка перед случайным поворотом
|
|
||||||
turntoeagle = 0.75 ;вероятность поворота к Орлу
|
|
||||||
bonus = 0.25 ;вероятность появления бонусного танка
|
|
||||||
|
|
||||||
|
|
||||||
[tank_p0]
|
|
||||||
movespeed = 2.5 ;скорость передвижения
|
|
||||||
bulletspeed = 8.0 ;скорость полёта снаряда
|
|
||||||
bullettype = 0 ;тип снаряда (0 - обычный, 1 - бронебойный)
|
|
||||||
bulletcount = 1 ;количество снарядов
|
|
||||||
hits = 1 ;количество хитпойнтов
|
|
||||||
|
|
||||||
[tank_p1]
|
|
||||||
movespeed = 3.0
|
|
||||||
bulletspeed = 8.5
|
|
||||||
bullettype = 0
|
|
||||||
bulletcount = 1
|
|
||||||
hits = 1
|
|
||||||
|
|
||||||
[tank_p2]
|
|
||||||
movespeed = 3.0
|
|
||||||
bulletspeed = 9.0
|
|
||||||
bullettype = 0
|
|
||||||
bulletcount = 2
|
|
||||||
hits = 1
|
|
||||||
|
|
||||||
[tank_p3]
|
|
||||||
movespeed = 2.9
|
|
||||||
bulletspeed = 9.0
|
|
||||||
bullettype = 1
|
|
||||||
bulletcount = 2
|
|
||||||
hits = 2
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[tank_b0]
|
|
||||||
movespeed = 2.0
|
|
||||||
bulletspeed = 7.0
|
|
||||||
bullettype = 0
|
|
||||||
bulletcount = 1
|
|
||||||
hits = 1
|
|
||||||
score = 100
|
|
||||||
|
|
||||||
[tank_b1]
|
|
||||||
movespeed = 4.0
|
|
||||||
bulletspeed = 7.0
|
|
||||||
bullettype = 0
|
|
||||||
bulletcount = 1
|
|
||||||
hits = 1
|
|
||||||
score = 200
|
|
||||||
|
|
||||||
[tank_b2]
|
|
||||||
movespeed = 2.0
|
|
||||||
bulletspeed = 9.0
|
|
||||||
bullettype = 0
|
|
||||||
bulletcount = 1
|
|
||||||
hits = 1
|
|
||||||
score = 300
|
|
||||||
|
|
||||||
[tank_b3]
|
|
||||||
movespeed = 1.8
|
|
||||||
bulletspeed = 8.0
|
|
||||||
bullettype = 0
|
|
||||||
bulletcount = 1
|
|
||||||
hits = 4
|
|
||||||
score = 400
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
game:
|
game:
|
||||||
levels: 3
|
levels: 8
|
||||||
friendlyFire: true
|
friendlyFire: true
|
||||||
|
|
||||||
map:
|
map:
|
||||||
@@ -9,27 +9,90 @@ map:
|
|||||||
gridHeight: 30
|
gridHeight: 30
|
||||||
|
|
||||||
bricks:
|
bricks:
|
||||||
- {type: -1, layer: 2, armor: -1} # border
|
- {type: border, index: -1, layer: 2, armor: -1}
|
||||||
- {type: 0, layer: 0, armor: 0} # none
|
- {type: none, index: 0, layer: 0, armor: 0}
|
||||||
- {type: 1, layer: 0, armor: 0} # ace
|
- {type: ace, index: 1, layer: 0, armor: 0}
|
||||||
- {type: 2, layer: 3, armor: 0} # bush
|
- {type: bush, index: 2, layer: 3, armor: 0}
|
||||||
- {type: 3, layer: 1, armor: 0} # water
|
- {type: water, index: 3, layer: 1, armor: 0}
|
||||||
- {type: 4, layer: 2, armor: 2} # armor
|
- {type: armor, index: 4, layer: 2, armor: 2}
|
||||||
- {type: 5, layer: 2, armor: 1} # brick
|
- {type: brick, index: 5, layer: 2, armor: 1}
|
||||||
|
|
||||||
team_tanks: &team_tanks
|
team:
|
||||||
tanks:
|
radiant: &radiant
|
||||||
- {group: any, type: 0, rate: 0.25}
|
|
||||||
- {group: any, type: 1, rate: 0.25}
|
|
||||||
- {group: any, type: 2, rate: 0.25}
|
|
||||||
|
|
||||||
teams:
|
|
||||||
- <<: *team_tanks
|
|
||||||
id: radiant
|
id: radiant
|
||||||
spawnInterval: 0
|
color: 0xff4422
|
||||||
- <<: *team_tanks
|
life: 20
|
||||||
|
dire: &dire
|
||||||
id: dire
|
id: dire
|
||||||
spawnInterval: 0
|
color: 0x2244ff
|
||||||
|
life: 20
|
||||||
|
|
||||||
|
player: &player
|
||||||
|
life: -1
|
||||||
|
control: bot
|
||||||
|
tanks:
|
||||||
|
- {type: slow, rate: 0.5, protect: 3, bonus: 0}
|
||||||
|
- {type: fast, rate: 0.5, protect: 3, bonus: 0}
|
||||||
|
|
||||||
|
human1: &human1
|
||||||
|
<<: *player
|
||||||
|
control: human
|
||||||
|
color: 0xf055a0
|
||||||
|
|
||||||
|
human2: &human2
|
||||||
|
<<: *player
|
||||||
|
control: human
|
||||||
|
color: 0xa055f0
|
||||||
|
|
||||||
|
presets:
|
||||||
|
- id: player1
|
||||||
|
teams:
|
||||||
|
- <<: *radiant
|
||||||
|
players:
|
||||||
|
- {<<: *human1, index: 0}
|
||||||
|
- {<<: *player, index: 1}
|
||||||
|
- {<<: *player, index: 2}
|
||||||
|
- {<<: *player, index: 3}
|
||||||
|
- {<<: *player, index: 4}
|
||||||
|
- <<: *dire
|
||||||
|
players:
|
||||||
|
- {<<: *player, index: 0}
|
||||||
|
- {<<: *player, index: 1}
|
||||||
|
- {<<: *player, index: 2}
|
||||||
|
- {<<: *player, index: 3}
|
||||||
|
- {<<: *player, index: 4}
|
||||||
|
- id: player2_coop
|
||||||
|
teams:
|
||||||
|
- <<: *radiant
|
||||||
|
players:
|
||||||
|
- {<<: *human1, index: 0}
|
||||||
|
- {<<: *human1, index: 1}
|
||||||
|
- {<<: *player, index: 2}
|
||||||
|
- {<<: *player, index: 3}
|
||||||
|
- {<<: *player, index: 4}
|
||||||
|
- <<: *dire
|
||||||
|
players:
|
||||||
|
- {<<: *player, index: 0}
|
||||||
|
- {<<: *player, index: 1}
|
||||||
|
- {<<: *player, index: 2}
|
||||||
|
- {<<: *player, index: 3}
|
||||||
|
- {<<: *player, index: 4}
|
||||||
|
- id: player2_vs
|
||||||
|
teams:
|
||||||
|
- <<: *radiant
|
||||||
|
players:
|
||||||
|
- {<<: *human1, index: 0}
|
||||||
|
- {<<: *player, index: 1}
|
||||||
|
- {<<: *player, index: 2}
|
||||||
|
- {<<: *player, index: 3}
|
||||||
|
- {<<: *player, index: 4}
|
||||||
|
- <<: *dire
|
||||||
|
players:
|
||||||
|
- {<<: *human2, index: 0}
|
||||||
|
- {<<: *player, index: 1}
|
||||||
|
- {<<: *player, index: 2}
|
||||||
|
- {<<: *player, index: 3}
|
||||||
|
- {<<: *player, index: 4}
|
||||||
|
|
||||||
points:
|
points:
|
||||||
- {team: radiant, type: eagle, index: -1, direction: right, x: 0, y: 28}
|
- {team: radiant, type: eagle, index: -1, direction: right, x: 0, y: 28}
|
||||||
@@ -52,40 +115,30 @@ bullet: &bullet
|
|||||||
piercing: 1
|
piercing: 1
|
||||||
|
|
||||||
tanks:
|
tanks:
|
||||||
any:
|
- type: slow
|
||||||
- type: 0
|
width: 38
|
||||||
width: 36
|
|
||||||
height: 36
|
height: 36
|
||||||
speed: 2.5
|
speed: 2.3
|
||||||
|
bullet:
|
||||||
|
<<: *bullet
|
||||||
|
speed: 12.0
|
||||||
|
bullets: 1
|
||||||
|
skin: bc
|
||||||
|
|
||||||
|
- type: fast
|
||||||
|
width: 40
|
||||||
|
height: 36
|
||||||
|
speed: 4.0
|
||||||
bullet:
|
bullet:
|
||||||
<<: *bullet
|
<<: *bullet
|
||||||
speed: 8.0
|
speed: 8.0
|
||||||
bullets: 1
|
bullets: 1
|
||||||
|
skin: bb
|
||||||
|
|
||||||
- type: 1
|
bonuses:
|
||||||
width: 40
|
- {type: clock}
|
||||||
height: 36
|
- {type: grenade}
|
||||||
speed: 3.0
|
- {type: helmet}
|
||||||
bullet:
|
- {type: life}
|
||||||
<<: *bullet
|
- {type: shovel}
|
||||||
speed: 8.5
|
- {type: star}
|
||||||
bullets: 1
|
|
||||||
|
|
||||||
- type: 2
|
|
||||||
width: 40
|
|
||||||
height: 36
|
|
||||||
speed: 3.0
|
|
||||||
bullet:
|
|
||||||
<<: *bullet
|
|
||||||
speed: 9.0
|
|
||||||
bullets: 2
|
|
||||||
|
|
||||||
- type: 3
|
|
||||||
width: 42
|
|
||||||
height: 38
|
|
||||||
speed: 2.9
|
|
||||||
bullet:
|
|
||||||
<<: *bullet
|
|
||||||
speed: 9.0
|
|
||||||
piercing: 3
|
|
||||||
bullets: 2
|
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
000044000000000000000000005500004400550000004400000000000000000000550000440055000000440000004400003333000055000044005555000044000000440000333300005500004400555500004422442244000000000000550000440000000000442244224400000000000055000044000000000000000000444444555544444400442200330000000000000044444455554444440044220033005555333333554422220000222244000022003300555533333355442222000022224400002200330000000000000044220000000022440000440033000000000000004422000000002244000044003300000000000000550000555500005500002200000000000000000055000055550000550000220000004444444400005500445555440055000044444444444444440000550044555544005500004444444400000022000055000055550000550000000000000000002200005500005555000055000000000000003300440000442200000000224400000000000000330044000044220000000022440000000000000033002200004422220000222244553333335555003300220000442222000022224455333333555500330022440044444455554444440000000000000033002244004444445555444444000000000000000000440000550000000000004422442244000000000044000055000000000000442244224400005555004400005500003333000044000000440000555500440000550000333300004400000044000000550044000055000000000000000000004400000055004400005500000000000000000000440000
|
points: [{index: -1, team: radiant, x: 0, direction: right, type: eagle, y: 28}, {index: 0, team: radiant, x: 0, direction: right, type: tank, y: 0}, {index: 1, team: radiant, x: 6, direction: right, type: tank, y: 10}, {index: 2, team: radiant, x: 6, direction: right, type: tank, y: 16}, {index: 3, team: radiant, x: 6, direction: right, type: tank, y: 22}, {index: 4, team: radiant, x: 10, direction: right, type: tank, y: 28}, {index: -1, team: dire, x: 38, direction: right, type: eagle, y: 0}, {index: 0, team: dire, x: 38, direction: left, type: tank, y: 28}, {index: 1, team: dire, x: 32, direction: left, type: tank, y: 18}, {index: 2, team: dire, x: 32, direction: left, type: tank, y: 12}, {index: 3, team: dire, x: 32, direction: left, type: tank, y: 6}, {index: 4, team: dire, x: 28, direction: left, type: tank, y: 0}]
|
||||||
|
data: "000044000000000000000000005500004400550000004400000000000000000000550000440055000000440000004400003333000055000044005555000044000000440000333300005500004400555500004422442244000000000000550000440000000000442244224400000000000055000044000000000000000000444444555544444400442200330000000000000044444455554444440044220033005555333333554422220000222244000022003300555533333355442222000022224400002200330000000000000044220000000022440000440033000000000000004422000000002244000044003300000000000000550000555500005500002200000000000000000055000055550000550000220000004444444400005500445555440055000044444444444444440000550044555544005500004444444400000022000055000055550000550000000000000000002200005500005555000055000000000000003300440000442200000000224400000000000000330044000044220000000022440000000000000033002200004422220000222244553333335555003300220000442222000022224455333333555500330022440044444455554444440000000000000033002244004444445555444444000000000000000000440000550000000000004422442244000000000044000055000000000000442244224400005555004400005500003333000044000000440000555500440000550000333300004400000044000000550044000055000000000000000000004400000055004400005500000000000000000000440000"
|
||||||
|
|||||||
2
src/client/resources/dota/levels/level003.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
points: [{index: -1, direction: right, team: radiant, x: 24, type: eagle, y: 26}, {index: 0, direction: right, team: radiant, x: 14, type: tank, y: 26}, {index: 1, direction: right, team: radiant, x: 20, type: tank, y: 20}, {index: 2, direction: right, team: radiant, x: 26, type: tank, y: 20}, {index: 3, direction: right, team: radiant, x: 34, type: tank, y: 24}, {index: 4, direction: right, team: radiant, x: 38, type: tank, y: 22}, {index: -1, direction: right, team: dire, x: 22, type: eagle, y: 2}, {index: 0, direction: left, team: dire, x: 8, type: tank, y: 2}, {index: 1, direction: left, team: dire, x: 12, type: tank, y: 6}, {index: 2, direction: left, team: dire, x: 20, type: tank, y: 6}, {index: 3, direction: left, team: dire, x: 21, type: tank, y: 10}, {index: 4, direction: left, team: dire, x: 28, type: tank, y: 4}]
|
||||||
|
data: "444444444400000000440000004444000000000044444444440000000044000000444400000000004444440000004444004400000044440033444400444444000000444400440000004444003344440000000000440000440044000000000000000000000000000044000044004400000000000000000000003344004400000000000044004444440000444400334400440000000000004400444444000044440000000000004400444444440033440000005544000000000000440044444444003344000000554444004433440044444400000000004400440000004400443344004444440000000000440044000000440000000000004444004444440044004444440044000000000000444400444444004400444444000000440055440044440044440000000055444400000044005544004444004444000000005544440000444400444400000000000000443300000000000044440044440000000000000044330000000000000044004444003300444444004444004433004400004400444400330044444400444400443300444400000000000033000000000000000044000000440000000000003300000000000000004400000044440044004444444400444444440000440044004444004400444444440044444444000044004400000000000000440000000000000000000000440000000000000044000000000000000000000044004455003344000000440044000000440033444400445500334400000044004400000044003344440044440000000044000000440000004400000000004444000000004400000044000000440000000000"
|
||||||
2
src/client/resources/dota/levels/level004.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
points: [{index: -1, direction: right, team: radiant, x: 12, type: eagle, y: 2}, {index: 0, direction: right, team: radiant, x: 6, type: tank, y: 6}, {index: 1, direction: right, team: radiant, x: 10, type: tank, y: 10}, {index: 2, direction: right, team: radiant, x: 14, type: tank, y: 10}, {index: 3, direction: right, team: radiant, x: 18, type: tank, y: 6}, {index: 4, direction: right, team: radiant, x: 20, type: tank, y: 2}, {index: -1, direction: right, team: dire, x: 22, type: eagle, y: 26}, {index: 0, direction: left, team: dire, x: 12, type: tank, y: 26}, {index: 1, direction: left, team: dire, x: 18, type: tank, y: 22}, {index: 2, direction: left, team: dire, x: 24, type: tank, y: 22}, {index: 3, direction: left, team: dire, x: 28, type: tank, y: 18}, {index: 4, direction: left, team: dire, x: 30, type: tank, y: 10}]
|
||||||
|
data: "000000000033333300000000000000000000000000000000003333330000000000000000000000000000004400330033004400000000003300000044000000440033003300440000000000330000004400000000003333330000000044440000000000000000000000333333000000004444000000000000000000000000000000003300000000004444000000000000000000000000330000000000444400000044000000004400000000004400000044000000004400000000440000000000440000004400000000000033000000000000004444000000000000000000003300000000000000444400000000000000000000000000330000440000000033000000000000000000000033000044000000003300000000000000000000000000444400004400000000000000000000000000000044440000440000000000000000000000334444004444000000000044000000000000000033444400444400000000004400000000004400000044000000000000330000440000000000440000004400000000000033000044000000000000440000000000330000440000000000000033000044000000000033000044000000000000003300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044000000003333330000000033000000000000004400000000333333000000003300000000000000000000440033003300440000000000000000000000000044003300330044000000000000000000000000000000333333000000000000000000000000000000000033333300000000000000"
|
||||||
2
src/client/resources/dota/levels/level005.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
points: [{index: -1, direction: right, team: radiant, x: 19, type: eagle, y: 28}, {index: 0, direction: right, team: radiant, x: 0, type: tank, y: 28}, {index: 1, direction: right, team: radiant, x: 10, type: tank, y: 22}, {index: 2, direction: right, team: radiant, x: 19, type: tank, y: 18}, {index: 3, direction: right, team: radiant, x: 28, type: tank, y: 22}, {index: 4, direction: right, team: radiant, x: 38, type: tank, y: 28}, {index: -1, direction: right, team: dire, x: 19, type: eagle, y: 0}, {index: 0, direction: left, team: dire, x: 0, type: tank, y: 0}, {index: 1, direction: left, team: dire, x: 10, type: tank, y: 6}, {index: 2, direction: left, team: dire, x: 19, type: tank, y: 10}, {index: 3, direction: left, team: dire, x: 28, type: tank, y: 6}, {index: 4, direction: left, team: dire, x: 38, type: tank, y: 0}]
|
||||||
|
data: "000000000000440000000000004400000000000000000000000044000000000000440000000000004400000000000000000440000000000000000044440000000000000000044000000000000000004400000000005555555555555555555500000000000000000000555555555555555555550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000550000000000000000000000000000000000000055000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004400000000000000000000440000000000000000440000000000000000000044000000005555555544333333333553333333334455555555555555554433333333355333333333445555555500000000440000000000000000000044000000000000000044000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000550000000000000000000000000000000000000055000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000055555555555555555555000000000000000000005555555555555555555500000000004400000000000000000440000000000000000044440000000000000000044000000000000000004400000000000044000000000000440000000000000000000000004400000000000044000000000000"
|
||||||
2
src/client/resources/dota/levels/level006.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
points: [{index: -1, direction: right, team: radiant, x: 19, type: eagle, y: 28}, {index: 0, direction: right, team: radiant, x: 2, type: tank, y: 22}, {index: 1, direction: right, team: radiant, x: 9, type: tank, y: 20}, {index: 2, direction: right, team: radiant, x: 19, type: tank, y: 24}, {index: 3, direction: right, team: radiant, x: 29, type: tank, y: 20}, {index: 4, direction: right, team: radiant, x: 36, type: tank, y: 22}, {index: -1, direction: right, team: dire, x: 19, type: eagle, y: 0}, {index: 0, direction: left, team: dire, x: 2, type: tank, y: 6}, {index: 1, direction: left, team: dire, x: 9, type: tank, y: 8}, {index: 2, direction: left, team: dire, x: 19, type: tank, y: 4}, {index: 3, direction: left, team: dire, x: 29, type: tank, y: 8}, {index: 4, direction: left, team: dire, x: 36, type: tank, y: 6}]
|
||||||
|
data: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005555555544444455555555000000000000000000555555554444445555555500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005500000000000000550000000000000000000000550000000000000055000000000000000000000055000000000000005500000000000000000000005500000000000000550000000000000000000000000044000000440000000000000000000000000000004400000044000000000000000333333333333333445500004433333333333333333333333333333344550000443333333333333333333333333333334400440044333333333333333333333333333333440044004433333333333333333333333333333344000055443333333333333333333333333333334400005544333333333333333000000000000000440000004400000000000000000000000000000044000000440000000000000000000000000055000000000000005500000000000000000000005500000000000000550000000000000000000000550000000000000055000000000000000000000055000000000000005500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005555555544444455555555000000000000000000555555554444445555555500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
||||||
2
src/client/resources/dota/levels/level007.txt
Normal file
@@ -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}]
|
||||||
|
Before Width: | Height: | Size: 450 B After Width: | Height: | Size: 450 B |
|
Before Width: | Height: | Size: 566 B After Width: | Height: | Size: 566 B |
|
Before Width: | Height: | Size: 354 B After Width: | Height: | Size: 354 B |
|
Before Width: | Height: | Size: 541 B After Width: | Height: | Size: 541 B |
|
Before Width: | Height: | Size: 455 B After Width: | Height: | Size: 455 B |
|
Before Width: | Height: | Size: 532 B After Width: | Height: | Size: 532 B |
|
Before Width: | Height: | Size: 374 B After Width: | Height: | Size: 374 B |
|
Before Width: | Height: | Size: 737 B After Width: | Height: | Size: 737 B |
|
Before Width: | Height: | Size: 307 B After Width: | Height: | Size: 307 B |
|
Before Width: | Height: | Size: 304 B After Width: | Height: | Size: 304 B |
|
Before Width: | Height: | Size: 279 B After Width: | Height: | Size: 279 B |
|
Before Width: | Height: | Size: 969 B After Width: | Height: | Size: 969 B |
|
Before Width: | Height: | Size: 93 B After Width: | Height: | Size: 93 B |
|
Before Width: | Height: | Size: 598 B After Width: | Height: | Size: 598 B |
|
Before Width: | Height: | Size: 531 B After Width: | Height: | Size: 531 B |
|
Before Width: | Height: | Size: 598 B After Width: | Height: | Size: 598 B |
BIN
src/client/resources/image/tank/ba-0.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
src/client/resources/image/tank/ba-1.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
src/client/resources/image/tank/bb-0.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
src/client/resources/image/tank/bb-1.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
src/client/resources/image/tank/bc-0.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
src/client/resources/image/tank/bc-1.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
src/client/resources/image/tank/bd-0.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
src/client/resources/image/tank/bd-1.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
src/client/resources/image/tank/pa-0.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
src/client/resources/image/tank/pa-1.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
src/client/resources/image/tank/pb-0.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
src/client/resources/image/tank/pb-1.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
src/client/resources/image/tank/pc-0.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
src/client/resources/image/tank/pc-1.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
src/client/resources/image/tank/pd-0.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
src/client/resources/image/tank/pd-1.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 590 B |
@@ -1,20 +1,22 @@
|
|||||||
package ru.m.tankz;
|
package ru.m.tankz;
|
||||||
|
|
||||||
import ru.m.tankz.proto.pack.LeaveGameRequest;
|
|
||||||
import ru.m.tankz.proto.pack.LeaveGameResponse;
|
|
||||||
import ru.m.tankz.proto.pack.GameUpdateResponse;
|
|
||||||
import ru.m.tankz.proto.pack.GameActionRequest;
|
|
||||||
import ru.m.connect.IConnection;
|
|
||||||
import protohx.Message;
|
import protohx.Message;
|
||||||
import ru.m.tankz.proto.pack.ErrorResponse;
|
import ru.m.connect.IConnection;
|
||||||
import ru.m.tankz.proto.pack.GameListRequest;
|
|
||||||
import ru.m.tankz.proto.pack.GameListResponse;
|
|
||||||
import ru.m.tankz.proto.pack.CreateGameRequest;
|
import ru.m.tankz.proto.pack.CreateGameRequest;
|
||||||
import ru.m.tankz.proto.pack.CreateGameResponse;
|
import ru.m.tankz.proto.pack.CreateGameResponse;
|
||||||
|
import ru.m.tankz.proto.pack.ErrorResponse;
|
||||||
|
import ru.m.tankz.proto.pack.GameActionRequest;
|
||||||
|
import ru.m.tankz.proto.pack.GameListRequest;
|
||||||
|
import ru.m.tankz.proto.pack.GameListResponse;
|
||||||
|
import ru.m.tankz.proto.pack.GameUpdateResponse;
|
||||||
import ru.m.tankz.proto.pack.JoinGameRequest;
|
import ru.m.tankz.proto.pack.JoinGameRequest;
|
||||||
import ru.m.tankz.proto.pack.JoinGameResponse;
|
import ru.m.tankz.proto.pack.JoinGameResponse;
|
||||||
|
import ru.m.tankz.proto.pack.LeaveGameRequest;
|
||||||
|
import ru.m.tankz.proto.pack.LeaveGameResponse;
|
||||||
import ru.m.tankz.proto.pack.StartGameRequest;
|
import ru.m.tankz.proto.pack.StartGameRequest;
|
||||||
import ru.m.tankz.proto.pack.StartGameResponse;
|
import ru.m.tankz.proto.pack.StartGameResponse;
|
||||||
|
import Type;
|
||||||
|
|
||||||
|
|
||||||
class PacketBuilder implements IPacketBuilder {
|
class PacketBuilder implements IPacketBuilder {
|
||||||
|
|
||||||
|
|||||||
23
src/common/haxe/ru/m/tankz/Type.hx
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package ru.m.tankz;
|
||||||
|
|
||||||
|
|
||||||
|
typedef Type = Dynamic;
|
||||||
|
|
||||||
|
typedef GameType = String;
|
||||||
|
|
||||||
|
typedef TeamId = String;
|
||||||
|
|
||||||
|
typedef ControlType = String;
|
||||||
|
|
||||||
|
typedef BrickType = String;
|
||||||
|
|
||||||
|
typedef TankType = String;
|
||||||
|
|
||||||
|
typedef BonusType = String;
|
||||||
|
|
||||||
|
typedef PlayerId = {
|
||||||
|
var team:TeamId;
|
||||||
|
var index:Int;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef PresetId = String;
|
||||||
@@ -1,17 +1,56 @@
|
|||||||
package ru.m.tankz.bot;
|
package ru.m.tankz.bot;
|
||||||
|
|
||||||
import ru.m.tankz.game.Game;
|
|
||||||
import ru.m.tankz.core.EntityType;
|
|
||||||
import ru.m.tankz.control.Control;
|
|
||||||
import ru.m.geom.Direction;
|
|
||||||
import haxe.Timer;
|
import haxe.Timer;
|
||||||
|
import ru.m.geom.Direction;
|
||||||
|
import ru.m.tankz.control.Control;
|
||||||
|
import ru.m.tankz.core.Eagle;
|
||||||
|
import ru.m.tankz.core.Entity;
|
||||||
|
import ru.m.tankz.core.EntityType;
|
||||||
|
import ru.m.tankz.core.Tank;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
|
||||||
|
class BotHelper {
|
||||||
|
|
||||||
|
public static function findEagle(team:TeamId, handler:ControlHandler):Null<Eagle> {
|
||||||
|
for (entity in handler.entities) {
|
||||||
|
switch (EntityTypeResolver.of(entity)) {
|
||||||
|
case EntityType.EAGLE(eagle):
|
||||||
|
if (eagle.team != team) {
|
||||||
|
return eagle;
|
||||||
|
}
|
||||||
|
case x:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getDirectionTo(entity:Entity, target:Entity):Direction {
|
||||||
|
var x:Float = target.rect.x - entity.rect.x;
|
||||||
|
var y:Float = target.rect.y - entity.rect.y;
|
||||||
|
var xD:Direction = Direction.from(Std.int(x / Math.abs(x)), 0);
|
||||||
|
var yD:Direction = Direction.from(0, Std.int(y / Math.abs(y)));
|
||||||
|
if (entity.rect.direction == xD) return yD;
|
||||||
|
if (entity.rect.direction == yD) return xD;
|
||||||
|
return Math.abs(x) > Math.abs(y) ? xD : yD;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function randomDirection():Direction {
|
||||||
|
return [
|
||||||
|
Direction.TOP,
|
||||||
|
Direction.BOTTOM,
|
||||||
|
Direction.LEFT,
|
||||||
|
Direction.RIGHT,
|
||||||
|
][Math.floor(Math.random() * 4)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class BotControl extends Control {
|
class BotControl extends Control {
|
||||||
|
|
||||||
private var shotTimer:Timer;
|
private var shotTimer:Timer;
|
||||||
private var turnRandomTimer:Timer;
|
private var turnRandomTimer:Timer;
|
||||||
private var turnTimer:Timer;
|
private var turnTimer:Timer;
|
||||||
|
private var tank(get, null):Tank;
|
||||||
|
|
||||||
public function new(playerId:PlayerId) {
|
public function new(playerId:PlayerId) {
|
||||||
super(playerId);
|
super(playerId);
|
||||||
@@ -27,7 +66,6 @@ class BotControl extends Control {
|
|||||||
|
|
||||||
override public function start():Void {
|
override public function start():Void {
|
||||||
if (handler == null) return;
|
if (handler == null) return;
|
||||||
var tank = handler.entities.get(tankId);
|
|
||||||
action(TankAction.MOVE(tank.rect.direction));
|
action(TankAction.MOVE(tank.rect.direction));
|
||||||
if (shotTimer == null) {
|
if (shotTimer == null) {
|
||||||
shotTimer = new Timer(1000);
|
shotTimer = new Timer(1000);
|
||||||
@@ -65,15 +103,17 @@ class BotControl extends Control {
|
|||||||
turnTimer.stop();
|
turnTimer.stop();
|
||||||
turnTimer = null;
|
turnTimer = null;
|
||||||
}
|
}
|
||||||
action(TankAction.MOVE(randomDirection()));
|
// ToDo:
|
||||||
|
if (handler == null || tank == null) return;
|
||||||
|
var eagle:Eagle = BotHelper.findEagle(playerId.team, handler);
|
||||||
|
if (eagle != null && Math.random() > 0.25) {
|
||||||
|
action(TankAction.MOVE(BotHelper.getDirectionTo(tank, eagle)));
|
||||||
|
} else {
|
||||||
|
action(TankAction.MOVE(BotHelper.randomDirection()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function randomDirection():Direction {
|
private function get_tank():Tank {
|
||||||
return [
|
return cast handler.entities[tankId];
|
||||||
Direction.TOP,
|
|
||||||
Direction.BOTTOM,
|
|
||||||
Direction.LEFT,
|
|
||||||
Direction.RIGHT,
|
|
||||||
][Math.floor(Math.random() * 4)];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package ru.m.tankz.config;
|
package ru.m.tankz.config;
|
||||||
|
|
||||||
|
import ru.m.draw.Color;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
|
||||||
typedef GameConfig = {
|
typedef GameConfig = {
|
||||||
var levels: Int;
|
var levels: Int;
|
||||||
@@ -7,7 +10,7 @@ typedef GameConfig = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
typedef SpawnPoint = {
|
typedef SpawnPoint = {
|
||||||
var team:String;
|
var team:TeamId;
|
||||||
var type:String;
|
var type:String;
|
||||||
var index:Int;
|
var index:Int;
|
||||||
var x:Int;
|
var x:Int;
|
||||||
@@ -23,7 +26,8 @@ typedef MapConfig = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
typedef BrickConfig = {
|
typedef BrickConfig = {
|
||||||
var type:Int;
|
var type:BrickType;
|
||||||
|
var index:Int;
|
||||||
var layer:Int;
|
var layer:Int;
|
||||||
var armor:Int;
|
var armor:Int;
|
||||||
}
|
}
|
||||||
@@ -35,33 +39,49 @@ typedef BulletConfig = {
|
|||||||
var piercing:Int;
|
var piercing:Int;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef TankConfig = {
|
||||||
typedef TankType = {
|
var type:TankType;
|
||||||
var group:String;
|
|
||||||
var type:String;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef TankConfig = { > TankType,
|
|
||||||
var width:Float;
|
var width:Float;
|
||||||
var height:Float;
|
var height:Float;
|
||||||
var speed:Float;
|
var speed:Float;
|
||||||
var bullet:BulletConfig;
|
var bullet:BulletConfig;
|
||||||
var bullets:Int;
|
var bullets:Int;
|
||||||
var hits:Int;
|
var hits:Int;
|
||||||
|
var skin:String;
|
||||||
|
@:optinal var upgrade:TankType;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef TankSpawn = { > TankType,
|
typedef BonusConfig = {
|
||||||
var rate: Float;
|
var type:BonusType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef TankSpawn = {
|
||||||
|
var type:TankType;
|
||||||
|
var rate:Float;
|
||||||
|
@:optional var bonus:Float;
|
||||||
|
@:optional var protect:Float;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef PlayerConfig = {
|
||||||
|
var index:Int;
|
||||||
|
var control:ControlType;
|
||||||
|
var tanks:Array<TankSpawn>;
|
||||||
|
@:optional var life:Int;
|
||||||
|
@:optional var color:Color;
|
||||||
|
}
|
||||||
|
|
||||||
typedef TeamConfig = {
|
typedef TeamConfig = {
|
||||||
var id:String;
|
var id:TeamId;
|
||||||
var size:Int;
|
var players:Array<PlayerConfig>;
|
||||||
var spawnInterval:Int;
|
@:optional var life:Int;
|
||||||
var tanks:Array<TankSpawn>;
|
@:optional var spawnInterval:Int;
|
||||||
|
@:optional var color:Color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef GamePreset = {
|
||||||
|
var id:PresetId;
|
||||||
|
var teams:Array<TeamConfig>;
|
||||||
|
}
|
||||||
|
|
||||||
typedef LevelConfig = {
|
typedef LevelConfig = {
|
||||||
var data:Array<BrickConfig>;
|
var data:Array<BrickConfig>;
|
||||||
@@ -75,57 +95,75 @@ class Config {
|
|||||||
public var map(default, null):MapConfig;
|
public var map(default, null):MapConfig;
|
||||||
public var bricks(default, null):Array<BrickConfig>;
|
public var bricks(default, null):Array<BrickConfig>;
|
||||||
public var tanks(default, null):Array<TankConfig>;
|
public var tanks(default, null):Array<TankConfig>;
|
||||||
public var teams(default, null):Array<TeamConfig>;
|
public var presets(default, null):Array<GamePreset>;
|
||||||
public var points(default, null):Array<SpawnPoint>;
|
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 tankMap:Map<String, Map<String, TankConfig>>;
|
private var brickMapByIndex:Map<Int, BrickConfig>;
|
||||||
private var teamMap:Map<String, TeamConfig>;
|
private var tankMap:Map<TankType, TankConfig>;
|
||||||
|
private var presetsMap:Map<PresetId, GamePreset>;
|
||||||
|
private var bonusMap:Map<BonusType, BonusConfig>;
|
||||||
|
|
||||||
public function new(
|
public function new(
|
||||||
type:String,
|
type:String,
|
||||||
game:GameConfig,
|
game:GameConfig,
|
||||||
map:MapConfig,
|
map:MapConfig,
|
||||||
bricks:Array<BrickConfig>,
|
bricks:Array<BrickConfig>,
|
||||||
teams:Array<TeamConfig>,
|
presets:Array<GamePreset>,
|
||||||
points:Array<SpawnPoint>,
|
points:Array<SpawnPoint>,
|
||||||
tanks:Array<TankConfig>
|
tanks:Array<TankConfig>,
|
||||||
|
bonuses:Array<BonusConfig>
|
||||||
) {
|
) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.game = game;
|
this.game = game;
|
||||||
this.map = map;
|
this.map = map;
|
||||||
this.bricks = bricks;
|
this.bricks = bricks;
|
||||||
this.teams = teams;
|
this.presets = presets;
|
||||||
this.points = points;
|
this.points = points;
|
||||||
this.tanks = tanks;
|
this.tanks = tanks;
|
||||||
|
this.bonuses = bonuses;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function init() {
|
private function init() {
|
||||||
brickMap = new Map();
|
brickMap = new Map();
|
||||||
|
brickMapByIndex = new Map();
|
||||||
for (item in bricks) {
|
for (item in bricks) {
|
||||||
brickMap.set(item.type, item);
|
brickMap.set(item.type, item);
|
||||||
|
brickMapByIndex.set(item.index, item);
|
||||||
}
|
}
|
||||||
teamMap = new Map();
|
presetsMap = new Map();
|
||||||
for (team in teams) {
|
for (preset in presets) {
|
||||||
teamMap.set(team.id, team);
|
presetsMap.set(preset.id, preset);
|
||||||
}
|
}
|
||||||
tankMap = new Map();
|
tankMap = new Map();
|
||||||
for (item in tanks) {
|
for (item in tanks) {
|
||||||
if (!tankMap.exists(item.group)) tankMap.set(item.group, new Map<String, TankConfig>());
|
tankMap.set(item.type, item);
|
||||||
tankMap.get(item.group).set(item.type, item);
|
}
|
||||||
|
bonusMap = new Map();
|
||||||
|
for (item in bonuses) {
|
||||||
|
bonusMap.set(item.type, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBrick(type:Int):BrickConfig {
|
public function getBrick(type:BrickType):BrickConfig {
|
||||||
return brickMap.get(type);
|
return brickMap.get(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTeam(id:String):TeamConfig {
|
public function getBrickByIndex(index:Int):BrickConfig {
|
||||||
return teamMap.get(id);
|
return brickMapByIndex.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTank(group:String, type:String):TankConfig {
|
public function getPreset(id:PresetId):GamePreset {
|
||||||
return tankMap.get(group).get(type);
|
return presetsMap.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTank(type:TankType):TankConfig {
|
||||||
|
return tankMap.get(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBonus(type:BonusType):BonusConfig {
|
||||||
|
return bonusMap.get(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,10 @@ typedef ConfigSource = {
|
|||||||
var game:GameConfig;
|
var game:GameConfig;
|
||||||
var map: MapConfig;
|
var map: MapConfig;
|
||||||
var bricks: Array<BrickConfig>;
|
var bricks: Array<BrickConfig>;
|
||||||
var teams: Array<TeamConfig>;
|
var presets: Array<GamePreset>;
|
||||||
var points: Array<SpawnPoint>;
|
var points: Array<SpawnPoint>;
|
||||||
var tanks: Dynamic<Array<TankConfig>>;
|
var tanks: Array<TankConfig>;
|
||||||
|
var bonuses: Array<BonusConfig>;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ConfigBundle {
|
class ConfigBundle {
|
||||||
@@ -22,15 +23,7 @@ class ConfigBundle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function get(type:String):Config {
|
public static function get(type:String):Config {
|
||||||
var source:ConfigSource = convert(Yaml.parse(Assets.getText('resources/${type}/config.yaml'), Parser.options().useObjects()));
|
var source = convert(Yaml.parse(Assets.getText('resources/${type}/config.yaml'), Parser.options().useObjects()));
|
||||||
var tanks:Array<TankConfig> = [];
|
return new Config(type, source.game, source.map, source.bricks, source.presets, source.points, source.tanks, source.bonuses);
|
||||||
for (group in Reflect.fields(source.tanks)) {
|
|
||||||
var data:Array<TankConfig> = Reflect.field(source.tanks, group);
|
|
||||||
for (item in data) {
|
|
||||||
item.group = group;
|
|
||||||
tanks.push(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new Config(type, source.game, source.map, source.bricks, source.teams, source.points, tanks);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package ru.m.tankz.config;
|
package ru.m.tankz.config;
|
||||||
|
|
||||||
import yaml.Renderer;
|
|
||||||
import yaml.Parser;
|
|
||||||
import yaml.Yaml;
|
|
||||||
import openfl.Assets;
|
import openfl.Assets;
|
||||||
import ru.m.tankz.game.Game;
|
|
||||||
import ru.m.tankz.config.Config;
|
import ru.m.tankz.config.Config;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
import yaml.Parser;
|
||||||
|
import yaml.Renderer;
|
||||||
|
import yaml.Yaml;
|
||||||
|
|
||||||
|
|
||||||
typedef LevelSource = {
|
typedef LevelSource = {
|
||||||
@@ -13,7 +13,6 @@ typedef LevelSource = {
|
|||||||
@:optional var points:Array<SpawnPoint>;
|
@:optional var points:Array<SpawnPoint>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class LevelBundle {
|
class LevelBundle {
|
||||||
|
|
||||||
private static function formatLevel(level:Int):String {
|
private static function formatLevel(level:Int):String {
|
||||||
@@ -27,7 +26,7 @@ class LevelBundle {
|
|||||||
for (line in ~/\s+/g.split(data)) {
|
for (line in ~/\s+/g.split(data)) {
|
||||||
for (c in line.split('')) {
|
for (c in line.split('')) {
|
||||||
if (c.length > 0) {
|
if (c.length > 0) {
|
||||||
bricks.push(config.getBrick(Std.parseInt(c)));
|
bricks.push(config.getBrickByIndex(Std.parseInt(c)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,20 +36,19 @@ class LevelBundle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function loads(config:Config, data:String):LevelConfig {
|
public static function loads(config:Config, data:String):LevelConfig {
|
||||||
try {
|
if (config.type == 'classic') {
|
||||||
|
return loadsOld(config, data);
|
||||||
|
} else {
|
||||||
var obj:LevelSource = Yaml.parse(data, Parser.options().useObjects());
|
var obj:LevelSource = Yaml.parse(data, Parser.options().useObjects());
|
||||||
return {
|
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,
|
points: obj.points,
|
||||||
}
|
}
|
||||||
} catch (error:Dynamic) {
|
|
||||||
L.w('LevelBundle', '${error}');
|
|
||||||
return loadsOld(config, data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function dumps(config:Config, level:LevelConfig):String {
|
public static function dumps(config:Config, level:LevelConfig):String {
|
||||||
var bricksStr = level.data.map(function(brick:BrickConfig) return brick.type).join('');
|
var bricksStr = level.data.map(function(brick:BrickConfig) return Std.string(brick.index)).join('');
|
||||||
return Yaml.render({
|
return Yaml.render({
|
||||||
data: bricksStr,
|
data: bricksStr,
|
||||||
points: level.points,
|
points: level.points,
|
||||||
|
|||||||
@@ -1,22 +1,19 @@
|
|||||||
package ru.m.tankz.control;
|
package ru.m.tankz.control;
|
||||||
|
|
||||||
import ru.m.tankz.game.Game;
|
import ru.m.geom.Direction;
|
||||||
import ru.m.tankz.core.Entity;
|
import ru.m.tankz.core.Entity;
|
||||||
import ru.m.tankz.core.EntityType;
|
import ru.m.tankz.core.EntityType;
|
||||||
import ru.m.geom.Direction;
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
|
||||||
enum TankAction {
|
enum TankAction {
|
||||||
MOVE(direction:Direction);
|
MOVE(direction:Direction);
|
||||||
LEVEL_UP(level:Int);
|
UPGRADE;
|
||||||
STOP;
|
STOP;
|
||||||
SHOT;
|
SHOT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef ControlType = String;
|
|
||||||
|
|
||||||
|
|
||||||
class Control {
|
class Control {
|
||||||
public static var NONE(default, never):ControlType = 'none';
|
public static var NONE(default, never):ControlType = 'none';
|
||||||
public static var HUMAN(default, never):ControlType = 'human';
|
public static var HUMAN(default, never):ControlType = 'human';
|
||||||
|
|||||||
15
src/common/haxe/ru/m/tankz/core/Bonus.hx
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package ru.m.tankz.core;
|
||||||
|
|
||||||
|
import ru.m.geom.Rectangle;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
|
||||||
|
class Bonus extends Entity {
|
||||||
|
|
||||||
|
public var bonusType(default, null):BonusType;
|
||||||
|
|
||||||
|
public function new(bonusType:BonusType) {
|
||||||
|
super(new Rectangle(0, 0, 44, 44));
|
||||||
|
this.bonusType = bonusType;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package ru.m.tankz.core;
|
package ru.m.tankz.core;
|
||||||
|
|
||||||
import ru.m.tankz.game.Game;
|
|
||||||
import ru.m.tankz.config.Config;
|
|
||||||
import ru.m.geom.Rectangle;
|
|
||||||
import ru.m.geom.Direction;
|
import ru.m.geom.Direction;
|
||||||
|
import ru.m.geom.Rectangle;
|
||||||
|
import ru.m.tankz.config.Config;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
|
||||||
class Bullet extends MobileEntity {
|
class Bullet extends MobileEntity {
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
package ru.m.tankz.core;
|
package ru.m.tankz.core;
|
||||||
|
|
||||||
import ru.m.tankz.game.Game;
|
|
||||||
import ru.m.geom.Rectangle;
|
import ru.m.geom.Rectangle;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
|
||||||
class Eagle extends Entity {
|
class Eagle extends Entity {
|
||||||
|
|
||||||
public var team(default, null):TeamId;
|
public var team(default, null):TeamId;
|
||||||
|
public var death(default, default):Bool;
|
||||||
|
|
||||||
public function new(team:TeamId) {
|
public function new(team:TeamId) {
|
||||||
super(new Rectangle(0, 0, 44, 44));
|
super(new Rectangle(0, 0, 44, 44));
|
||||||
this.team = team;
|
this.team = team;
|
||||||
|
this.death = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package ru.m.tankz.core;
|
package ru.m.tankz.core;
|
||||||
|
|
||||||
import ru.m.geom.Rectangle;
|
import ru.m.geom.Rectangle;
|
||||||
|
import Type;
|
||||||
|
|
||||||
|
|
||||||
class Entity implements IKey {
|
class Entity implements IKey {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package ru.m.tankz.core;
|
package ru.m.tankz.core;
|
||||||
|
|
||||||
import Type.ValueType;
|
import Type;
|
||||||
import ru.m.tankz.map.Grid.GridCell;
|
import ru.m.tankz.map.Grid;
|
||||||
|
|
||||||
|
|
||||||
enum EntityType {
|
enum EntityType {
|
||||||
@@ -9,6 +9,7 @@ enum EntityType {
|
|||||||
TANK(tank:Tank);
|
TANK(tank:Tank);
|
||||||
BULLET(bullet:Bullet);
|
BULLET(bullet:Bullet);
|
||||||
CELL(cell:GridCell);
|
CELL(cell:GridCell);
|
||||||
|
BONUS(bonus:Bonus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -20,7 +21,23 @@ class EntityTypeResolver {
|
|||||||
case ValueType.TClass(Tank): EntityType.TANK(cast entity);
|
case ValueType.TClass(Tank): EntityType.TANK(cast entity);
|
||||||
case ValueType.TClass(Bullet): EntityType.BULLET(cast entity);
|
case ValueType.TClass(Bullet): EntityType.BULLET(cast entity);
|
||||||
case ValueType.TClass(GridCell): EntityType.CELL(cast entity);
|
case ValueType.TClass(GridCell): EntityType.CELL(cast entity);
|
||||||
|
case ValueType.TClass(Bonus): EntityType.BONUS(cast entity);
|
||||||
case x: null;
|
case x: null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function as<T>(entity:Entity, type:Class<T>):Null<T> {
|
||||||
|
if (Std.is(entity, type)) {
|
||||||
|
return cast entity;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function asCall<T, R>(entity:Entity, type:Class<T>, fun:T->R, ?defaultResult:R):R {
|
||||||
|
var e:T = as(entity, type);
|
||||||
|
if (e != null) {
|
||||||
|
return fun(e);
|
||||||
|
}
|
||||||
|
return defaultResult;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
27
src/common/haxe/ru/m/tankz/core/Modificator.hx
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package ru.m.tankz.core;
|
||||||
|
|
||||||
|
import haxe.Timer;
|
||||||
|
|
||||||
|
class Modificator {
|
||||||
|
|
||||||
|
public var active(default, default):Bool;
|
||||||
|
private var timer:Timer;
|
||||||
|
|
||||||
|
public function new() {
|
||||||
|
active = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function on(seconds:Float):Void {
|
||||||
|
off();
|
||||||
|
active = true;
|
||||||
|
timer = Timer.delay(off, Std.int(seconds * 1000));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function off():Void {
|
||||||
|
if (timer != null) {
|
||||||
|
timer.stop();
|
||||||
|
timer = null;
|
||||||
|
}
|
||||||
|
active = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,22 +1,29 @@
|
|||||||
package ru.m.tankz.core;
|
package ru.m.tankz.core;
|
||||||
|
|
||||||
import ru.m.tankz.game.Game;
|
import ru.m.draw.Color;
|
||||||
|
import ru.m.geom.Direction;
|
||||||
import ru.m.geom.Point;
|
import ru.m.geom.Point;
|
||||||
|
import ru.m.geom.Rectangle;
|
||||||
import ru.m.tankz.config.Config;
|
import ru.m.tankz.config.Config;
|
||||||
import ru.m.tankz.core.Bullet;
|
import ru.m.tankz.core.Bullet;
|
||||||
import ru.m.geom.Rectangle;
|
import ru.m.tankz.Type;
|
||||||
import ru.m.geom.Direction;
|
|
||||||
|
|
||||||
|
|
||||||
class Tank extends MobileEntity {
|
class Tank extends MobileEntity {
|
||||||
public var playerId(default, null):PlayerId;
|
public var playerId(default, null):PlayerId;
|
||||||
public var config(default, set):TankConfig;
|
public var config(default, set):TankConfig;
|
||||||
|
public var color(default, default):Color;
|
||||||
public var hits(default, default):Int;
|
public var hits(default, default):Int;
|
||||||
|
public var bonus(default, default):Bool;
|
||||||
|
public var protect(default, null):Modificator;
|
||||||
|
public var freezing(default, null):Modificator;
|
||||||
|
|
||||||
private var bulletsCounter:Int = 0;
|
private var bulletsCounter:Int = 0;
|
||||||
|
|
||||||
public function new(playerId:PlayerId, config:TankConfig) {
|
public function new(playerId:PlayerId, config:TankConfig) {
|
||||||
super(new Rectangle(0, 0, config.width, config.height), config.speed, Direction.RIGHT);
|
super(new Rectangle(0, 0, config.width, config.height), config.speed, Direction.RIGHT);
|
||||||
|
this.protect = new Modificator();
|
||||||
|
this.freezing = new Modificator();
|
||||||
this.playerId = playerId;
|
this.playerId = playerId;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.hits = config.hits;
|
this.hits = config.hits;
|
||||||
@@ -32,7 +39,14 @@ class Tank extends MobileEntity {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override public function move(direction:Direction):Void {
|
||||||
|
if (!freezing.active) {
|
||||||
|
super.move(direction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function shot():Null<Bullet> {
|
public function shot():Null<Bullet> {
|
||||||
|
if (freezing.active) return null;
|
||||||
if (bulletsCounter >= config.bullets) return null;
|
if (bulletsCounter >= config.bullets) return null;
|
||||||
var bullet = new Bullet(this);
|
var bullet = new Bullet(this);
|
||||||
bullet.rect.center = rect.center.add(new Point(rect.width / 4 * rect.direction.x, rect.height / 4 * rect.direction.y));
|
bullet.rect.center = rect.center.add(new Point(rect.width / 4 * rect.direction.x, rect.height / 4 * rect.direction.y));
|
||||||
|
|||||||
@@ -12,14 +12,12 @@ import ru.m.tankz.core.Tank;
|
|||||||
import ru.m.tankz.map.LevelMap;
|
import ru.m.tankz.map.LevelMap;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
interface EngineListener {
|
interface EngineListener {
|
||||||
public function onSpawn(entity:EntityType):Void;
|
public function onSpawn(entity:EntityType):Void;
|
||||||
public function onCollision(entity:EntityType, with:EntityType):Void;
|
public function onCollision(entity:EntityType, with:EntityType):Void;
|
||||||
public function onDestroy(entity:EntityType):Void;
|
public function onDestroy(entity:EntityType):Void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class CollisionProcessor implements EngineListener {
|
class CollisionProcessor implements EngineListener {
|
||||||
|
|
||||||
private var engine:Engine;
|
private var engine:Engine;
|
||||||
@@ -30,51 +28,36 @@ class CollisionProcessor implements EngineListener {
|
|||||||
|
|
||||||
public function onSpawn(entity:EntityType):Void {}
|
public function onSpawn(entity:EntityType):Void {}
|
||||||
|
|
||||||
private function checkTankBullet(tank:Tank, bullet:Bullet):Bool {
|
public function onCollision(entity:EntityType, with:EntityType):Void {
|
||||||
if (bullet.tankId == tank.id) return false;
|
switch [entity, with] {
|
||||||
return engine.config.game.friendlyFire || tank.playerId.team != bullet.playerId.team;
|
case [EntityType.TANK(tank), EntityType.TANK(other_tank)]:
|
||||||
}
|
tank.rect.lean(other_tank.rect);
|
||||||
|
case [EntityType.TANK(tank), EntityType.EAGLE(eagle)]:
|
||||||
private function hitTank(tank:Tank):Void {
|
tank.rect.lean(eagle.rect);
|
||||||
|
case [EntityType.TANK(tank), EntityType.BONUS(bonus)]:
|
||||||
|
engine.destroy(bonus);
|
||||||
|
case [EntityType.TANK(tank), EntityType.BULLET(bullet)] |
|
||||||
|
[EntityType.BULLET(bullet), EntityType.TANK(tank)]:
|
||||||
|
if (bullet.tankId == tank.id || (!engine.config.game.friendlyFire && tank.playerId.team == bullet.playerId.team)) {
|
||||||
|
// Nothing
|
||||||
|
} else {
|
||||||
|
if (!tank.protect.active) {
|
||||||
if (tank.hits > 0) {
|
if (tank.hits > 0) {
|
||||||
tank.hits--;
|
tank.hits--;
|
||||||
} else {
|
} else {
|
||||||
engine.destroy(tank);
|
engine.destroy(tank);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
engine.destroy(bullet);
|
||||||
public function onCollision(entity:EntityType, with:EntityType):Void {
|
|
||||||
switch (entity) {
|
|
||||||
case EntityType.TANK(tank1):
|
|
||||||
switch (with) {
|
|
||||||
case EntityType.TANK(tank2):
|
|
||||||
tank1.rect.lean(tank2.rect);
|
|
||||||
case EntityType.BULLET(bullet2):
|
|
||||||
if (checkTankBullet(tank1, bullet2)) {
|
|
||||||
hitTank(tank1);
|
|
||||||
engine.destroy(bullet2);
|
|
||||||
}
|
|
||||||
case EntityType.EAGLE(eagle):
|
|
||||||
tank1.rect.lean(eagle.rect);
|
|
||||||
case EntityType.CELL(cell):
|
|
||||||
tank1.rect.lean(cell.rect);
|
|
||||||
}
|
|
||||||
case EntityType.BULLET(bullet1):
|
|
||||||
switch (with) {
|
|
||||||
case EntityType.TANK(tank2):
|
|
||||||
if (checkTankBullet(tank2, bullet1)) {
|
|
||||||
engine.destroy(bullet1);
|
|
||||||
hitTank(tank2);
|
|
||||||
}
|
|
||||||
case EntityType.BULLET(bullet2):
|
|
||||||
engine.destroy(bullet1);
|
|
||||||
engine.destroy(bullet2);
|
|
||||||
case EntityType.EAGLE(eagle):
|
|
||||||
engine.destroy(bullet1);
|
|
||||||
engine.destroy(eagle);
|
|
||||||
case EntityType.CELL(cell):
|
|
||||||
engine.destroy(bullet1);
|
|
||||||
}
|
}
|
||||||
|
case [EntityType.BULLET(bullet), EntityType.BULLET(other_bullet)]:
|
||||||
|
engine.destroy(bullet);
|
||||||
|
engine.destroy(other_bullet);
|
||||||
|
case [EntityType.BULLET(bullet), EntityType.CELL(cell)]:
|
||||||
|
engine.destroy(bullet);
|
||||||
|
case [EntityType.BULLET(bullet), EntityType.EAGLE(eagle)]:
|
||||||
|
engine.destroy(bullet);
|
||||||
|
eagle.death = true;
|
||||||
case _:
|
case _:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -82,7 +65,8 @@ class CollisionProcessor implements EngineListener {
|
|||||||
public function onDestroy(entity:EntityType):Void { }
|
public function onDestroy(entity:EntityType):Void { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@:build(yield.parser.Parser.run())
|
||||||
|
//@:yield //ToDo: not working
|
||||||
class Engine implements ControlHandler {
|
class Engine implements ControlHandler {
|
||||||
|
|
||||||
public var config(default, default):Config;
|
public var config(default, default):Config;
|
||||||
@@ -131,9 +115,10 @@ class Engine implements ControlHandler {
|
|||||||
switch (action) {
|
switch (action) {
|
||||||
case TankAction.MOVE(direction):
|
case TankAction.MOVE(direction):
|
||||||
tank.move(direction);
|
tank.move(direction);
|
||||||
case TankAction.LEVEL_UP(level):
|
case TankAction.UPGRADE:
|
||||||
// ToDo:
|
if (tank.config.upgrade != null) {
|
||||||
tank.config = config.getTank('human', Std.string(Std.int(Math.min(Std.parseInt(tank.config.type) + level, 3))));
|
tank.config = config.getTank(tank.config.upgrade);
|
||||||
|
}
|
||||||
case TankAction.STOP:
|
case TankAction.STOP:
|
||||||
tank.stop();
|
tank.stop();
|
||||||
case TankAction.SHOT:
|
case TankAction.SHOT:
|
||||||
@@ -144,8 +129,6 @@ class Engine implements ControlHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function update():Void {
|
public function update():Void {
|
||||||
var newTime:Float = Date.now().getTime();
|
var newTime:Float = Date.now().getTime();
|
||||||
var d:Float = newTime - time;
|
var d:Float = newTime - time;
|
||||||
@@ -165,6 +148,15 @@ class Engine implements ControlHandler {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
if (entity.mx != 0 || entity.my != 0) {
|
if (entity.mx != 0 || entity.my != 0) {
|
||||||
|
var asTank:Tank = EntityTypeResolver.as(entity, Tank);
|
||||||
|
var asBullet:Bullet = EntityTypeResolver.as(entity, Bullet);
|
||||||
|
|
||||||
|
if (asTank != null) {
|
||||||
|
if (asTank.freezing.active) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var side:Line = entity.rect.getSide(entity.rect.direction.reverse());
|
var side:Line = entity.rect.getSide(entity.rect.direction.reverse());
|
||||||
var step:Point = new Point(entity.rect.direction.x * map.cellWidth / 4, entity.rect.direction.y * map.cellHeight / 4);
|
var step:Point = new Point(entity.rect.direction.x * map.cellWidth / 4, entity.rect.direction.y * map.cellHeight / 4);
|
||||||
var end:Point = side.center.add(new Point(entity.mx * (d / 30), entity.my * (d / 30)));
|
var end:Point = side.center.add(new Point(entity.mx * (d / 30), entity.my * (d / 30)));
|
||||||
@@ -198,15 +190,14 @@ class Engine implements ControlHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Std.is(entity, Bullet)) {
|
if (asBullet != null) {
|
||||||
var bullet:Bullet = cast ent;
|
|
||||||
if (collision) {
|
if (collision) {
|
||||||
cells = map.grid.getCells(side.setLength(map.grid.cellWidth * 3));
|
cells = map.grid.getCells(side.setLength(map.grid.cellWidth * 3));
|
||||||
for (cell in cells) {
|
for (cell in cells) {
|
||||||
if (cell.armor > 0) {
|
if (cell.armor > 0) {
|
||||||
if (cell.armor == bullet.config.piercing) {
|
if (cell.armor == asBullet.config.piercing) {
|
||||||
cell.destroyed = true;
|
cell.destroyed = true;
|
||||||
} else if (cell.armor < bullet.config.piercing) {
|
} else if (cell.armor < asBullet.config.piercing) {
|
||||||
var brick = map.getBrick(cell);
|
var brick = map.getBrick(cell);
|
||||||
brick.destroyed = true;
|
brick.destroyed = true;
|
||||||
}
|
}
|
||||||
@@ -230,4 +221,13 @@ class Engine implements ControlHandler {
|
|||||||
listeners = [];
|
listeners = [];
|
||||||
entities = new Map();
|
entities = new Map();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function iterTanks(filter:Tank->Bool):Iterator<Tank> {
|
||||||
|
for (entity in entities) {
|
||||||
|
var tank:Tank = EntityTypeResolver.as(entity, Tank);
|
||||||
|
if (tank != null && filter(tank)) {
|
||||||
|
@yield return tank;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package ru.m.tankz.game;
|
package ru.m.tankz.game;
|
||||||
|
|
||||||
import ru.m.tankz.control.Control;
|
|
||||||
import haxe.ds.Option;
|
import haxe.ds.Option;
|
||||||
import ru.m.tankz.game.GameState.PlayerState;
|
|
||||||
import ru.m.tankz.game.Game;
|
import ru.m.tankz.game.Game;
|
||||||
|
import ru.m.tankz.game.GameState;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
|
||||||
class ClassicGame extends Game {
|
class ClassicGame extends Game {
|
||||||
@@ -13,49 +13,17 @@ class ClassicGame extends Game {
|
|||||||
public static var HUMAN(default, never):TeamId = 'human';
|
public static var HUMAN(default, never):TeamId = 'human';
|
||||||
public static var BOT(default, never):TeamId = 'bot';
|
public static var BOT(default, never):TeamId = 'bot';
|
||||||
|
|
||||||
public static var PLAYER1(default, never):GameMode = [{team:HUMAN, type:Control.HUMAN, index:0}];
|
public static var PLAYER1(default, never):PresetId = 'player1';
|
||||||
public static var PLAYER2(default, never):GameMode = [{team:HUMAN, type:Control.HUMAN, index:0}, {team:HUMAN, type:Control.HUMAN, index:1}];
|
public static var PLAYER2(default, never):PresetId = 'player2';
|
||||||
|
|
||||||
private static var HUMAN_LIFE(default, never):Int = 3;
|
|
||||||
private static var BOT_LIFE(default, never):Int = 20;
|
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
super(TYPE);
|
super(TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function buildState(level:Int, mode:GameMode):GameState {
|
|
||||||
var state = new GameState();
|
|
||||||
state.type = TYPE;
|
|
||||||
state.mode = mode;
|
|
||||||
state.level = level;
|
|
||||||
state.teams[HUMAN] = {life: -1, players: new Map(), lose: false};
|
|
||||||
state.teams[BOT] = {life: BOT_LIFE, players: new Map(), lose: false};
|
|
||||||
for (human in mode) {
|
|
||||||
state.teams[HUMAN].players[human.index] = {
|
|
||||||
id:human,
|
|
||||||
life:HUMAN_LIFE,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
for (i in 0...mode.length * 2 + 2) {
|
|
||||||
state.teams[BOT].players[i] = {
|
|
||||||
id:{team:BOT, index:i, type:Control.BOT},
|
|
||||||
life:-1,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
override public function next():Option<GameState> {
|
override public function next():Option<GameState> {
|
||||||
if (!state.teams[HUMAN].lose) {
|
if (state.loser == HUMAN) {
|
||||||
state.level++;
|
|
||||||
if (state.level >= config.game.levels) state.level = 0;
|
|
||||||
state.teams[BOT].lose = false;
|
|
||||||
state.teams[BOT].life = BOT_LIFE;
|
|
||||||
for (ps in state.teams[HUMAN].players) {
|
|
||||||
if (ps.life > 0) ps.life++;
|
|
||||||
}
|
|
||||||
return Option.Some(state);
|
|
||||||
}
|
|
||||||
return Option.None;
|
return Option.None;
|
||||||
}
|
}
|
||||||
|
return super.next();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package ru.m.tankz.game;
|
package ru.m.tankz.game;
|
||||||
|
|
||||||
import ru.m.tankz.control.Control;
|
|
||||||
import haxe.ds.Option;
|
|
||||||
import ru.m.tankz.game.Game;
|
import ru.m.tankz.game.Game;
|
||||||
import ru.m.tankz.game.GameState;
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
|
||||||
class DotaGame extends Game {
|
class DotaGame extends Game {
|
||||||
@@ -13,54 +11,11 @@ class DotaGame extends Game {
|
|||||||
public static var RADIANT(default, never):TeamId = 'radiant';
|
public static var RADIANT(default, never):TeamId = 'radiant';
|
||||||
public static var DIRE(default, never):TeamId = 'dire';
|
public static var DIRE(default, never):TeamId = 'dire';
|
||||||
|
|
||||||
public static var PLAYER1(default, never):GameMode = [
|
public static var PLAYER1(default, never):PresetId = 'player1';
|
||||||
{team:RADIANT, type:Control.HUMAN, index:0}
|
public static var PLAYER2_COOP(default, never):PresetId = 'player2_coop';
|
||||||
];
|
public static var PLAYER2_VS(default, never):PresetId = 'player2_vs';
|
||||||
|
|
||||||
public static var PLAYER2_COOP(default, never):GameMode = [
|
|
||||||
{team:RADIANT, type:Control.HUMAN, index:0},
|
|
||||||
{team:RADIANT, type:Control.HUMAN, index:1}
|
|
||||||
];
|
|
||||||
|
|
||||||
public static var PLAYER2_VS(default, never):GameMode = [
|
|
||||||
{team:RADIANT, type:Control.HUMAN, index:0},
|
|
||||||
{team:DIRE, type:Control.HUMAN, index:0}
|
|
||||||
];
|
|
||||||
|
|
||||||
private static var TEAM_SIZE(default, never):Int = 5;
|
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
super(TYPE);
|
super(TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function buildState(level:Int, mode:GameMode):GameState {
|
|
||||||
var state = new GameState();
|
|
||||||
state.type = TYPE;
|
|
||||||
state.mode = mode;
|
|
||||||
state.level = level;
|
|
||||||
state.teams[RADIANT] = {life: 20, players: new Map(), lose: false};
|
|
||||||
state.teams[DIRE] = {life: 20, players: new Map(), lose: false};
|
|
||||||
for (i in 0...TEAM_SIZE) {
|
|
||||||
state.teams[RADIANT].players[i] = {
|
|
||||||
id: {team:RADIANT, index:i, type:Control.BOT},
|
|
||||||
life: -1,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
for (i in 0...TEAM_SIZE) {
|
|
||||||
state.teams[DIRE].players[i] = {
|
|
||||||
id: {team:DIRE, index:i, type:Control.BOT},
|
|
||||||
life: -1,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
for (human in mode) {
|
|
||||||
state.teams[human.team].players[human.index].id = human;
|
|
||||||
}
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
override public function next():Option<GameState> {
|
|
||||||
state.level++;
|
|
||||||
if (state.level >= config.game.levels) state.level = 0;
|
|
||||||
return Option.Some(buildState(state.level, state.mode));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import ru.m.tankz.config.ConfigBundle;
|
|||||||
import ru.m.tankz.config.LevelBundle;
|
import ru.m.tankz.config.LevelBundle;
|
||||||
import ru.m.tankz.control.Control;
|
import ru.m.tankz.control.Control;
|
||||||
import ru.m.tankz.control.HumanControl;
|
import ru.m.tankz.control.HumanControl;
|
||||||
|
import ru.m.tankz.core.Bonus;
|
||||||
import ru.m.tankz.core.Eagle;
|
import ru.m.tankz.core.Eagle;
|
||||||
import ru.m.tankz.core.Entity;
|
import ru.m.tankz.core.Entity;
|
||||||
import ru.m.tankz.core.EntityType;
|
import ru.m.tankz.core.EntityType;
|
||||||
@@ -19,33 +20,21 @@ import ru.m.tankz.core.Tank;
|
|||||||
import ru.m.tankz.engine.Engine;
|
import ru.m.tankz.engine.Engine;
|
||||||
import ru.m.tankz.game.GameState;
|
import ru.m.tankz.game.GameState;
|
||||||
import ru.m.tankz.game.Spawner;
|
import ru.m.tankz.game.Spawner;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
typedef GameType = String;
|
|
||||||
|
|
||||||
typedef GameMode = Array<PlayerId>;
|
|
||||||
|
|
||||||
typedef TeamId = String;
|
|
||||||
|
|
||||||
typedef PlayerId = {
|
|
||||||
var team:TeamId;
|
|
||||||
var type:ControlType;
|
|
||||||
var index:Int;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class Game implements EngineListener {
|
class Game implements EngineListener {
|
||||||
|
|
||||||
private static var TAG(default, never):String = Type.getClassName(Game).split('.').pop();
|
private static var TAG(default, never):String = 'Game';
|
||||||
|
|
||||||
public var type(default, null):GameType;
|
public var type(default, null):GameType;
|
||||||
public var state(default, null):GameState;
|
public var state(default, null):GameState;
|
||||||
|
public var preset(default, null):GamePreset;
|
||||||
public var teams(default, null):Map<TeamId, Team>;
|
public var teams(default, null):Map<TeamId, Team>;
|
||||||
public var config(default, null):Config;
|
public var config(default, null):Config;
|
||||||
public var engine(default, null):Engine;
|
public var engine(default, null):Engine;
|
||||||
|
|
||||||
private var points:Array<SpawnPoint>;
|
private var points:Array<SpawnPoint>;
|
||||||
private var spawners:Map<TeamId, Spawner>;
|
|
||||||
private var deferred:Deferred<GameState>;
|
private var deferred:Deferred<GameState>;
|
||||||
private var stream:Stream<GameState>;
|
private var stream:Stream<GameState>;
|
||||||
|
|
||||||
@@ -56,16 +45,26 @@ class Game implements EngineListener {
|
|||||||
engine.listeners.push(this);
|
engine.listeners.push(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTeam(teamId:TeamId):Team {
|
||||||
|
return teams[teamId];
|
||||||
|
}
|
||||||
|
|
||||||
public function getPlayer(playerId:PlayerId):Player {
|
public function getPlayer(playerId:PlayerId):Player {
|
||||||
return teams[playerId.team].players[playerId.index];
|
return teams[playerId.team].players[playerId.index];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildTank(playerId:PlayerId, point:SpawnPoint):Tank {
|
private function buildTank(playerId:PlayerId, point:SpawnPoint):Tank {
|
||||||
var types:Array<TankSpawn> = teams[playerId.team].config.tanks;
|
var player = getPlayer(playerId);
|
||||||
var type:TankSpawn = types[Math.floor(Math.random() * types.length)];
|
var spawns:Array<TankSpawn> = player.config.tanks;
|
||||||
var tankConfig:TankConfig = config.getTank(type.group, type.type);
|
var spawn:TankSpawn = spawns[Math.floor(Math.random() * spawns.length)];
|
||||||
|
var tankConfig:TankConfig = config.getTank(spawn.type);
|
||||||
var tank = new Tank(playerId, tankConfig);
|
var tank = new Tank(playerId, tankConfig);
|
||||||
|
tank.color = player.config.color.zero ? teams[playerId.team].config.color : player.config.color;
|
||||||
|
tank.bonus = Math.random() < spawn.bonus;
|
||||||
applyPoint(tank, point);
|
applyPoint(tank, point);
|
||||||
|
if (spawn.protect > 0) {
|
||||||
|
tank.protect.on(spawn.protect);
|
||||||
|
}
|
||||||
return tank;
|
return tank;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,26 +74,25 @@ class Game implements EngineListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function start(state:GameState):Stream<GameState> {
|
public function start(state:GameState):Stream<GameState> {
|
||||||
this.deferred = new Deferred();
|
|
||||||
this.state = state;
|
this.state = state;
|
||||||
|
this.preset = config.getPreset(state.presetId);
|
||||||
|
this.deferred = new Deferred();
|
||||||
var level = LevelBundle.get(type, config, state.level);
|
var level = LevelBundle.get(type, config, state.level);
|
||||||
points = level.points != null ? level.points : config.points;
|
points = level.points != null ? level.points : config.points;
|
||||||
engine.map.setData(level.data);
|
engine.map.setData(level.data);
|
||||||
teams = new Map<TeamId, Team>();
|
teams = new Map<TeamId, Team>();
|
||||||
spawners = new Map<TeamId, Spawner>();
|
|
||||||
var humanControlIndex = 0;
|
var humanControlIndex = 0;
|
||||||
for (teamConfig in config.teams) {
|
for (teamConfig in preset.teams) {
|
||||||
var team = new Team(teamConfig);
|
var teamPoints = points.filter(function(p:SpawnPoint) return p.team == teamConfig.id);
|
||||||
for (playerState in state.teams[team.id].players) {
|
var team:Team = new Team(teamConfig, teamPoints);
|
||||||
var player = new Player(playerState.id);
|
|
||||||
team.players[player.id.index] = player;
|
|
||||||
teams[team.id] = team;
|
teams[team.id] = team;
|
||||||
if (player.id.type != null) {
|
for (player in team.players.iterator()) {
|
||||||
var control = switch (player.id.type) {
|
if (player.config.control != null) {
|
||||||
|
var control = switch (player.config.control) {
|
||||||
case Control.HUMAN: new HumanControl(player.id, humanControlIndex++);
|
case Control.HUMAN: new HumanControl(player.id, humanControlIndex++);
|
||||||
case Control.BOT: new BotControl(player.id);
|
case Control.BOT: new BotControl(player.id);
|
||||||
case Control.NONE: null;
|
case Control.NONE: null;
|
||||||
case _: throw 'Unsupported control type: "${player.id.type}"';
|
case _: throw 'Unsupported control type: "${player.config.control}"';
|
||||||
}
|
}
|
||||||
L.d(TAG, 'control(${player.id} - ${control})');
|
L.d(TAG, 'control(${player.id} - ${control})');
|
||||||
if (control != null) {
|
if (control != null) {
|
||||||
@@ -103,17 +101,16 @@ class Game implements EngineListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var teamPoints = points.filter(function(p:SpawnPoint) return p.team == team.id);
|
team.spawner.runner = spawn;
|
||||||
spawners[team.id] = new Spawner(team.config, teamPoints, spawn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (team in teams) {
|
for (team in teams.iterator()) {
|
||||||
for (player in team.players) {
|
for (player in team.players.iterator()) {
|
||||||
if (trySpawn(player.id)) {
|
if (team.trySpawn(player.id)) {
|
||||||
spawners[team.id].push(player.id);
|
team.spawner.push(player.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var eaglePoint = spawners[team.id].getPoint('eagle');
|
var eaglePoint = team.spawner.getPoint('eagle');
|
||||||
if (eaglePoint != null) {
|
if (eaglePoint != null) {
|
||||||
var eagle = new Eagle(team.id);
|
var eagle = new Eagle(team.id);
|
||||||
applyPoint(eagle, eaglePoint);
|
applyPoint(eagle, eaglePoint);
|
||||||
@@ -126,15 +123,15 @@ class Game implements EngineListener {
|
|||||||
|
|
||||||
private function spawn(task:SpawnTask):Void {
|
private function spawn(task:SpawnTask):Void {
|
||||||
L.d(TAG, 'spawn(${task}');
|
L.d(TAG, 'spawn(${task}');
|
||||||
getPlayer(task.playerId).tankId = 0;
|
var team = getTeam(task.playerId.team);
|
||||||
if (trySpawn(task.playerId, true)) {
|
var player = getPlayer(task.playerId);
|
||||||
|
player.tankId = 0;
|
||||||
|
if (getTeam(task.playerId.team).trySpawn(task.playerId, true)) {
|
||||||
var tank = buildTank(task.playerId, task.point);
|
var tank = buildTank(task.playerId, task.point);
|
||||||
var player:Player = getPlayer(task.playerId);
|
|
||||||
player.tankId = tank.id;
|
player.tankId = tank.id;
|
||||||
Timer.delay(function() engine.spawn(tank), 1500);
|
engine.spawn(tank);
|
||||||
} else if (!isTeamAlive(task.playerId.team)) {
|
} else if (!team.isAlive) {
|
||||||
state.teams[task.playerId.team].lose = true;
|
lose(team.id);
|
||||||
complete();
|
|
||||||
}
|
}
|
||||||
deferred.resolve(state);
|
deferred.resolve(state);
|
||||||
}
|
}
|
||||||
@@ -156,89 +153,104 @@ class Game implements EngineListener {
|
|||||||
switch (entity) {
|
switch (entity) {
|
||||||
case EntityType.TANK(tank):
|
case EntityType.TANK(tank):
|
||||||
getPlayer(tank.playerId).control.start();
|
getPlayer(tank.playerId).control.start();
|
||||||
case x:
|
case _:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onCollision(entity:EntityType, with:EntityType):Void {
|
public function onCollision(entity:EntityType, with:EntityType):Void {
|
||||||
switch (entity) {
|
switch entity {
|
||||||
case EntityType.TANK(tank):
|
case EntityType.TANK(tank):
|
||||||
var control = getPlayer(tank.playerId).control;
|
var control = getPlayer(tank.playerId).control;
|
||||||
if (control != null) control.onCollision(with);
|
if (control != null) control.onCollision(with);
|
||||||
case x:
|
case _:
|
||||||
}
|
}
|
||||||
|
switch [entity, with] {
|
||||||
|
case [EntityType.TANK(tank), EntityType.BONUS(bonus)]:
|
||||||
|
applyBonus(tank, bonus);
|
||||||
|
case [EntityType.BULLET(_), EntityType.EAGLE(eagle)]:
|
||||||
|
lose(eagle.team);
|
||||||
|
deferred.resolve(state);
|
||||||
|
case _:
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isTeamAlive(team:TeamId):Bool {
|
|
||||||
var ts:TeamState = state.teams[team];
|
|
||||||
var life:Int = Lambda.fold(ts.players, function(ps, t) return t + ps.life, ts.life);
|
|
||||||
if (life > 0) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
for (player in teams[team].players) {
|
|
||||||
if (player.tankId > 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (spawners[team].active) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function trySpawn(player:PlayerId, spawn:Bool = false):Bool {
|
|
||||||
var ts:TeamState = state.teams[player.team];
|
|
||||||
var ps:PlayerState = ts.players[player.index];
|
|
||||||
var result = false;
|
|
||||||
if (ps.life > -1) {
|
|
||||||
if (ps.life > 0) {
|
|
||||||
if (spawn) ps.life--;
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
} else if (ts.life > -1) {
|
|
||||||
if (ts.life > 0) {
|
|
||||||
if (spawn) ts.life--;
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onDestroy(entity:EntityType):Void {
|
public function onDestroy(entity:EntityType):Void {
|
||||||
switch (entity) {
|
switch (entity) {
|
||||||
case EntityType.TANK(tank):
|
case EntityType.TANK(tank):
|
||||||
getPlayer(tank.playerId).control.stop();
|
var team = getTeam(tank.playerId.team);
|
||||||
getPlayer(tank.playerId).tankId = 0; //ToDo: ?
|
var player = getPlayer(tank.playerId);
|
||||||
var respawn:Bool = trySpawn(tank.playerId);
|
player.control.stop();
|
||||||
|
player.tankId = 0; //ToDo: ?
|
||||||
|
var respawn:Bool = team.trySpawn(player.id);
|
||||||
if (respawn) {
|
if (respawn) {
|
||||||
spawners[tank.playerId.team].push(tank.playerId);
|
team.spawner.push(player.id);
|
||||||
}
|
}
|
||||||
if (!isTeamAlive(tank.playerId.team)) {
|
if (!team.isAlive) {
|
||||||
state.teams[tank.playerId.team].lose = true;
|
lose(team.id);
|
||||||
complete();
|
|
||||||
}
|
}
|
||||||
|
if (tank.bonus) spawnBonus();
|
||||||
deferred.resolve(state);
|
deferred.resolve(state);
|
||||||
case EntityType.EAGLE(eagle):
|
case _:
|
||||||
state.teams[eagle.team].lose = true;
|
|
||||||
complete();
|
|
||||||
deferred.resolve(state);
|
|
||||||
case x:
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function lose(teamId:TeamId):Void {
|
||||||
|
state.loser = teamId;
|
||||||
|
complete();
|
||||||
|
}
|
||||||
|
|
||||||
public function onAction(tankId:Int, action:TankAction):Void {
|
public function onAction(tankId:Int, action:TankAction):Void {
|
||||||
engine.action(tankId, action);
|
engine.action(tankId, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function next():Option<GameState> {
|
public function next():Option<GameState> {
|
||||||
return Option.None;
|
var level = state.level + 1;
|
||||||
|
state.level++;
|
||||||
|
if (level >= config.game.levels) level = 0;
|
||||||
|
return Option.Some(new GameState(state.type, preset.id, level));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function dispose():Void {
|
public function dispose():Void {
|
||||||
engine.dispose();
|
engine.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function spawnBonus(?type:BonusType):Void {
|
||||||
|
var bonusConfig:BonusConfig = type != null ? config.getBonus(type) : config.bonuses[Math.floor(Math.random() * config.bonuses.length)];
|
||||||
|
var bonus = new Bonus(bonusConfig.type);
|
||||||
|
bonus.rect.x = Math.random() * engine.map.width;
|
||||||
|
bonus.rect.y = Math.random() * engine.map.height;
|
||||||
|
engine.spawn(bonus);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline private function alienTank(team:TeamId):Tank->Bool {
|
||||||
|
return function(tank:Tank):Bool return team != tank.playerId.team;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function applyBonus(tank:Tank, bonus:Bonus):Void {
|
||||||
|
L.e('XXX', 'applyBonus: ${bonus.bonusType}');
|
||||||
|
switch (bonus.bonusType) {
|
||||||
|
case 'life':
|
||||||
|
getPlayer(tank.playerId).life++;
|
||||||
|
case 'star':
|
||||||
|
if (tank.config.upgrade != null) {
|
||||||
|
tank.config = config.getTank(tank.config.upgrade);
|
||||||
|
} else {
|
||||||
|
tank.hits++;
|
||||||
|
}
|
||||||
|
case 'grenade':
|
||||||
|
for (t in engine.iterTanks(alienTank(tank.playerId.team))) {
|
||||||
|
engine.destroy(t);
|
||||||
|
}
|
||||||
|
case 'helmet':
|
||||||
|
tank.protect.on(20);
|
||||||
|
case 'clock':
|
||||||
|
for (t in engine.iterTanks(alienTank(tank.playerId.team))) {
|
||||||
|
t.freezing.on(10);
|
||||||
|
}
|
||||||
|
case 'shovel':
|
||||||
|
// ToDo: protect eagle/area
|
||||||
|
case _:
|
||||||
|
engine.destroy(tank); // :-D
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +1,18 @@
|
|||||||
package ru.m.tankz.game;
|
package ru.m.tankz.game;
|
||||||
|
|
||||||
import ru.m.tankz.game.Game;
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
|
||||||
typedef ControlType = String;
|
|
||||||
|
|
||||||
|
|
||||||
typedef PlayerState = {
|
|
||||||
var id:PlayerId;
|
|
||||||
var life:Int;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
typedef TeamState = {
|
|
||||||
var players:Map<Int, PlayerState>;
|
|
||||||
var life:Int;
|
|
||||||
var lose:Bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class GameState {
|
class GameState {
|
||||||
public var type:GameType;
|
public var type:GameType;
|
||||||
public var mode:GameMode;
|
|
||||||
public var level:Int;
|
public var level:Int;
|
||||||
public var teams:Map<TeamId, TeamState>;
|
public var presetId:PresetId;
|
||||||
|
public var loser:TeamId;
|
||||||
|
|
||||||
public function new() {
|
public function new(type:GameType, presetId:PresetId, level:Int = 0) {
|
||||||
type = null;
|
this.type = type;
|
||||||
level = -1;
|
this.presetId = presetId;
|
||||||
teams = new Map();
|
this.level = level;
|
||||||
|
this.loser = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,27 @@
|
|||||||
package ru.m.tankz.game;
|
package ru.m.tankz.game;
|
||||||
|
|
||||||
|
import ru.m.tankz.config.Config;
|
||||||
import ru.m.tankz.control.Control;
|
import ru.m.tankz.control.Control;
|
||||||
import ru.m.tankz.game.Game;
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
|
||||||
class Player {
|
class Player {
|
||||||
|
|
||||||
|
public var config(default, null):PlayerConfig;
|
||||||
public var id(default, null):PlayerId;
|
public var id(default, null):PlayerId;
|
||||||
public var tankId(default, set):Int;
|
public var tankId(default, set):Int;
|
||||||
public var control(default, set):Control;
|
public var control(default, set):Control;
|
||||||
|
public var life(default, default):Int;
|
||||||
|
public var isAlive(get, null):Bool;
|
||||||
|
|
||||||
public function new(id:PlayerId, control:Control=null) {
|
public function new(teamId:TeamId, config:PlayerConfig) {
|
||||||
this.id = id;
|
this.config = config;
|
||||||
this.control = control;
|
this.id = {team:teamId, index:config.index};
|
||||||
|
this.control = null;
|
||||||
|
this.life = config.life;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_tankId(value:Int):Int {
|
private function set_tankId(value:Int):Int {
|
||||||
tankId = value;
|
tankId = value;
|
||||||
if (control != null) {
|
if (control != null) {
|
||||||
control.tankId = tankId;
|
control.tankId = tankId;
|
||||||
@@ -23,7 +29,7 @@ class Player {
|
|||||||
return tankId;
|
return tankId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_control(value:Control):Control {
|
private function set_control(value:Control):Control {
|
||||||
if (control != null) control.dispose();
|
if (control != null) control.dispose();
|
||||||
control = value;
|
control = value;
|
||||||
if (control != null) {
|
if (control != null) {
|
||||||
@@ -31,4 +37,8 @@ class Player {
|
|||||||
}
|
}
|
||||||
return control;
|
return control;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function get_isAlive():Bool {
|
||||||
|
return tankId > 0 || life > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
package ru.m.tankz.game;
|
package ru.m.tankz.game;
|
||||||
|
|
||||||
|
|
||||||
import haxe.Timer;
|
import haxe.Timer;
|
||||||
import ru.m.tankz.game.Game;
|
|
||||||
import ru.m.tankz.config.Config;
|
import ru.m.tankz.config.Config;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
|
||||||
typedef SpawnTask = {
|
typedef SpawnTask = {
|
||||||
@@ -11,14 +10,13 @@ typedef SpawnTask = {
|
|||||||
var playerId:PlayerId;
|
var playerId:PlayerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class Spawner {
|
class Spawner {
|
||||||
|
|
||||||
public var active(get, never):Bool;
|
public var active(get, never):Bool;
|
||||||
|
public var runner(default, default):SpawnTask -> Void;
|
||||||
|
|
||||||
private var config:TeamConfig;
|
private var config:TeamConfig;
|
||||||
private var points:Array<SpawnPoint>;
|
private var points:Array<SpawnPoint>;
|
||||||
private var runner:SpawnTask -> Void;
|
|
||||||
private var queue:Array<SpawnTask>;
|
private var queue:Array<SpawnTask>;
|
||||||
private var timer:Timer;
|
private var timer:Timer;
|
||||||
|
|
||||||
@@ -26,10 +24,10 @@ class Spawner {
|
|||||||
private var anyPoints:Array<SpawnPoint>;
|
private var anyPoints:Array<SpawnPoint>;
|
||||||
private var index:Int;
|
private var index:Int;
|
||||||
|
|
||||||
public function new(config:TeamConfig, points:Array<SpawnPoint>, runner:SpawnTask -> Void) {
|
public function new(config:TeamConfig, points:Array<SpawnPoint>) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.points = points;
|
this.points = points;
|
||||||
this.runner = runner;
|
this.runner = null;
|
||||||
queue = [];
|
queue = [];
|
||||||
indexedPoints = new Map();
|
indexedPoints = new Map();
|
||||||
anyPoints = [];
|
anyPoints = [];
|
||||||
|
|||||||
@@ -1,21 +1,59 @@
|
|||||||
package ru.m.tankz.game;
|
package ru.m.tankz.game;
|
||||||
|
|
||||||
import ru.m.tankz.config.Config.TeamConfig;
|
import ru.m.tankz.Type;
|
||||||
import ru.m.tankz.game.Player;
|
import ru.m.tankz.config.Config;
|
||||||
import ru.m.tankz.game.Game;
|
|
||||||
|
|
||||||
|
|
||||||
class Team {
|
class Team {
|
||||||
|
|
||||||
public var id(default, null):TeamId;
|
public var id(default, null):TeamId;
|
||||||
public var config(default, null):TeamConfig;
|
public var config(default, null):TeamConfig;
|
||||||
|
public var spawner(default, null):Spawner;
|
||||||
public var players(default, null):Map<Int, Player>;
|
public var players(default, null):Map<Int, Player>;
|
||||||
|
public var life(default, default):Int;
|
||||||
|
public var isAlive(get, null):Bool;
|
||||||
|
|
||||||
private static var i:Int = 0;
|
public function new(config:TeamConfig, points:Array<SpawnPoint>) {
|
||||||
|
|
||||||
public function new(config:TeamConfig) {
|
|
||||||
this.id = config.id;
|
this.id = config.id;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.players = new Map();
|
this.players = new Map();
|
||||||
|
for (playerConfig in config.players) {
|
||||||
|
this.players[playerConfig.index] = new Player(id, playerConfig);
|
||||||
|
}
|
||||||
|
this.life = config.life;
|
||||||
|
this.spawner = new Spawner(config, points);
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
if (spawn) player.life--;
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
} else if (life > -1) {
|
||||||
|
if (life > 0) {
|
||||||
|
if (spawn) life--;
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ToDo: eagle state?
|
||||||
|
private function get_isAlive():Bool {
|
||||||
|
if (life > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (spawner.active) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
for (player in players) {
|
||||||
|
if (player.isAlive) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,6 @@ import ru.m.tankz.core.IKey;
|
|||||||
|
|
||||||
|
|
||||||
class Brick implements IKey {
|
class Brick implements IKey {
|
||||||
public static var BORDER:BrickConfig = {
|
|
||||||
type: -1,
|
|
||||||
layer: 2,
|
|
||||||
armor: -1,
|
|
||||||
}
|
|
||||||
|
|
||||||
public var cellX(default, null):Int;
|
public var cellX(default, null):Int;
|
||||||
public var cellY(default, null):Int;
|
public var cellY(default, null):Int;
|
||||||
public var key(get, null):String;
|
public var key(get, null):String;
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ class LevelMap {
|
|||||||
public var gridWidth(default, null):Int;
|
public var gridWidth(default, null):Int;
|
||||||
public var gridHeight(default, null):Int;
|
public var gridHeight(default, null):Int;
|
||||||
|
|
||||||
|
public var width(get, null):Float;
|
||||||
|
public var height(get, null):Float;
|
||||||
|
|
||||||
public var bricks(default, null):Array<Brick>;
|
public var bricks(default, null):Array<Brick>;
|
||||||
|
|
||||||
public var grid(default, null):Grid;
|
public var grid(default, null):Grid;
|
||||||
@@ -68,4 +71,12 @@ class LevelMap {
|
|||||||
var cellY:Int = Math.floor(point.y / config.cellHeight);
|
var cellY:Int = Math.floor(point.y / config.cellHeight);
|
||||||
return bricks[cellX + cellY * config.gridWidth];
|
return bricks[cellX + cellY * config.gridWidth];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private inline function get_width():Float {
|
||||||
|
return config.cellWidth * config.gridWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
private inline function get_height():Float {
|
||||||
|
return config.cellHeight * config.gridHeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,44 +1,30 @@
|
|||||||
package ru.m.tankz.editor;
|
package ru.m.tankz.editor;
|
||||||
|
|
||||||
|
|
||||||
import ru.m.tankz.editor.MapEditView.Brush;
|
|
||||||
import ru.m.tankz.game.DotaGame;
|
|
||||||
import haxework.gui.list.ListView;
|
|
||||||
import haxework.gui.list.VListView;
|
|
||||||
import ru.m.tankz.editor.FileUtil;
|
|
||||||
import haxework.gui.LabelView;
|
|
||||||
import ru.m.tankz.config.Config;
|
|
||||||
import ru.m.tankz.config.LevelBundle;
|
|
||||||
import ru.m.tankz.game.ClassicGame;
|
|
||||||
import ru.m.tankz.config.ConfigBundle;
|
|
||||||
import haxework.gui.ButtonView;
|
|
||||||
import haxework.gui.Root;
|
|
||||||
import flash.text.Font;
|
import flash.text.Font;
|
||||||
import haxework.resources.Resources;
|
import haxework.gui.ButtonView;
|
||||||
import haxework.resources.IResources;
|
import haxework.gui.frame.FrameSwitcher;
|
||||||
import haxework.provider.Provider;
|
import haxework.gui.VGroupView;
|
||||||
import haxework.log.TraceLogger;
|
import haxework.gui.Root;
|
||||||
import haxework.gui.ViewBuilder;
|
import haxework.gui.ViewBuilder;
|
||||||
import haxework.gui.GroupView;
|
import haxework.log.TraceLogger;
|
||||||
import haxework.log.JSLogger;
|
import haxework.provider.Provider;
|
||||||
import haxework.log.SocketLogger;
|
import haxework.resources.IResources;
|
||||||
|
import haxework.resources.Resources;
|
||||||
|
import ru.m.tankz.frame.LevelFrame;
|
||||||
|
#if flash import haxework.log.JSLogger; #end
|
||||||
|
#if debug import haxework.log.SocketLogger; #end
|
||||||
|
|
||||||
|
|
||||||
interface EditorViewLayout {
|
interface EditorViewLayout {
|
||||||
var openButton(default, null):ButtonView;
|
var switcher(default, null):FrameSwitcher;
|
||||||
var saveButton(default, null):ButtonView;
|
|
||||||
var fileNameLabel(default, null):LabelView;
|
|
||||||
var mapView(default, null):MapEditView;
|
|
||||||
var spawnPointList(default, null):VListView<SpawnPoint>;
|
|
||||||
var brickList(default, null):VListView<BrickConfig>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@:template("ru/m/tankz/editor/Editor.yaml")
|
@:template('ru/m/tankz/editor/Editor.yaml', 'ru/m/tankz/editor/Style.yaml')
|
||||||
class EditorView extends GroupView implements ViewBuilder implements EditorViewLayout {}
|
class EditorView extends VGroupView implements ViewBuilder implements EditorViewLayout {}
|
||||||
|
|
||||||
class Editor {
|
class Editor {
|
||||||
|
|
||||||
private static inline var TAG = "Tankz.Editor";
|
private static inline var TAG = 'Editor';
|
||||||
|
|
||||||
public static function main() {
|
public static function main() {
|
||||||
L.push(new TraceLogger());
|
L.push(new TraceLogger());
|
||||||
@@ -49,80 +35,29 @@ class Editor {
|
|||||||
L.push(new SocketLogger());
|
L.push(new SocketLogger());
|
||||||
#end
|
#end
|
||||||
Const.init();
|
Const.init();
|
||||||
L.d(TAG, "Debug: " + Const.DEBUG);
|
L.d(TAG, 'Debug: ${Const.DEBUG}');
|
||||||
L.i(TAG, "Version: " + Const.VERSION);
|
L.i(TAG, 'Version: ${Const.VERSION}');
|
||||||
L.i(TAG, "Build: " + Const.BUILD);
|
L.i(TAG, 'Build: ${Const.BUILD}');
|
||||||
new Editor();
|
new Editor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private var view:EditorView;
|
private var view:EditorView;
|
||||||
private var config:Config;
|
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
Provider.setFactory(IResources, Resources);
|
Provider.setFactory(IResources, Resources);
|
||||||
|
|
||||||
var font:Font = Font.enumerateFonts()[0];
|
var font:Font = Font.enumerateFonts()[0];
|
||||||
Provider.get(IResources).text.put("font", "Bookman Old Style");
|
Provider.get(IResources).text.put('font', 'Bookman Old Style');
|
||||||
Provider.get(IResources).text.put("version", 'v${Const.VERSION} b${Const.BUILD}');
|
Provider.get(IResources).text.put('version', 'v${Const.VERSION} b${Const.BUILD}');
|
||||||
|
|
||||||
view = new EditorView();
|
view = new EditorView({handler: this});
|
||||||
Root.bind(view);
|
Root.bind(view);
|
||||||
view.content.stage.stageFocusRect = false;
|
view.content.stage.stageFocusRect = false;
|
||||||
|
|
||||||
view.openButton.onPress = this;
|
view.switcher.change(LevelFrame.ID);
|
||||||
view.saveButton.onPress = this;
|
|
||||||
|
|
||||||
config = ConfigBundle.get(DotaGame.TYPE);
|
|
||||||
view.mapView.config = config;
|
|
||||||
view.mapView.data = LevelBundle.empty(config);
|
|
||||||
|
|
||||||
view.brickList.data = config.bricks.filter(function(brick) return brick.type > -1);
|
|
||||||
view.spawnPointList.data = config.points;
|
|
||||||
|
|
||||||
var resetSelected = function() {
|
|
||||||
for (v in view.brickList.items) {
|
|
||||||
cast(v, BrickView).selected = false;
|
|
||||||
}
|
|
||||||
for (v in view.spawnPointList.items) {
|
|
||||||
cast(v, SpawnPointView).selected = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
view.brickList.dispatcher.addListener({
|
|
||||||
onListItemClick: function(item:IListItemView<BrickConfig>) {
|
|
||||||
view.mapView.brush = Brush.BRICK(item.data);
|
|
||||||
resetSelected();
|
|
||||||
cast(item, BrickView).selected = true; }
|
|
||||||
});
|
|
||||||
|
|
||||||
view.spawnPointList.dispatcher.addListener({
|
|
||||||
onListItemClick: function(item:IListItemView<SpawnPoint>) {
|
|
||||||
view.mapView.brush = Brush.POINT(item.data);
|
|
||||||
resetSelected();
|
|
||||||
cast(item, SpawnPointView).selected = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
view.mapView.brush = Brush.BRICK(view.brickList.data[0]);
|
|
||||||
cast(view.brickList.items[0], BrickView).selected = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPress(v:ButtonView):Void {
|
public function onPress(v:ButtonView):Void {
|
||||||
switch (v.id) {
|
view.switcher.change(v.id.split('btn_').pop());
|
||||||
case 'openButton':
|
|
||||||
L.d(TAG, 'OPEN');
|
|
||||||
FileUtil.browse().then(function(content:FileContent) {
|
|
||||||
view.fileNameLabel.text = content.name;
|
|
||||||
view.mapView.data = LevelBundle.loads(config, content.content);
|
|
||||||
});
|
|
||||||
case 'saveButton':
|
|
||||||
L.d(TAG, 'SAVE');
|
|
||||||
FileUtil.save({
|
|
||||||
name: view.fileNameLabel.text,
|
|
||||||
content: LevelBundle.dumps(config, view.mapView.data),
|
|
||||||
});
|
|
||||||
case _:
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,71 +1,48 @@
|
|||||||
$type: haxework.gui.GroupView
|
---
|
||||||
|
$type: haxework.gui.VGroupView
|
||||||
pWidth: 100
|
pWidth: 100
|
||||||
pHeight: 100
|
pHeight: 100
|
||||||
|
skin:
|
||||||
|
$type: haxework.gui.skin.BitmapSkin
|
||||||
|
image: "@asset:image:resources/images/background.png"
|
||||||
|
fillType: REPEAT
|
||||||
views:
|
views:
|
||||||
- $type: haxework.gui.VGroupView
|
# Tabs
|
||||||
pWidth: 100
|
|
||||||
pHeight: 100
|
|
||||||
views:
|
|
||||||
- $type: haxework.gui.HGroupView
|
|
||||||
pWidth: 100
|
|
||||||
height: 20
|
|
||||||
views:
|
|
||||||
- id: openButton
|
|
||||||
$type: haxework.gui.ButtonView
|
|
||||||
text: Open
|
|
||||||
contentSize: true
|
|
||||||
skin:
|
|
||||||
$type: haxework.gui.skin.ButtonColorSkin
|
|
||||||
color: 0xaaff00
|
|
||||||
- id: saveButton
|
|
||||||
$type: haxework.gui.ButtonView
|
|
||||||
text: Save
|
|
||||||
contentSize: true
|
|
||||||
skin:
|
|
||||||
$type: haxework.gui.skin.ButtonColorSkin
|
|
||||||
color: 0xaaff00
|
|
||||||
- id: fileNameLabel
|
|
||||||
$type: haxework.gui.LabelView
|
|
||||||
contentSize: true
|
|
||||||
- $type: haxework.gui.HGroupView
|
- $type: haxework.gui.HGroupView
|
||||||
contentSize: true
|
contentSize: true
|
||||||
views:
|
views:
|
||||||
- id: spawnPointList
|
- id: btn_level
|
||||||
$type: haxework.gui.list.VListView<SpawnPoint>
|
$type: haxework.gui.ButtonView
|
||||||
factory: '@class:ru.m.tankz.editor.SpawnPointView'
|
$style: button
|
||||||
width: 56
|
text: Level
|
||||||
pHeight: 100
|
onPress: "@link:handler"
|
||||||
scroll:
|
- id: btn_tank
|
||||||
$type: haxework.gui.list.VScrollView
|
$type: haxework.gui.ButtonView
|
||||||
width: 0
|
$style: button
|
||||||
pHeight: 100
|
text: Tank
|
||||||
skin:
|
onPress: "@link:handler"
|
||||||
$type: haxework.gui.list.VScrollSkin
|
- $type: haxework.gui.SpriteView
|
||||||
|
height: 3
|
||||||
|
pWidth: 100
|
||||||
skin:
|
skin:
|
||||||
$type: haxework.gui.skin.ColorSkin
|
$type: haxework.gui.skin.ColorSkin
|
||||||
color: 0x000000
|
color: "#aaaaaa"
|
||||||
alpha: 0.0
|
# Switcher
|
||||||
- id: mapView
|
- id: switcher
|
||||||
$type: ru.m.tankz.editor.MapEditView
|
$type: haxework.gui.frame.FrameSwitcher
|
||||||
contentSize: true
|
pWidth: 100
|
||||||
- id: brickList
|
|
||||||
$type: haxework.gui.list.VListView<BrickConfig>
|
|
||||||
factory: '@class:ru.m.tankz.editor.BrickView'
|
|
||||||
width: 30
|
|
||||||
pHeight: 100
|
pHeight: 100
|
||||||
scroll:
|
paddings: 5
|
||||||
$type: haxework.gui.list.VScrollView
|
views:
|
||||||
width: 0
|
- id: level
|
||||||
pHeight: 100
|
$type: ru.m.tankz.editor.frame.LevelFrame
|
||||||
skin:
|
- id: tank
|
||||||
$type: haxework.gui.list.VScrollSkin
|
$type: ru.m.tankz.editor.frame.TankFrame
|
||||||
skin:
|
# Version
|
||||||
$type: haxework.gui.skin.ColorSkin
|
|
||||||
color: 0x000000
|
|
||||||
alpha: 0.0
|
|
||||||
- $type: haxework.gui.LabelView
|
- $type: haxework.gui.LabelView
|
||||||
|
$style: label
|
||||||
inLayout: false
|
inLayout: false
|
||||||
contentSize: true
|
contentSize: true
|
||||||
vAlign: BOTTOM
|
vAlign: BOTTOM
|
||||||
hAlign: RIGHT
|
hAlign: RIGHT
|
||||||
text: '@res:text:version'
|
text: "@res:text:version"
|
||||||
|
|||||||
15
src/editor/haxe/ru/m/tankz/editor/Style.yaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
button:
|
||||||
|
height: 20
|
||||||
|
width: 150
|
||||||
|
margins: 2
|
||||||
|
skin:
|
||||||
|
$type: haxework.gui.skin.ButtonColorSkin
|
||||||
|
color: 0xaaff00
|
||||||
|
|
||||||
|
label:
|
||||||
|
fontColor: 0xffffff
|
||||||
|
fontEmbed: false
|
||||||
|
fontFamily: '@res:text:fontName'
|
||||||
|
fontSize: 16
|
||||||
|
shadowColor: 0x000000
|
||||||
110
src/editor/haxe/ru/m/tankz/editor/frame/LevelFrame.hx
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
package ru.m.tankz.editor.frame;
|
||||||
|
|
||||||
|
import haxework.gui.ButtonView;
|
||||||
|
import haxework.gui.LabelView;
|
||||||
|
import haxework.gui.list.ListView;
|
||||||
|
import haxework.gui.list.VListView;
|
||||||
|
import haxework.gui.VGroupView;
|
||||||
|
import haxework.gui.ViewBuilder;
|
||||||
|
import haxework.provider.Provider;
|
||||||
|
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.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;
|
||||||
|
|
||||||
|
|
||||||
|
interface LevelFrameLayout {
|
||||||
|
var gameClassicButton(default, null):ButtonView;
|
||||||
|
var gameDotaButton(default, null):ButtonView;
|
||||||
|
var openButton(default, null):ButtonView;
|
||||||
|
var saveButton(default, null):ButtonView;
|
||||||
|
var fileNameLabel(default, null):LabelView;
|
||||||
|
var mapView(default, null):MapEditView;
|
||||||
|
var spawnPointList(default, null):VListView<SpawnPoint>;
|
||||||
|
var brickList(default, null):VListView<BrickConfig>;
|
||||||
|
}
|
||||||
|
|
||||||
|
@:template('ru/m/tankz/editor/frame/LevelFrame.yaml', 'ru/m/tankz/editor/Style.yaml')
|
||||||
|
class LevelFrame extends VGroupView implements ViewBuilder implements LevelFrameLayout {
|
||||||
|
public static inline var ID = 'level';
|
||||||
|
public static inline var TAG = 'level';
|
||||||
|
|
||||||
|
private var config:Config;
|
||||||
|
|
||||||
|
public function init():Void {
|
||||||
|
gameClassicButton.onPress = this;
|
||||||
|
gameDotaButton.onPress = this;
|
||||||
|
openButton.onPress = this;
|
||||||
|
saveButton.onPress = this;
|
||||||
|
|
||||||
|
var resetSelected = function() {
|
||||||
|
for (v in brickList.items) {
|
||||||
|
cast(v, BrickView).selected = false;
|
||||||
|
}
|
||||||
|
for (v in spawnPointList.items) {
|
||||||
|
cast(v, SpawnPointView).selected = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
brickList.dispatcher.addListener({
|
||||||
|
onListItemClick: function(item:IListItemView<BrickConfig>) {
|
||||||
|
mapView.brush = Brush.BRICK(item.data);
|
||||||
|
resetSelected();
|
||||||
|
cast(item, BrickView).selected = true; }
|
||||||
|
});
|
||||||
|
|
||||||
|
spawnPointList.dispatcher.addListener({
|
||||||
|
onListItemClick: function(item:IListItemView<SpawnPoint>) {
|
||||||
|
mapView.brush = Brush.POINT(item.data);
|
||||||
|
resetSelected();
|
||||||
|
cast(item, SpawnPointView).selected = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onShow():Void {
|
||||||
|
setGameType(ClassicGame.TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setGameType(type:GameType):Void {
|
||||||
|
config = ConfigBundle.get(type);
|
||||||
|
Provider.set(Config, config);
|
||||||
|
|
||||||
|
mapView.config = config;
|
||||||
|
mapView.data = LevelBundle.empty(config);
|
||||||
|
|
||||||
|
brickList.data = config.bricks.filter(function(brick) return brick.index > -1);
|
||||||
|
spawnPointList.data = config.points;
|
||||||
|
|
||||||
|
mapView.brush = Brush.BRICK(brickList.data[0]);
|
||||||
|
cast(brickList.items[0], BrickView).selected = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onPress(v:ButtonView):Void {
|
||||||
|
switch (v.id) {
|
||||||
|
case 'gameClassicButton':
|
||||||
|
setGameType(ClassicGame.TYPE);
|
||||||
|
case 'gameDotaButton':
|
||||||
|
setGameType(DotaGame.TYPE);
|
||||||
|
case 'openButton':
|
||||||
|
L.d(TAG, 'OPEN');
|
||||||
|
FileUtil.browse().then(function(content:FileContent) {
|
||||||
|
fileNameLabel.text = content.name;
|
||||||
|
mapView.data = LevelBundle.loads(config, content.content);
|
||||||
|
});
|
||||||
|
case 'saveButton':
|
||||||
|
L.d(TAG, 'SAVE');
|
||||||
|
FileUtil.save({
|
||||||
|
name: fileNameLabel.text,
|
||||||
|
content: LevelBundle.dumps(config, mapView.data),
|
||||||
|
});
|
||||||
|
case _:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
68
src/editor/haxe/ru/m/tankz/editor/frame/LevelFrame.yaml
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
---
|
||||||
|
$type: haxework.gui.VGroupView
|
||||||
|
pWidth: 100
|
||||||
|
pHeight: 100
|
||||||
|
layoutMargin: 2
|
||||||
|
layoutVAlign: TOP
|
||||||
|
views:
|
||||||
|
- $type: haxework.gui.HGroupView
|
||||||
|
contentSize: true
|
||||||
|
views:
|
||||||
|
- id: gameClassicButton
|
||||||
|
$type: haxework.gui.ButtonView
|
||||||
|
$style: button
|
||||||
|
text: Classic
|
||||||
|
- id: gameDotaButton
|
||||||
|
$type: haxework.gui.ButtonView
|
||||||
|
$style: button
|
||||||
|
text: DotA
|
||||||
|
- $type: haxework.gui.HGroupView
|
||||||
|
contentSize: true
|
||||||
|
views:
|
||||||
|
- id: openButton
|
||||||
|
$type: haxework.gui.ButtonView
|
||||||
|
$style: button
|
||||||
|
text: Open
|
||||||
|
- id: saveButton
|
||||||
|
$type: haxework.gui.ButtonView
|
||||||
|
$style: button
|
||||||
|
text: Save
|
||||||
|
- id: fileNameLabel
|
||||||
|
$type: haxework.gui.LabelView
|
||||||
|
contentSize: true
|
||||||
|
- $type: haxework.gui.HGroupView
|
||||||
|
contentSize: true
|
||||||
|
views:
|
||||||
|
- id: spawnPointList
|
||||||
|
$type: haxework.gui.list.VListView<SpawnPoint>
|
||||||
|
factory: "@class:ru.m.tankz.editor.level.SpawnPointView"
|
||||||
|
width: 56
|
||||||
|
pHeight: 100
|
||||||
|
scroll:
|
||||||
|
$type: haxework.gui.list.VScrollView
|
||||||
|
width: 0
|
||||||
|
pHeight: 100
|
||||||
|
skin:
|
||||||
|
$type: haxework.gui.list.VScrollSkin
|
||||||
|
skin:
|
||||||
|
$type: haxework.gui.skin.ColorSkin
|
||||||
|
color: 0x000000
|
||||||
|
alpha: 0.0
|
||||||
|
- id: mapView
|
||||||
|
$type: ru.m.tankz.editor.level.MapEditView
|
||||||
|
contentSize: true
|
||||||
|
- id: brickList
|
||||||
|
$type: haxework.gui.list.VListView<BrickConfig>
|
||||||
|
factory: "@class:ru.m.tankz.editor.level.BrickView"
|
||||||
|
width: 30
|
||||||
|
pHeight: 100
|
||||||
|
scroll:
|
||||||
|
$type: haxework.gui.list.VScrollView
|
||||||
|
width: 0
|
||||||
|
pHeight: 100
|
||||||
|
skin:
|
||||||
|
$type: haxework.gui.list.VScrollSkin
|
||||||
|
skin:
|
||||||
|
$type: haxework.gui.skin.ColorSkin
|
||||||
|
color: 0x000000
|
||||||
|
alpha: 0.0
|
||||||
34
src/editor/haxe/ru/m/tankz/editor/frame/TankFrame.hx
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package ru.m.tankz.editor.frame;
|
||||||
|
|
||||||
|
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', 'ru/m/tankz/editor/Style.yaml')
|
||||||
|
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}');
|
||||||
|
}
|
||||||
|
}
|
||||||
49
src/editor/haxe/ru/m/tankz/editor/frame/TankFrame.yaml
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
---
|
||||||
|
$type: haxework.gui.HGroupView
|
||||||
|
pWidth: 100
|
||||||
|
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
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package ru.m.tankz.editor;
|
package ru.m.tankz.editor.level;
|
||||||
|
|
||||||
import flash.display.Bitmap;
|
import flash.display.Bitmap;
|
||||||
import flash.display.Shape;
|
import flash.display.Shape;
|
||||||
@@ -38,7 +38,7 @@ class BrickView extends SpriteView implements IListItemView<BrickConfig> {
|
|||||||
|
|
||||||
private function set_data(value:BrickConfig):BrickConfig {
|
private function set_data(value:BrickConfig):BrickConfig {
|
||||||
data = value;
|
data = value;
|
||||||
var src = 'resources/images/map/map_${value.type}.png';
|
var src = 'resources/image/map/${value.type}.png';
|
||||||
imageView.bitmapData = Assets.getBitmapData(src);
|
imageView.bitmapData = Assets.getBitmapData(src);
|
||||||
imageView.x = (width - imageView.width) / 2;
|
imageView.x = (width - imageView.width) / 2;
|
||||||
imageView.y = (height - imageView.height) / 2;
|
imageView.y = (height - imageView.height) / 2;
|
||||||