[common] added Dota game type
This commit is contained in:
@@ -19,9 +19,9 @@
|
||||
"@style": "button"
|
||||
},
|
||||
{
|
||||
"id": "start_lan",
|
||||
"id": "dota",
|
||||
"@type": "haxework.gui.ButtonView",
|
||||
"text": "Multiplayer",
|
||||
"text": "DotA",
|
||||
"@style": "button"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ru.m.tankz;
|
||||
|
||||
import ru.m.tankz.game.ClassicGame;
|
||||
import ru.m.tankz.game.DotaGame;
|
||||
import ru.m.tankz.game.Game;
|
||||
import flash.ui.Keyboard;
|
||||
import flash.events.KeyboardEvent;
|
||||
@@ -76,6 +77,7 @@ class Client implements IConnectionHandler {
|
||||
});
|
||||
|
||||
Provider.setFactory(Game, ClassicGame, ClassicGame.TYPE);
|
||||
Provider.setFactory(Game, DotaGame, DotaGame.TYPE);
|
||||
}
|
||||
|
||||
public function onPress(view:ButtonView):Void {
|
||||
|
||||
@@ -113,6 +113,14 @@ class TankItem extends RenderItem<Tank> {
|
||||
var group = value.config.group;
|
||||
var index = value.playerId.index;
|
||||
if (group == 'human') group = 'player';
|
||||
if (group == 'radiant') {
|
||||
group = 'player';
|
||||
index = 0;
|
||||
}
|
||||
if (group == 'dire') {
|
||||
group = 'player';
|
||||
index = 1;
|
||||
}
|
||||
if (group == 'bot') index = 0;
|
||||
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;
|
||||
|
||||
import ru.m.tankz.game.Game;
|
||||
import ru.m.tankz.game.GameState;
|
||||
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;
|
||||
@@ -9,27 +11,43 @@ import haxework.gui.ViewBuilder;
|
||||
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")
|
||||
class StartFrame extends VGroupView implements ViewBuilder {
|
||||
class StartFrame extends VGroupView implements ViewBuilder implements StartFrameLayout {
|
||||
|
||||
public static inline var ID = "start";
|
||||
|
||||
public function init() {
|
||||
start_1p.onPress = this;
|
||||
start_2p.onPress = this;
|
||||
dota.onPress = this;
|
||||
}
|
||||
|
||||
public function onPress(view:ButtonView):Void {
|
||||
switch (view.id) {
|
||||
case 'start_1p':
|
||||
startGame(1);
|
||||
startGame(ClassicGame.TYPE, 1);
|
||||
case 'start_2p':
|
||||
startGame(2);
|
||||
startGame(ClassicGame.TYPE, 2);
|
||||
case 'dota':
|
||||
startGame(DotaGame.TYPE, 2);
|
||||
}
|
||||
}
|
||||
|
||||
private function startGame(humans:Int):Void {
|
||||
Provider.set(GameState, ClassicGame.buildState(0, humans));
|
||||
Provider.get(IFrameSwitcher).change(LevelFrame.ID);
|
||||
private function startGame(type:GameType, humans:Int):Void {
|
||||
switch (type) {
|
||||
case ClassicGame.TYPE:
|
||||
Provider.set(GameState, ClassicGame.buildState(0, humans));
|
||||
Provider.get(IFrameSwitcher).change(LevelFrame.ID);
|
||||
case DotaGame.TYPE:
|
||||
Provider.set(GameState, DotaGame.buildState(0, humans));
|
||||
Provider.get(IFrameSwitcher).change(GameFrame.ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user