[common] added Dota game type
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tankz",
|
"name": "tankz",
|
||||||
"version": "0.0.7",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"ansi-colors": "^1.0.1",
|
"ansi-colors": "^1.0.1",
|
||||||
|
|||||||
@@ -12,11 +12,11 @@
|
|||||||
<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"/>
|
||||||
<!--<window width="760" height="600"/>-->
|
<window width="1024" height="768" unless="html5"/>
|
||||||
<haxeflag name="-D" value="swf-gpu"/>
|
<haxeflag name="-D" value="swf-gpu"/>
|
||||||
<haxeflag name="-D" value="native-trace"/>
|
<haxeflag name="-D" value="native-trace"/>
|
||||||
<!--<haxeflag name="-D" value="proto_debug"/>-->
|
<!--<haxeflag name="-D" value="proto_debug"/>-->
|
||||||
<haxeflag name="-dce" value="no"/>
|
<haxeflag name="-dce" value="no"/>
|
||||||
|
<haxeflag name="-D" value="dom"/>
|
||||||
<!--<template path="src/client/webapp/index_template.html" rename="index.html"/>-->
|
<!--<template path="src/client/webapp/index_template.html" rename="index.html"/>-->
|
||||||
</project>
|
</project>
|
||||||
@@ -19,9 +19,9 @@
|
|||||||
"@style": "button"
|
"@style": "button"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "start_lan",
|
"id": "dota",
|
||||||
"@type": "haxework.gui.ButtonView",
|
"@type": "haxework.gui.ButtonView",
|
||||||
"text": "Multiplayer",
|
"text": "DotA",
|
||||||
"@style": "button"
|
"@style": "button"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package ru.m.tankz;
|
package ru.m.tankz;
|
||||||
|
|
||||||
import ru.m.tankz.game.ClassicGame;
|
import ru.m.tankz.game.ClassicGame;
|
||||||
|
import ru.m.tankz.game.DotaGame;
|
||||||
import ru.m.tankz.game.Game;
|
import ru.m.tankz.game.Game;
|
||||||
import flash.ui.Keyboard;
|
import flash.ui.Keyboard;
|
||||||
import flash.events.KeyboardEvent;
|
import flash.events.KeyboardEvent;
|
||||||
@@ -76,6 +77,7 @@ class Client implements IConnectionHandler {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Provider.setFactory(Game, ClassicGame, ClassicGame.TYPE);
|
Provider.setFactory(Game, ClassicGame, ClassicGame.TYPE);
|
||||||
|
Provider.setFactory(Game, DotaGame, DotaGame.TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPress(view:ButtonView):Void {
|
public function onPress(view:ButtonView):Void {
|
||||||
|
|||||||
@@ -113,6 +113,14 @@ class TankItem extends RenderItem<Tank> {
|
|||||||
var group = value.config.group;
|
var group = value.config.group;
|
||||||
var index = value.playerId.index;
|
var index = value.playerId.index;
|
||||||
if (group == 'human') group = 'player';
|
if (group == 'human') group = 'player';
|
||||||
|
if (group == 'radiant') {
|
||||||
|
group = 'player';
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
if (group == 'dire') {
|
||||||
|
group = 'player';
|
||||||
|
index = 1;
|
||||||
|
}
|
||||||
if (group == 'bot') index = 0;
|
if (group == 'bot') index = 0;
|
||||||
return 'resources/images/tank/${group}/tank_${group.charAt(0)}${value.config.type}_${index}-0.png';
|
return 'resources/images/tank/${group}/tank_${group.charAt(0)}${value.config.type}_${index}-0.png';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package ru.m.tankz.view.frames;
|
package ru.m.tankz.view.frames;
|
||||||
|
|
||||||
|
import ru.m.tankz.game.Game;
|
||||||
import ru.m.tankz.game.GameState;
|
import ru.m.tankz.game.GameState;
|
||||||
import ru.m.tankz.game.ClassicGame;
|
import ru.m.tankz.game.ClassicGame;
|
||||||
|
import ru.m.tankz.game.DotaGame;
|
||||||
import haxework.gui.frame.IFrameSwitcher;
|
import haxework.gui.frame.IFrameSwitcher;
|
||||||
import haxework.provider.Provider;
|
import haxework.provider.Provider;
|
||||||
import haxework.gui.ButtonView;
|
import haxework.gui.ButtonView;
|
||||||
@@ -9,27 +11,43 @@ import haxework.gui.ViewBuilder;
|
|||||||
import haxework.gui.VGroupView;
|
import haxework.gui.VGroupView;
|
||||||
|
|
||||||
|
|
||||||
|
interface StartFrameLayout {
|
||||||
|
var start_1p(default, null):ButtonView;
|
||||||
|
var start_2p(default, null):ButtonView;
|
||||||
|
var dota(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 {
|
class StartFrame extends VGroupView implements ViewBuilder implements StartFrameLayout {
|
||||||
|
|
||||||
public static inline var ID = "start";
|
public static inline var ID = "start";
|
||||||
|
|
||||||
public function init() {
|
public function init() {
|
||||||
start_1p.onPress = this;
|
start_1p.onPress = this;
|
||||||
start_2p.onPress = this;
|
start_2p.onPress = this;
|
||||||
|
dota.onPress = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPress(view:ButtonView):Void {
|
public function onPress(view:ButtonView):Void {
|
||||||
switch (view.id) {
|
switch (view.id) {
|
||||||
case 'start_1p':
|
case 'start_1p':
|
||||||
startGame(1);
|
startGame(ClassicGame.TYPE, 1);
|
||||||
case 'start_2p':
|
case 'start_2p':
|
||||||
startGame(2);
|
startGame(ClassicGame.TYPE, 2);
|
||||||
|
case 'dota':
|
||||||
|
startGame(DotaGame.TYPE, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function startGame(humans:Int):Void {
|
private function startGame(type:GameType, humans:Int):Void {
|
||||||
|
switch (type) {
|
||||||
|
case ClassicGame.TYPE:
|
||||||
Provider.set(GameState, ClassicGame.buildState(0, humans));
|
Provider.set(GameState, ClassicGame.buildState(0, humans));
|
||||||
Provider.get(IFrameSwitcher).change(LevelFrame.ID);
|
Provider.get(IFrameSwitcher).change(LevelFrame.ID);
|
||||||
|
case DotaGame.TYPE:
|
||||||
|
Provider.set(GameState, DotaGame.buildState(0, humans));
|
||||||
|
Provider.get(IFrameSwitcher).change(GameFrame.ID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
134
src/client/resources/dota/config.yaml
Normal file
134
src/client/resources/dota/config.yaml
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
levels: 36
|
||||||
|
|
||||||
|
map:
|
||||||
|
cellWidth: 22
|
||||||
|
cellHeight: 22
|
||||||
|
gridWidth: 40
|
||||||
|
gridHeight: 30
|
||||||
|
|
||||||
|
bricks:
|
||||||
|
# border
|
||||||
|
- type: -1
|
||||||
|
layer: 2
|
||||||
|
armor: -1
|
||||||
|
# none
|
||||||
|
- type: 0
|
||||||
|
layer: 0
|
||||||
|
armor: 0
|
||||||
|
# ace
|
||||||
|
- type: 1
|
||||||
|
layer: 0
|
||||||
|
armor: 0
|
||||||
|
# bush
|
||||||
|
- type: 2
|
||||||
|
layer: 3
|
||||||
|
armor: 0
|
||||||
|
# water
|
||||||
|
- type: 3
|
||||||
|
layer: 1
|
||||||
|
armor: 0
|
||||||
|
# armor
|
||||||
|
- type: 4
|
||||||
|
layer: 2
|
||||||
|
armor: 2
|
||||||
|
# brick
|
||||||
|
- type: 5
|
||||||
|
layer: 2
|
||||||
|
armor: 1
|
||||||
|
|
||||||
|
teams:
|
||||||
|
- id: radiant
|
||||||
|
spawnInterval: 0
|
||||||
|
points:
|
||||||
|
- type: eagle
|
||||||
|
index: -1
|
||||||
|
x: 0
|
||||||
|
y: 28
|
||||||
|
direction: right
|
||||||
|
- type: tank
|
||||||
|
index: 0
|
||||||
|
x: 0
|
||||||
|
y: 0
|
||||||
|
direction: top
|
||||||
|
- type: tank
|
||||||
|
index: 1
|
||||||
|
x: 6
|
||||||
|
y: 10
|
||||||
|
direction: top
|
||||||
|
- type: tank
|
||||||
|
index: 2
|
||||||
|
x: 6
|
||||||
|
y: 16
|
||||||
|
direction: top
|
||||||
|
- type: tank
|
||||||
|
index: 3
|
||||||
|
x: 6
|
||||||
|
y: 22
|
||||||
|
direction: top
|
||||||
|
- type: tank
|
||||||
|
index: 4
|
||||||
|
x: 10
|
||||||
|
y: 28
|
||||||
|
direction: top
|
||||||
|
- id: dire
|
||||||
|
spawnInterval: 0
|
||||||
|
points:
|
||||||
|
- type: eagle
|
||||||
|
index: -1
|
||||||
|
x: 38
|
||||||
|
y: 0
|
||||||
|
direction: right
|
||||||
|
- type: tank
|
||||||
|
index: 0
|
||||||
|
x: 38
|
||||||
|
y: 28
|
||||||
|
direction: bottom
|
||||||
|
- type: tank
|
||||||
|
index: 1
|
||||||
|
x: 32
|
||||||
|
y: 18
|
||||||
|
direction: bottom
|
||||||
|
- type: tank
|
||||||
|
index: 2
|
||||||
|
x: 32
|
||||||
|
y: 12
|
||||||
|
direction: bottom
|
||||||
|
- type: tank
|
||||||
|
index: 3
|
||||||
|
x: 32
|
||||||
|
y: 6
|
||||||
|
direction: bottom
|
||||||
|
- type: tank
|
||||||
|
index: 4
|
||||||
|
x: 28
|
||||||
|
y: 0
|
||||||
|
direction: bottom
|
||||||
|
|
||||||
|
|
||||||
|
bullet: &bullet
|
||||||
|
width: 12
|
||||||
|
height: 12
|
||||||
|
speed: 0
|
||||||
|
piercing: 1
|
||||||
|
|
||||||
|
tanks:
|
||||||
|
radiant: &tanks
|
||||||
|
- type: 0
|
||||||
|
width: 36
|
||||||
|
height: 36
|
||||||
|
speed: 2.5
|
||||||
|
bullet:
|
||||||
|
<<: *bullet
|
||||||
|
speed: 8.0
|
||||||
|
bullets: 1
|
||||||
|
|
||||||
|
- type: 1
|
||||||
|
width: 40
|
||||||
|
height: 36
|
||||||
|
speed: 3.0
|
||||||
|
bullet:
|
||||||
|
<<: *bullet
|
||||||
|
speed: 8.5
|
||||||
|
bullets: 1
|
||||||
|
dire:
|
||||||
|
- <<: *tanks
|
||||||
30
src/client/resources/dota/levels/level000.txt
Normal file
30
src/client/resources/dota/levels/level000.txt
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
0000000000000000000000000000000000005500
|
||||||
|
0000000000000000000000000000000000005500
|
||||||
|
0000000000000000000000000000000000005555
|
||||||
|
0000000000000000000000000000000000005555
|
||||||
|
0000000000000000000000000000000000000000
|
||||||
|
0000000000000000000000000000000000000000
|
||||||
|
0000000000000000000000000000000000000000
|
||||||
|
0000000000000000000000000000000000000000
|
||||||
|
0000000000000000000000000000000000000000
|
||||||
|
0000000000000000000000000000000000000000
|
||||||
|
0000000000000000000000000000000000000000
|
||||||
|
0000000000000000000000000000000000000000
|
||||||
|
0000000000000000000000000000000000000000
|
||||||
|
0000000000000000000000000000000000000000
|
||||||
|
0000000000000000000000000000000000000000
|
||||||
|
0000000000000000000000000000000000000000
|
||||||
|
0000000000000000000000000000000000000000
|
||||||
|
0000000000000000000000000000000000000000
|
||||||
|
0000000000000000000000000000000000000000
|
||||||
|
0000000000000000000000000000000000000000
|
||||||
|
0000000000000000000000000000000000000000
|
||||||
|
0000000000000000000000000000000000000000
|
||||||
|
0000000000000000000000000000000000000000
|
||||||
|
0000000000000000000000000000000000000000
|
||||||
|
0000000000000000000000000000000000000000
|
||||||
|
0000000000000000000000000000000000000000
|
||||||
|
5555000000000000000000000000000000000000
|
||||||
|
5555000000000000000000000000000000000000
|
||||||
|
0055000000000000000000000000000000000000
|
||||||
|
0055000000000000000000000000000000000000
|
||||||
@@ -22,8 +22,6 @@ class ConfigBundle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function get(type:String):Config {
|
public static function get(type:String):Config {
|
||||||
switch (type) {
|
|
||||||
case ClassicGame.TYPE:
|
|
||||||
var source:ConfigSource = convert(Yaml.parse(Assets.getText('resources/${type}/config.yaml'), Parser.options().useObjects()));
|
var source:ConfigSource = convert(Yaml.parse(Assets.getText('resources/${type}/config.yaml'), Parser.options().useObjects()));
|
||||||
var tanks:Array<TankConfig> = [];
|
var tanks:Array<TankConfig> = [];
|
||||||
for (group in Reflect.fields(source.tanks)) {
|
for (group in Reflect.fields(source.tanks)) {
|
||||||
@@ -34,8 +32,5 @@ class ConfigBundle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new Config(type, source.levels, source.map, source.bricks, source.teams, tanks);
|
return new Config(type, source.levels, source.map, source.bricks, source.teams, tanks);
|
||||||
case _:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
56
src/common/haxe/ru/m/tankz/game/DotaGame.hx
Normal file
56
src/common/haxe/ru/m/tankz/game/DotaGame.hx
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
package ru.m.tankz.game;
|
||||||
|
|
||||||
|
import ru.m.tankz.game.Game;
|
||||||
|
import ru.m.tankz.game.GameState;
|
||||||
|
|
||||||
|
|
||||||
|
class DotaGame extends Game {
|
||||||
|
|
||||||
|
public static var TYPE(default, never):GameType = 'dota';
|
||||||
|
|
||||||
|
public static var RADIANT(default, never):TeamId = 'radiant';
|
||||||
|
public static var DIRE(default, never):TeamId = 'dire';
|
||||||
|
|
||||||
|
private static var TEAM_SIZE(default, never):Int = 5;
|
||||||
|
|
||||||
|
public function new() {
|
||||||
|
super(TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function buildState(level:Int, humans:Int):GameState {
|
||||||
|
var state = new GameState();
|
||||||
|
state.type = TYPE;
|
||||||
|
state.level = level;
|
||||||
|
state.players[RADIANT] = new Map();
|
||||||
|
state.players[DIRE] = new Map();
|
||||||
|
for (i in 0...TEAM_SIZE) {
|
||||||
|
state.players[RADIANT][i] = {
|
||||||
|
index:i,
|
||||||
|
tank:{
|
||||||
|
group: RADIANT,
|
||||||
|
type: '1'
|
||||||
|
},
|
||||||
|
control:{
|
||||||
|
type: 'bot',
|
||||||
|
index: i
|
||||||
|
},
|
||||||
|
life:-1,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
for (i in 0...TEAM_SIZE) {
|
||||||
|
state.players[DIRE][i] = {
|
||||||
|
index:i,
|
||||||
|
tank:{
|
||||||
|
group: DIRE,
|
||||||
|
type: '1'
|
||||||
|
},
|
||||||
|
control:{
|
||||||
|
type: 'bot',
|
||||||
|
index: i
|
||||||
|
},
|
||||||
|
life:-1,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -74,12 +74,15 @@ class Game implements EngineListener {
|
|||||||
var control = switch (playerState.control.type) {
|
var control = switch (playerState.control.type) {
|
||||||
case HumanControl.TYPE: new HumanControl(playerState.control.index);
|
case HumanControl.TYPE: new HumanControl(playerState.control.index);
|
||||||
case BotControl.TYPE: new BotControl(playerState.control.index);
|
case BotControl.TYPE: new BotControl(playerState.control.index);
|
||||||
|
case 'none': null;
|
||||||
case _: throw 'Unsupported control type: "${playerState.control.type}"';
|
case _: throw 'Unsupported control type: "${playerState.control.type}"';
|
||||||
}
|
}
|
||||||
|
if (control != null) {
|
||||||
player.control = control;
|
player.control = control;
|
||||||
player.control.bind(engine);
|
player.control.bind(engine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
spawners.set(team.id, new Spawner(team.config, spawn));
|
spawners.set(team.id, new Spawner(team.config, spawn));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class LevelMap {
|
|||||||
bricksMap = new HashMap();
|
bricksMap = new HashMap();
|
||||||
bricks = Lambda.array(Lambda.mapi(data, function(i:Int, brickConfig:BrickConfig):Brick {
|
bricks = Lambda.array(Lambda.mapi(data, function(i:Int, brickConfig:BrickConfig):Brick {
|
||||||
var cellX = Std.int(i % gridWidth);
|
var cellX = Std.int(i % gridWidth);
|
||||||
var cellY = Std.int(Math.floor(i / gridHeight));
|
var cellY = Std.int(Math.floor(i / gridWidth));
|
||||||
var cells:HashMap<Point, GridCell> = new HashMap();
|
var cells:HashMap<Point, GridCell> = new HashMap();
|
||||||
var point:Point = new Point(cellX * 2, cellY * 2);
|
var point:Point = new Point(cellX * 2, cellY * 2);
|
||||||
if (brickConfig.layer > 0 || brickConfig.armor > 0) {
|
if (brickConfig.layer > 0 || brickConfig.armor > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user