[common] add hard bot
This commit is contained in:
@@ -30,7 +30,8 @@ class Style {
|
||||
Skin.text(textColor, 16, fontFamily),
|
||||
]);
|
||||
resources.skin.put("text.header", [
|
||||
Skin.color(lightColor),
|
||||
Skin.color(0x000000, 0.1),
|
||||
Skin.border(lightColor, 1, 2),
|
||||
Skin.text(textColor, 22, fontFamily),
|
||||
Skin.size(200, 38),
|
||||
]);
|
||||
@@ -40,11 +41,13 @@ class Style {
|
||||
Skin.size(250, 50)
|
||||
]);
|
||||
resources.skin.put("text.box", [
|
||||
Skin.color(lightColor),
|
||||
Skin.color(0x000000, 0.1),
|
||||
Skin.border(lightColor, 1, 2),
|
||||
Skin.text(textColor, 16, fontFamily),
|
||||
]);
|
||||
resources.skin.put("text.box.active", [
|
||||
Skin.color(0x55aa55),
|
||||
Skin.border(0x88dd88, 1, 2),
|
||||
Skin.text(textColor, 16, fontFamily),
|
||||
]);
|
||||
resources.skin.put("button.simple", [
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
package ru.m.tankz.control;
|
||||
|
||||
import ru.m.tankz.bot.StupidBotControl;
|
||||
import ru.m.tankz.bot.HardBotControl;
|
||||
import ru.m.tankz.control.Control.Controller;
|
||||
import ru.m.tankz.Type;
|
||||
import ru.m.tankz.bot.BotControl;
|
||||
|
||||
|
||||
class ClientControlFactory implements IControlFactory {
|
||||
|
||||
private var humanControlIndex:Int;
|
||||
|
||||
public function new() {
|
||||
humanControlIndex = 0;
|
||||
}
|
||||
|
||||
public function build(id:PlayerId, type:ControlType):Control {
|
||||
return switch (type) {
|
||||
case Control.HUMAN: new HumanControl(id, humanControlIndex++);
|
||||
case Control.BOT: new BotControl(id);
|
||||
case Control.NONE: null;
|
||||
case _: throw 'Unsupported control type: "${type}"';
|
||||
public function build(id:PlayerId, controller:Controller):Control {
|
||||
return switch controller {
|
||||
case HUMAN(index): new HumanControl(id, index);
|
||||
case BOT(type): switch type {
|
||||
case StupidBotControl.BOT_TYPE: new StupidBotControl(id);
|
||||
case HardBotControl.BOT_TYPE: new HardBotControl(id);
|
||||
case _: null;
|
||||
}
|
||||
case NONE: null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,10 @@ import ru.m.tankz.preset.DotaGame;
|
||||
}
|
||||
|
||||
public function onShow() {
|
||||
resultView.data = resultState.players.filter(function(player) return player.control == Control.HUMAN);
|
||||
resultView.data = resultState.players.filter(function(player) return switch player.controller {
|
||||
case HUMAN(_): true;
|
||||
case _: false;
|
||||
});
|
||||
levelLabel.text = 'Level: ${resultState.level}';
|
||||
nextButton.visible = state != null;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
views:
|
||||
- $type: haxework.gui.VGroupView
|
||||
skinId: container
|
||||
layout.margin: 3
|
||||
layout.margin: 5
|
||||
views:
|
||||
- $type: haxework.gui.ImageView
|
||||
image: $asset:image:resources/image/ui/logo.png
|
||||
|
||||
@@ -8,8 +8,7 @@ views:
|
||||
$type: haxework.gui.LabelView
|
||||
skinId: text.box
|
||||
geometry.size.height: 38
|
||||
geometry.padding: [20, 0]
|
||||
geometry.hAlign: center
|
||||
geometry.size.width: 100%
|
||||
- $type: haxework.gui.SpriteView
|
||||
geometry.size.height: 50%
|
||||
- id: bot
|
||||
|
||||
@@ -5,6 +5,7 @@ import haxework.gui.GroupView;
|
||||
import haxework.resources.IResources;
|
||||
import ru.m.tankz.bundle.IConfigBundle;
|
||||
import ru.m.tankz.config.Config;
|
||||
import ru.m.tankz.control.Control.Controller;
|
||||
import ru.m.tankz.game.GameState;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
@@ -35,7 +36,8 @@ class LevelFrame extends GroupView {
|
||||
for (team in value.teams) {
|
||||
for (player in team.players) {
|
||||
var playerId = new PlayerId(team.id, player.index);
|
||||
state.players.push(new PlayerState(playerId, player.control, player.life));
|
||||
var controller = player.human ? HUMAN(player.index) : NONE;
|
||||
state.players.push(new PlayerState(playerId, controller, player.life));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package ru.m.tankz.frame.common;
|
||||
|
||||
import haxework.color.ColorUtil;
|
||||
import ru.m.tankz.control.Control;
|
||||
import haxework.gui.DataView;
|
||||
import haxework.gui.HGroupView;
|
||||
import haxework.gui.LabelView;
|
||||
import haxework.gui.skin.ISkin;
|
||||
import haxework.gui.ToggleButtonView;
|
||||
import ru.m.tankz.control.Control;
|
||||
import ru.m.tankz.game.GameState;
|
||||
import ru.m.tankz.Type.TeamId;
|
||||
|
||||
@@ -42,7 +42,7 @@ class TeamSkin implements ISkin<TeamButton> {
|
||||
}
|
||||
|
||||
@:template class PlayerView extends HGroupView {
|
||||
private static inline var NONE:TeamId = "none";
|
||||
private static inline var TEAM_NONE:TeamId = "none";
|
||||
|
||||
public var item_index(default, set):Int;
|
||||
public var data(default, set):Array<PlayerState>;
|
||||
@@ -59,13 +59,13 @@ class TeamSkin implements ISkin<TeamButton> {
|
||||
view.skin = [new TeamSkin(getTeamColor(team))];
|
||||
view.geometry.padding = [10, 5];
|
||||
view.team = team;
|
||||
view.on = team == NONE;
|
||||
view.on = team == TEAM_NONE;
|
||||
return view;
|
||||
}
|
||||
|
||||
private function set_data(value:Array<PlayerState>):Array<PlayerState> {
|
||||
data = value;
|
||||
teams.data = [NONE].concat([for (team in state.preset.teams) team.id]);
|
||||
teams.data = [TEAM_NONE].concat([for (team in state.preset.teams) team.id]);
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -88,16 +88,20 @@ class TeamSkin implements ISkin<TeamButton> {
|
||||
|
||||
private function onTeamSelect(team:TeamId) {
|
||||
if (player != null) {
|
||||
player.control = Control.BOT;
|
||||
player.controller = NONE;
|
||||
player.color = 0;
|
||||
player = null;
|
||||
}
|
||||
for (p in data) {
|
||||
if (p.id.team == team && p.control != Control.HUMAN) {
|
||||
player = p;
|
||||
player.control = Control.HUMAN;
|
||||
player.color = ColorUtil.multiply(state.config.getTeam(team).color, 1.7);
|
||||
break;
|
||||
if (p.id.team == team) {
|
||||
switch (p.controller) {
|
||||
case NONE:
|
||||
player = p;
|
||||
player.controller = HUMAN(item_index);
|
||||
player.color = ColorUtil.multiply(state.config.getTeam(team).color, 1.7);
|
||||
break;
|
||||
case _:
|
||||
}
|
||||
}
|
||||
}
|
||||
for (view in teams.views) {
|
||||
|
||||
@@ -7,14 +7,14 @@ views:
|
||||
tank: bc
|
||||
color: 0xff4422
|
||||
- $type: haxework.gui.SpriteView
|
||||
geometry.size.width: 50%
|
||||
geometry.size.width: 25%
|
||||
- id: level
|
||||
$type: haxework.gui.LabelView
|
||||
skinId: text.box
|
||||
geometry.size.height: 38
|
||||
geometry.padding: [20, 0]
|
||||
- $type: haxework.gui.SpriteView
|
||||
geometry.size.width: 50%
|
||||
- $type: haxework.gui.SpriteView
|
||||
geometry.size.width: 25%
|
||||
- id: dire
|
||||
$type: ru.m.tankz.frame.common.LifeView
|
||||
tank: bc
|
||||
|
||||
@@ -44,11 +44,14 @@ import ru.m.tankz.storage.SettingsStorage;
|
||||
}
|
||||
}
|
||||
|
||||
private function onItemSelect(index:Int, value:ActionItem, view:ActionView):Void {
|
||||
view.edit();
|
||||
}
|
||||
|
||||
private function _change():Void {
|
||||
var p: Promise<Int> = Promise.promise(0);
|
||||
for (view in list.views) {
|
||||
var v: ActionView = cast view;
|
||||
if (v.data == null) break;
|
||||
p = p.pipe(function(_):Promise<Int> return v.edit());
|
||||
}
|
||||
p.then(function(_) _save());
|
||||
|
||||
@@ -27,3 +27,4 @@ views:
|
||||
layout:
|
||||
$type: haxework.gui.layout.VerticalLayout
|
||||
factory: $this:viewFactory
|
||||
+onItemSelect: $this:onItemSelect
|
||||
|
||||
Reference in New Issue
Block a user