[common] added Type bundle
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -1,28 +1,25 @@
|
|||||||
package ru.m.tankz.render;
|
package ru.m.tankz.render;
|
||||||
|
|
||||||
import ru.m.draw.BitmapUtil;
|
import flash.display.Bitmap;
|
||||||
import ru.m.tankz.game.Game.TeamId;
|
|
||||||
import ru.m.tankz.config.Config.TankType;
|
|
||||||
import ru.m.tankz.control.Control;
|
|
||||||
import flash.display.Sprite;
|
|
||||||
import ru.m.animate.Animate;
|
|
||||||
import ru.m.tankz.core.Eagle;
|
|
||||||
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.control.Control;
|
||||||
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;
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
package ru.m.tankz.view.frames;
|
package ru.m.tankz.view.frames;
|
||||||
|
|
||||||
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,7 +19,6 @@ interface StartFrameLayout {
|
|||||||
var dota_2p_vs(default, null):ButtonView;
|
var dota_2p_vs(default, null):ButtonView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@:template("layout/frames/start.json", "layout/styles.json")
|
@:template("layout/frames/start.json", "layout/styles.json")
|
||||||
class StartFrame extends VGroupView implements ViewBuilder implements StartFrameLayout {
|
class StartFrame extends VGroupView implements ViewBuilder implements StartFrameLayout {
|
||||||
|
|
||||||
|
|||||||
@@ -20,14 +20,14 @@ bricks:
|
|||||||
teams:
|
teams:
|
||||||
- id: human
|
- id: human
|
||||||
tanks:
|
tanks:
|
||||||
- {group: human, type: 0, rate: 1}
|
- {type: human0, rate: 1}
|
||||||
- id: bot
|
- id: bot
|
||||||
spawnInterval: 3000
|
spawnInterval: 3000
|
||||||
tanks:
|
tanks:
|
||||||
- {group: bot, type: 0, rate: 0.5}
|
- {type: bot0, rate: 0.5}
|
||||||
- {group: bot, type: 1, rate: 0.5}
|
- {type: bot1, rate: 0.5}
|
||||||
- {group: bot, type: 2, rate: 0.5}
|
- {type: bot2, rate: 0.5}
|
||||||
- {group: bot, type: 3, rate: 0.5}
|
- {type: bot3, rate: 0.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}
|
||||||
@@ -44,91 +44,89 @@ bullet: &bullet
|
|||||||
piercing: 1
|
piercing: 1
|
||||||
|
|
||||||
tanks:
|
tanks:
|
||||||
human:
|
- type: human0
|
||||||
- type: 0
|
width: 36
|
||||||
width: 36
|
height: 36
|
||||||
height: 36
|
speed: 2.5
|
||||||
speed: 2.5
|
bullet:
|
||||||
bullet:
|
<<: *bullet
|
||||||
<<: *bullet
|
speed: 8.0
|
||||||
speed: 8.0
|
bullets: 1
|
||||||
bullets: 1
|
skin: pa
|
||||||
skin: pa
|
|
||||||
|
|
||||||
- type: 1
|
- type: human1
|
||||||
width: 40
|
width: 40
|
||||||
height: 36
|
height: 36
|
||||||
speed: 3.0
|
speed: 3.0
|
||||||
bullet:
|
bullet:
|
||||||
<<: *bullet
|
<<: *bullet
|
||||||
speed: 8.5
|
speed: 8.5
|
||||||
bullets: 1
|
bullets: 1
|
||||||
skin: pb
|
skin: pb
|
||||||
|
|
||||||
- type: 2
|
- type: human2
|
||||||
width: 40
|
width: 40
|
||||||
height: 36
|
height: 36
|
||||||
speed: 3.0
|
speed: 3.0
|
||||||
bullet:
|
bullet:
|
||||||
<<: *bullet
|
<<: *bullet
|
||||||
speed: 9.0
|
speed: 9.0
|
||||||
bullets: 2
|
bullets: 2
|
||||||
skin: pc
|
skin: pc
|
||||||
|
|
||||||
- type: 3
|
- type: human3
|
||||||
width: 42
|
width: 42
|
||||||
height: 38
|
height: 38
|
||||||
speed: 2.9
|
speed: 2.9
|
||||||
bullet:
|
bullet:
|
||||||
<<: *bullet
|
<<: *bullet
|
||||||
speed: 9.0
|
speed: 9.0
|
||||||
piercing: 3
|
piercing: 3
|
||||||
bullets: 2
|
bullets: 2
|
||||||
hits: 1
|
hits: 1
|
||||||
skin: pd
|
skin: pd
|
||||||
|
|
||||||
bot:
|
- type: bot0
|
||||||
- type: 0
|
width: 38
|
||||||
width: 38
|
height: 36
|
||||||
height: 36
|
speed: 2.0
|
||||||
speed: 2.0
|
bullet:
|
||||||
bullet:
|
<<: *bullet
|
||||||
<<: *bullet
|
speed: 7.0
|
||||||
speed: 7.0
|
bullets: 1
|
||||||
bullets: 1
|
score: 100
|
||||||
score: 100
|
skin: ba
|
||||||
skin: ba
|
|
||||||
|
|
||||||
- type: 1
|
- type: bot1
|
||||||
width: 40
|
width: 40
|
||||||
height: 36
|
height: 36
|
||||||
speed: 4.0
|
speed: 4.0
|
||||||
bullet:
|
bullet:
|
||||||
<<: *bullet
|
<<: *bullet
|
||||||
speed: 7.0
|
speed: 7.0
|
||||||
bullets: 1
|
bullets: 1
|
||||||
score: 200
|
score: 200
|
||||||
skin: bb
|
skin: bb
|
||||||
|
|
||||||
- type: 2
|
- type: bot2
|
||||||
width: 38
|
width: 38
|
||||||
height: 36
|
height: 36
|
||||||
speed: 2.0
|
speed: 2.0
|
||||||
bullet:
|
bullet:
|
||||||
<<: *bullet
|
<<: *bullet
|
||||||
speed: 9.0
|
speed: 9.0
|
||||||
bullets: 1
|
bullets: 1
|
||||||
score: 300
|
score: 300
|
||||||
skin: bc
|
skin: bc
|
||||||
|
|
||||||
- type: 3
|
- type: bot3
|
||||||
width: 40
|
width: 40
|
||||||
height: 36
|
height: 36
|
||||||
speed: 1.8
|
speed: 1.8
|
||||||
bullet:
|
bullet:
|
||||||
<<: *bullet
|
<<: *bullet
|
||||||
speed: 8.0
|
speed: 8.0
|
||||||
bullets: 1
|
bullets: 1
|
||||||
score: 400
|
score: 400
|
||||||
hits: 3
|
hits: 3
|
||||||
skin: bd
|
skin: bd
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ bricks:
|
|||||||
|
|
||||||
team_tanks: &team_tanks
|
team_tanks: &team_tanks
|
||||||
tanks:
|
tanks:
|
||||||
- {group: any, type: 0, rate: 0.5}
|
- {type: slow, rate: 0.5}
|
||||||
- {group: any, type: 1, rate: 0.5}
|
- {type: fast, rate: 0.5}
|
||||||
|
|
||||||
teams:
|
teams:
|
||||||
- <<: *team_tanks
|
- <<: *team_tanks
|
||||||
@@ -51,23 +51,22 @@ bullet: &bullet
|
|||||||
piercing: 1
|
piercing: 1
|
||||||
|
|
||||||
tanks:
|
tanks:
|
||||||
any:
|
- type: slow
|
||||||
- type: 0
|
width: 38
|
||||||
width: 38
|
height: 36
|
||||||
height: 36
|
speed: 2.0
|
||||||
speed: 2.0
|
bullet:
|
||||||
bullet:
|
<<: *bullet
|
||||||
<<: *bullet
|
speed: 10.0
|
||||||
speed: 10.0
|
bullets: 1
|
||||||
bullets: 1
|
skin: bc
|
||||||
skin: bc
|
|
||||||
|
|
||||||
- type: 1
|
- type: fast
|
||||||
width: 40
|
width: 40
|
||||||
height: 36
|
height: 36
|
||||||
speed: 4.0
|
speed: 4.0
|
||||||
bullet:
|
bullet:
|
||||||
<<: *bullet
|
<<: *bullet
|
||||||
speed: 7.0
|
speed: 7.0
|
||||||
bullets: 1
|
bullets: 1
|
||||||
skin: bb
|
skin: bb
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|
||||||
|
|||||||
22
src/common/haxe/ru/m/tankz/Type.hx
Normal file
22
src/common/haxe/ru/m/tankz/Type.hx
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package ru.m.tankz;
|
||||||
|
|
||||||
|
import ru.m.draw.Color;
|
||||||
|
|
||||||
|
typedef Type = Dynamic;
|
||||||
|
|
||||||
|
typedef GameType = String;
|
||||||
|
|
||||||
|
typedef TeamId = String;
|
||||||
|
|
||||||
|
typedef ControlType = String;
|
||||||
|
|
||||||
|
typedef TankType = String;
|
||||||
|
|
||||||
|
typedef PlayerId = {
|
||||||
|
var team:TeamId;
|
||||||
|
var type:ControlType;
|
||||||
|
var index:Int;
|
||||||
|
@:optional var color:Color;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef GameMode = Array<PlayerId>;
|
||||||
@@ -1,14 +1,13 @@
|
|||||||
package ru.m.tankz.bot;
|
package ru.m.tankz.bot;
|
||||||
|
|
||||||
import ru.m.tankz.core.Tank;
|
|
||||||
import ru.m.tankz.core.Entity;
|
|
||||||
import ru.m.tankz.core.Eagle;
|
|
||||||
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 {
|
class BotHelper {
|
||||||
@@ -46,7 +45,6 @@ class BotHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class BotControl extends Control {
|
class BotControl extends Control {
|
||||||
|
|
||||||
private var shotTimer:Timer;
|
private var shotTimer:Timer;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package ru.m.tankz.config;
|
package ru.m.tankz.config;
|
||||||
|
|
||||||
import ru.m.draw.Color;
|
import ru.m.draw.Color;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
|
||||||
typedef GameConfig = {
|
typedef GameConfig = {
|
||||||
@@ -9,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;
|
||||||
@@ -37,13 +38,8 @@ 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;
|
||||||
@@ -53,13 +49,14 @@ typedef TankConfig = { > TankType,
|
|||||||
var skin:String;
|
var skin:String;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef TankSpawn = { > TankType,
|
typedef TankSpawn = {
|
||||||
|
var type:TankType;
|
||||||
var rate: Float;
|
var rate: Float;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef TeamConfig = {
|
typedef TeamConfig = {
|
||||||
var id:String;
|
var id:TeamId;
|
||||||
var size:Int;
|
var size:Int;
|
||||||
var tanks:Array<TankSpawn>;
|
var tanks:Array<TankSpawn>;
|
||||||
@:optional var spawnInterval:Int;
|
@:optional var spawnInterval:Int;
|
||||||
@@ -83,7 +80,7 @@ class Config {
|
|||||||
public var points(default, null):Array<SpawnPoint>;
|
public var points(default, null):Array<SpawnPoint>;
|
||||||
|
|
||||||
private var brickMap:Map<Int, BrickConfig>;
|
private var brickMap:Map<Int, BrickConfig>;
|
||||||
private var tankMap:Map<String, Map<String, TankConfig>>;
|
private var tankMap:Map<TankType, TankConfig>;
|
||||||
private var teamMap:Map<String, TeamConfig>;
|
private var teamMap:Map<String, TeamConfig>;
|
||||||
|
|
||||||
public function new(
|
public function new(
|
||||||
@@ -116,8 +113,7 @@ class Config {
|
|||||||
}
|
}
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +125,7 @@ class Config {
|
|||||||
return teamMap.get(id);
|
return teamMap.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTank(group:String, type:String):TankConfig {
|
public function getTank(type:TankType):TankConfig {
|
||||||
return tankMap.get(group).get(type);
|
return tankMap.get(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ typedef ConfigSource = {
|
|||||||
var bricks: Array<BrickConfig>;
|
var bricks: Array<BrickConfig>;
|
||||||
var teams: Array<TeamConfig>;
|
var teams: Array<TeamConfig>;
|
||||||
var points: Array<SpawnPoint>;
|
var points: Array<SpawnPoint>;
|
||||||
var tanks: Dynamic<Array<TankConfig>>;
|
var tanks: Array<TankConfig>;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ConfigBundle {
|
class ConfigBundle {
|
||||||
@@ -22,15 +22,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.teams, source.points, source.tanks);
|
||||||
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 {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
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 {
|
||||||
@@ -14,9 +14,6 @@ enum TankAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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';
|
||||||
|
|||||||
@@ -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,7 +1,7 @@
|
|||||||
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 {
|
||||||
|
|||||||
@@ -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,6 +1,6 @@
|
|||||||
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.GridCell;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package ru.m.tankz.core;
|
package ru.m.tankz.core;
|
||||||
|
|
||||||
import ru.m.draw.Color;
|
import ru.m.draw.Color;
|
||||||
import ru.m.tankz.game.Game;
|
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 {
|
||||||
|
|||||||
@@ -133,7 +133,13 @@ class Engine implements ControlHandler {
|
|||||||
tank.move(direction);
|
tank.move(direction);
|
||||||
case TankAction.LEVEL_UP(level):
|
case TankAction.LEVEL_UP(level):
|
||||||
// ToDo:
|
// ToDo:
|
||||||
tank.config = config.getTank('human', Std.string(Std.int(Math.min(Std.parseInt(tank.config.type) + level, 3))));
|
var newType = switch(tank.config.type) {
|
||||||
|
case 'human0': 'human1';
|
||||||
|
case 'human1': 'human2';
|
||||||
|
case 'human2': 'human3';
|
||||||
|
case x: 'human3';
|
||||||
|
}
|
||||||
|
tank.config = config.getTank(newType);
|
||||||
case TankAction.STOP:
|
case TankAction.STOP:
|
||||||
tank.stop();
|
tank.stop();
|
||||||
case TankAction.SHOT:
|
case TankAction.SHOT:
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
package ru.m.tankz.game;
|
package ru.m.tankz.game;
|
||||||
|
|
||||||
|
import haxe.ds.Option;
|
||||||
import ru.m.draw.Color;
|
import ru.m.draw.Color;
|
||||||
import ru.m.tankz.control.Control;
|
import ru.m.tankz.control.Control;
|
||||||
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.PlayerState;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
|
||||||
class ClassicGame extends Game {
|
class ClassicGame extends Game {
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
package ru.m.tankz.game;
|
package ru.m.tankz.game;
|
||||||
|
|
||||||
|
import haxe.ds.Option;
|
||||||
import ru.m.draw.Color;
|
import ru.m.draw.Color;
|
||||||
import ru.m.tankz.control.Control;
|
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.game.GameState;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
|
||||||
class DotaGame extends Game {
|
class DotaGame extends Game {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package ru.m.tankz.game;
|
package ru.m.tankz.game;
|
||||||
|
|
||||||
import ru.m.draw.Color;
|
|
||||||
import haxe.ds.Option;
|
import haxe.ds.Option;
|
||||||
import haxe.Timer;
|
import haxe.Timer;
|
||||||
import promhx.Deferred;
|
import promhx.Deferred;
|
||||||
@@ -20,25 +19,12 @@ 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;
|
|
||||||
@:optional var color:Color;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
||||||
@@ -63,9 +49,9 @@ class Game implements EngineListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 spawns:Array<TankSpawn> = teams[playerId.team].config.tanks;
|
||||||
var type:TankSpawn = types[Math.floor(Math.random() * types.length)];
|
var spawn:TankSpawn = spawns[Math.floor(Math.random() * spawns.length)];
|
||||||
var tankConfig:TankConfig = config.getTank(type.group, type.type);
|
var tankConfig:TankConfig = config.getTank(spawn.type);
|
||||||
var tank = new Tank(playerId, tankConfig);
|
var tank = new Tank(playerId, tankConfig);
|
||||||
tank.color = playerId.color.zero ? teams[playerId.team].config.color : playerId.color;
|
tank.color = playerId.color.zero ? teams[playerId.team].config.color : playerId.color;
|
||||||
applyPoint(tank, point);
|
applyPoint(tank, point);
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
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 = {
|
typedef PlayerState = {
|
||||||
@@ -11,14 +8,12 @@ typedef PlayerState = {
|
|||||||
var life:Int;
|
var life:Int;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef TeamState = {
|
typedef TeamState = {
|
||||||
var players:Map<Int, PlayerState>;
|
var players:Map<Int, PlayerState>;
|
||||||
var life:Int;
|
var life:Int;
|
||||||
var lose:Bool;
|
var lose:Bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class GameState {
|
class GameState {
|
||||||
public var type:GameType;
|
public var type:GameType;
|
||||||
public var mode:GameMode;
|
public var mode:GameMode;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package ru.m.tankz.game;
|
package ru.m.tankz.game;
|
||||||
|
|
||||||
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 {
|
||||||
|
|||||||
@@ -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,7 +10,6 @@ typedef SpawnTask = {
|
|||||||
var playerId:PlayerId;
|
var playerId:PlayerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class Spawner {
|
class Spawner {
|
||||||
|
|
||||||
public var active(get, never):Bool;
|
public var active(get, never):Bool;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package ru.m.tankz.game;
|
package ru.m.tankz.game;
|
||||||
|
|
||||||
import ru.m.tankz.config.Config.TeamConfig;
|
import ru.m.tankz.config.Config;
|
||||||
import ru.m.tankz.game.Player;
|
import ru.m.tankz.game.Player;
|
||||||
import ru.m.tankz.game.Game;
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
|
||||||
class Team {
|
class Team {
|
||||||
|
|||||||
Reference in New Issue
Block a user