[common] added Type bundle
This commit is contained in:
@@ -1,18 +1,17 @@
|
||||
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.ui.Keyboard;
|
||||
import flash.events.KeyboardEvent;
|
||||
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>;
|
||||
|
||||
|
||||
class HumanControl extends Control {
|
||||
|
||||
private var keyBinding:KeyBinding;
|
||||
|
||||
@@ -1,28 +1,25 @@
|
||||
package ru.m.tankz.render;
|
||||
|
||||
import ru.m.draw.BitmapUtil;
|
||||
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.Bitmap;
|
||||
import flash.display.DisplayObject;
|
||||
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.Rectangle;
|
||||
import ru.m.tankz.control.Control;
|
||||
import ru.m.tankz.core.Bullet;
|
||||
import ru.m.tankz.map.Brick;
|
||||
import openfl.Assets;
|
||||
import ru.m.tankz.core.Eagle;
|
||||
import ru.m.tankz.core.Tank;
|
||||
import flash.display.Bitmap;
|
||||
import ru.m.tankz.map.Brick;
|
||||
|
||||
|
||||
typedef TRectangle = {
|
||||
var rect(default, null):Rectangle;
|
||||
}
|
||||
|
||||
|
||||
class RenderItem<T:TRectangle, D:DisplayObject> {
|
||||
|
||||
public var value(default, null):T;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package ru.m.tankz.view.frames;
|
||||
|
||||
import ru.m.tankz.game.Game;
|
||||
import ru.m.tankz.game.GameState;
|
||||
import haxework.gui.ButtonView;
|
||||
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.DotaGame;
|
||||
import haxework.gui.frame.IFrameSwitcher;
|
||||
import haxework.provider.Provider;
|
||||
import haxework.gui.ButtonView;
|
||||
import haxework.gui.ViewBuilder;
|
||||
import haxework.gui.VGroupView;
|
||||
import ru.m.tankz.game.GameState;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
|
||||
interface StartFrameLayout {
|
||||
@@ -19,7 +19,6 @@ interface StartFrameLayout {
|
||||
var dota_2p_vs(default, null):ButtonView;
|
||||
}
|
||||
|
||||
|
||||
@:template("layout/frames/start.json", "layout/styles.json")
|
||||
class StartFrame extends VGroupView implements ViewBuilder implements StartFrameLayout {
|
||||
|
||||
|
||||
@@ -20,14 +20,14 @@ bricks:
|
||||
teams:
|
||||
- id: human
|
||||
tanks:
|
||||
- {group: human, type: 0, rate: 1}
|
||||
- {type: human0, rate: 1}
|
||||
- id: bot
|
||||
spawnInterval: 3000
|
||||
tanks:
|
||||
- {group: bot, type: 0, rate: 0.5}
|
||||
- {group: bot, type: 1, rate: 0.5}
|
||||
- {group: bot, type: 2, rate: 0.5}
|
||||
- {group: bot, type: 3, rate: 0.5}
|
||||
- {type: bot0, rate: 0.5}
|
||||
- {type: bot1, rate: 0.5}
|
||||
- {type: bot2, rate: 0.5}
|
||||
- {type: bot3, rate: 0.5}
|
||||
|
||||
points:
|
||||
- {team: human, type: eagle, index: -1, direction: right, x: 12, y: 24}
|
||||
@@ -44,91 +44,89 @@ bullet: &bullet
|
||||
piercing: 1
|
||||
|
||||
tanks:
|
||||
human:
|
||||
- type: 0
|
||||
width: 36
|
||||
height: 36
|
||||
speed: 2.5
|
||||
bullet:
|
||||
<<: *bullet
|
||||
speed: 8.0
|
||||
bullets: 1
|
||||
skin: pa
|
||||
- type: human0
|
||||
width: 36
|
||||
height: 36
|
||||
speed: 2.5
|
||||
bullet:
|
||||
<<: *bullet
|
||||
speed: 8.0
|
||||
bullets: 1
|
||||
skin: pa
|
||||
|
||||
- type: 1
|
||||
width: 40
|
||||
height: 36
|
||||
speed: 3.0
|
||||
bullet:
|
||||
<<: *bullet
|
||||
speed: 8.5
|
||||
bullets: 1
|
||||
skin: pb
|
||||
- type: human1
|
||||
width: 40
|
||||
height: 36
|
||||
speed: 3.0
|
||||
bullet:
|
||||
<<: *bullet
|
||||
speed: 8.5
|
||||
bullets: 1
|
||||
skin: pb
|
||||
|
||||
- type: 2
|
||||
width: 40
|
||||
height: 36
|
||||
speed: 3.0
|
||||
bullet:
|
||||
<<: *bullet
|
||||
speed: 9.0
|
||||
bullets: 2
|
||||
skin: pc
|
||||
- type: human2
|
||||
width: 40
|
||||
height: 36
|
||||
speed: 3.0
|
||||
bullet:
|
||||
<<: *bullet
|
||||
speed: 9.0
|
||||
bullets: 2
|
||||
skin: pc
|
||||
|
||||
- type: 3
|
||||
width: 42
|
||||
height: 38
|
||||
speed: 2.9
|
||||
bullet:
|
||||
<<: *bullet
|
||||
speed: 9.0
|
||||
piercing: 3
|
||||
bullets: 2
|
||||
hits: 1
|
||||
skin: pd
|
||||
- type: human3
|
||||
width: 42
|
||||
height: 38
|
||||
speed: 2.9
|
||||
bullet:
|
||||
<<: *bullet
|
||||
speed: 9.0
|
||||
piercing: 3
|
||||
bullets: 2
|
||||
hits: 1
|
||||
skin: pd
|
||||
|
||||
bot:
|
||||
- type: 0
|
||||
width: 38
|
||||
height: 36
|
||||
speed: 2.0
|
||||
bullet:
|
||||
<<: *bullet
|
||||
speed: 7.0
|
||||
bullets: 1
|
||||
score: 100
|
||||
skin: ba
|
||||
- type: bot0
|
||||
width: 38
|
||||
height: 36
|
||||
speed: 2.0
|
||||
bullet:
|
||||
<<: *bullet
|
||||
speed: 7.0
|
||||
bullets: 1
|
||||
score: 100
|
||||
skin: ba
|
||||
|
||||
- type: 1
|
||||
width: 40
|
||||
height: 36
|
||||
speed: 4.0
|
||||
bullet:
|
||||
<<: *bullet
|
||||
speed: 7.0
|
||||
bullets: 1
|
||||
score: 200
|
||||
skin: bb
|
||||
- type: bot1
|
||||
width: 40
|
||||
height: 36
|
||||
speed: 4.0
|
||||
bullet:
|
||||
<<: *bullet
|
||||
speed: 7.0
|
||||
bullets: 1
|
||||
score: 200
|
||||
skin: bb
|
||||
|
||||
- type: 2
|
||||
width: 38
|
||||
height: 36
|
||||
speed: 2.0
|
||||
bullet:
|
||||
<<: *bullet
|
||||
speed: 9.0
|
||||
bullets: 1
|
||||
score: 300
|
||||
skin: bc
|
||||
- type: bot2
|
||||
width: 38
|
||||
height: 36
|
||||
speed: 2.0
|
||||
bullet:
|
||||
<<: *bullet
|
||||
speed: 9.0
|
||||
bullets: 1
|
||||
score: 300
|
||||
skin: bc
|
||||
|
||||
- type: 3
|
||||
width: 40
|
||||
height: 36
|
||||
speed: 1.8
|
||||
bullet:
|
||||
<<: *bullet
|
||||
speed: 8.0
|
||||
bullets: 1
|
||||
score: 400
|
||||
hits: 3
|
||||
skin: bd
|
||||
- type: bot3
|
||||
width: 40
|
||||
height: 36
|
||||
speed: 1.8
|
||||
bullet:
|
||||
<<: *bullet
|
||||
speed: 8.0
|
||||
bullets: 1
|
||||
score: 400
|
||||
hits: 3
|
||||
skin: bd
|
||||
|
||||
@@ -19,8 +19,8 @@ bricks:
|
||||
|
||||
team_tanks: &team_tanks
|
||||
tanks:
|
||||
- {group: any, type: 0, rate: 0.5}
|
||||
- {group: any, type: 1, rate: 0.5}
|
||||
- {type: slow, rate: 0.5}
|
||||
- {type: fast, rate: 0.5}
|
||||
|
||||
teams:
|
||||
- <<: *team_tanks
|
||||
@@ -51,23 +51,22 @@ bullet: &bullet
|
||||
piercing: 1
|
||||
|
||||
tanks:
|
||||
any:
|
||||
- type: 0
|
||||
width: 38
|
||||
height: 36
|
||||
speed: 2.0
|
||||
bullet:
|
||||
<<: *bullet
|
||||
speed: 10.0
|
||||
bullets: 1
|
||||
skin: bc
|
||||
- type: slow
|
||||
width: 38
|
||||
height: 36
|
||||
speed: 2.0
|
||||
bullet:
|
||||
<<: *bullet
|
||||
speed: 10.0
|
||||
bullets: 1
|
||||
skin: bc
|
||||
|
||||
- type: 1
|
||||
width: 40
|
||||
height: 36
|
||||
speed: 4.0
|
||||
bullet:
|
||||
<<: *bullet
|
||||
speed: 7.0
|
||||
bullets: 1
|
||||
skin: bb
|
||||
- type: fast
|
||||
width: 40
|
||||
height: 36
|
||||
speed: 4.0
|
||||
bullet:
|
||||
<<: *bullet
|
||||
speed: 7.0
|
||||
bullets: 1
|
||||
skin: bb
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
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 ru.m.tankz.proto.pack.ErrorResponse;
|
||||
import ru.m.tankz.proto.pack.GameListRequest;
|
||||
import ru.m.tankz.proto.pack.GameListResponse;
|
||||
import ru.m.connect.IConnection;
|
||||
import ru.m.tankz.proto.pack.CreateGameRequest;
|
||||
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.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.StartGameResponse;
|
||||
import Type;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
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 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 {
|
||||
@@ -46,7 +45,6 @@ class BotHelper {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class BotControl extends Control {
|
||||
|
||||
private var shotTimer:Timer;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ru.m.tankz.config;
|
||||
|
||||
import ru.m.draw.Color;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
|
||||
typedef GameConfig = {
|
||||
@@ -9,7 +10,7 @@ typedef GameConfig = {
|
||||
}
|
||||
|
||||
typedef SpawnPoint = {
|
||||
var team:String;
|
||||
var team:TeamId;
|
||||
var type:String;
|
||||
var index:Int;
|
||||
var x:Int;
|
||||
@@ -37,13 +38,8 @@ typedef BulletConfig = {
|
||||
var piercing:Int;
|
||||
}
|
||||
|
||||
|
||||
typedef TankType = {
|
||||
var group:String;
|
||||
var type:String;
|
||||
}
|
||||
|
||||
typedef TankConfig = { > TankType,
|
||||
typedef TankConfig = {
|
||||
var type:TankType;
|
||||
var width:Float;
|
||||
var height:Float;
|
||||
var speed:Float;
|
||||
@@ -53,13 +49,14 @@ typedef TankConfig = { > TankType,
|
||||
var skin:String;
|
||||
}
|
||||
|
||||
typedef TankSpawn = { > TankType,
|
||||
typedef TankSpawn = {
|
||||
var type:TankType;
|
||||
var rate: Float;
|
||||
}
|
||||
|
||||
|
||||
typedef TeamConfig = {
|
||||
var id:String;
|
||||
var id:TeamId;
|
||||
var size:Int;
|
||||
var tanks:Array<TankSpawn>;
|
||||
@:optional var spawnInterval:Int;
|
||||
@@ -83,7 +80,7 @@ class Config {
|
||||
public var points(default, null):Array<SpawnPoint>;
|
||||
|
||||
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>;
|
||||
|
||||
public function new(
|
||||
@@ -116,8 +113,7 @@ class Config {
|
||||
}
|
||||
tankMap = new Map();
|
||||
for (item in tanks) {
|
||||
if (!tankMap.exists(item.group)) tankMap.set(item.group, new Map<String, TankConfig>());
|
||||
tankMap.get(item.group).set(item.type, item);
|
||||
tankMap.set(item.type, item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +125,7 @@ class Config {
|
||||
return teamMap.get(id);
|
||||
}
|
||||
|
||||
public function getTank(group:String, type:String):TankConfig {
|
||||
return tankMap.get(group).get(type);
|
||||
public function getTank(type:TankType):TankConfig {
|
||||
return tankMap.get(type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ typedef ConfigSource = {
|
||||
var bricks: Array<BrickConfig>;
|
||||
var teams: Array<TeamConfig>;
|
||||
var points: Array<SpawnPoint>;
|
||||
var tanks: Dynamic<Array<TankConfig>>;
|
||||
var tanks: Array<TankConfig>;
|
||||
}
|
||||
|
||||
class ConfigBundle {
|
||||
@@ -22,15 +22,7 @@ class ConfigBundle {
|
||||
}
|
||||
|
||||
public static function get(type:String):Config {
|
||||
var source:ConfigSource = convert(Yaml.parse(Assets.getText('resources/${type}/config.yaml'), Parser.options().useObjects()));
|
||||
var tanks:Array<TankConfig> = [];
|
||||
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);
|
||||
var source = convert(Yaml.parse(Assets.getText('resources/${type}/config.yaml'), Parser.options().useObjects()));
|
||||
return new Config(type, source.game, source.map, source.bricks, source.teams, source.points, source.tanks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package ru.m.tankz.config;
|
||||
|
||||
import yaml.Renderer;
|
||||
import yaml.Parser;
|
||||
import yaml.Yaml;
|
||||
import openfl.Assets;
|
||||
import ru.m.tankz.game.Game;
|
||||
import ru.m.tankz.config.Config;
|
||||
import ru.m.tankz.Type;
|
||||
import yaml.Parser;
|
||||
import yaml.Renderer;
|
||||
import yaml.Yaml;
|
||||
|
||||
|
||||
typedef LevelSource = {
|
||||
@@ -13,7 +13,6 @@ typedef LevelSource = {
|
||||
@:optional var points:Array<SpawnPoint>;
|
||||
}
|
||||
|
||||
|
||||
class LevelBundle {
|
||||
|
||||
private static function formatLevel(level:Int):String {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
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.EntityType;
|
||||
import ru.m.geom.Direction;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
|
||||
enum TankAction {
|
||||
@@ -14,9 +14,6 @@ enum TankAction {
|
||||
}
|
||||
|
||||
|
||||
typedef ControlType = String;
|
||||
|
||||
|
||||
class Control {
|
||||
public static var NONE(default, never):ControlType = 'none';
|
||||
public static var HUMAN(default, never):ControlType = 'human';
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
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.Rectangle;
|
||||
import ru.m.tankz.config.Config;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
|
||||
class Bullet extends MobileEntity {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package ru.m.tankz.core;
|
||||
|
||||
import ru.m.tankz.game.Game;
|
||||
import ru.m.geom.Rectangle;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
|
||||
class Eagle extends Entity {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ru.m.tankz.core;
|
||||
|
||||
import ru.m.geom.Rectangle;
|
||||
import Type;
|
||||
|
||||
|
||||
class Entity implements IKey {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package ru.m.tankz.core;
|
||||
|
||||
import Type.ValueType;
|
||||
import Type;
|
||||
import ru.m.tankz.map.Grid.GridCell;
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package ru.m.tankz.core;
|
||||
|
||||
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.Rectangle;
|
||||
import ru.m.tankz.config.Config;
|
||||
import ru.m.tankz.core.Bullet;
|
||||
import ru.m.geom.Rectangle;
|
||||
import ru.m.geom.Direction;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
|
||||
class Tank extends MobileEntity {
|
||||
|
||||
@@ -133,7 +133,13 @@ class Engine implements ControlHandler {
|
||||
tank.move(direction);
|
||||
case TankAction.LEVEL_UP(level):
|
||||
// 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:
|
||||
tank.stop();
|
||||
case TankAction.SHOT:
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package ru.m.tankz.game;
|
||||
|
||||
import haxe.ds.Option;
|
||||
import ru.m.draw.Color;
|
||||
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.GameState.PlayerState;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
|
||||
class ClassicGame extends Game {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package ru.m.tankz.game;
|
||||
|
||||
import haxe.ds.Option;
|
||||
import ru.m.draw.Color;
|
||||
import ru.m.tankz.control.Control;
|
||||
import haxe.ds.Option;
|
||||
import ru.m.tankz.game.Game;
|
||||
import ru.m.tankz.game.GameState;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
|
||||
class DotaGame extends Game {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package ru.m.tankz.game;
|
||||
|
||||
import ru.m.draw.Color;
|
||||
import haxe.ds.Option;
|
||||
import haxe.Timer;
|
||||
import promhx.Deferred;
|
||||
@@ -20,25 +19,12 @@ import ru.m.tankz.core.Tank;
|
||||
import ru.m.tankz.engine.Engine;
|
||||
import ru.m.tankz.game.GameState;
|
||||
import ru.m.tankz.game.Spawner;
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
|
||||
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 state(default, null):GameState;
|
||||
@@ -63,9 +49,9 @@ class Game implements EngineListener {
|
||||
}
|
||||
|
||||
private function buildTank(playerId:PlayerId, point:SpawnPoint):Tank {
|
||||
var types:Array<TankSpawn> = teams[playerId.team].config.tanks;
|
||||
var type:TankSpawn = types[Math.floor(Math.random() * types.length)];
|
||||
var tankConfig:TankConfig = config.getTank(type.group, type.type);
|
||||
var spawns:Array<TankSpawn> = teams[playerId.team].config.tanks;
|
||||
var spawn:TankSpawn = spawns[Math.floor(Math.random() * spawns.length)];
|
||||
var tankConfig:TankConfig = config.getTank(spawn.type);
|
||||
var tank = new Tank(playerId, tankConfig);
|
||||
tank.color = playerId.color.zero ? teams[playerId.team].config.color : playerId.color;
|
||||
applyPoint(tank, point);
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package ru.m.tankz.game;
|
||||
|
||||
import ru.m.tankz.game.Game;
|
||||
|
||||
|
||||
typedef ControlType = String;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
|
||||
typedef PlayerState = {
|
||||
@@ -11,14 +8,12 @@ typedef PlayerState = {
|
||||
var life:Int;
|
||||
}
|
||||
|
||||
|
||||
typedef TeamState = {
|
||||
var players:Map<Int, PlayerState>;
|
||||
var life:Int;
|
||||
var lose:Bool;
|
||||
}
|
||||
|
||||
|
||||
class GameState {
|
||||
public var type:GameType;
|
||||
public var mode:GameMode;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package ru.m.tankz.game;
|
||||
|
||||
import ru.m.tankz.control.Control;
|
||||
import ru.m.tankz.game.Game;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
|
||||
class Player {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package ru.m.tankz.game;
|
||||
|
||||
|
||||
import haxe.Timer;
|
||||
import ru.m.tankz.game.Game;
|
||||
import ru.m.tankz.config.Config;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
|
||||
typedef SpawnTask = {
|
||||
@@ -11,7 +10,6 @@ typedef SpawnTask = {
|
||||
var playerId:PlayerId;
|
||||
}
|
||||
|
||||
|
||||
class Spawner {
|
||||
|
||||
public var active(get, never):Bool;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
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.Game;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
|
||||
class Team {
|
||||
|
||||
Reference in New Issue
Block a user