[client] fixes

This commit is contained in:
2019-07-18 14:32:37 +03:00
parent 3361d252ee
commit 94340bddb1
9 changed files with 25 additions and 27 deletions

View File

@@ -1,5 +1,6 @@
package ru.m.tankz.local;
import ru.m.tankz.control.HumanControl;
import ru.m.tankz.game.GameEvent;
import ru.m.tankz.game.GameRunner;
import ru.m.tankz.local.LocalControlFactory;
@@ -18,20 +19,20 @@ class LocalGame extends GameRunner {
override public function onGameEvent(event:GameEvent):Void {
super.onGameEvent(event);
switch event {
case COMPLETE(result):
updateProgress(result);
case COMPLETE(result): updateProgress(result);
case _:
}
}
private static function updateProgress(result:Result):Void {
var complete = true;
for (rule in result.state.config.game.complete) {
if (rule.team != null && rule.team != result.winner) {
complete = false;
private function updateProgress(result:Result):Void {
var complete = false;
var humansTeams:Array<TeamId> = [];
for (control in controls) {
if (Std.is(HumanControl, control) && humansTeams.indexOf(control.playerId.team) == -1) {
humansTeams.push(control.playerId.team);
}
}
if (complete) {
if (humansTeams.length == 1 && result.winner == humansTeams[0]) {
var progress = gameStorage.get(new PackId(result.state.type));
progress.completeLevel(result.level.id, result.state.presetId);
gameStorage.set(progress);

View File

@@ -16,10 +16,15 @@ import ru.m.tankz.control.PlayerControl;
private function set_control(value:PlayerControl):PlayerControl {
control = value;
slotLabel.text = '${control.playerId.team}(${control.playerId.index})';
// ToDo: style
//slotLabel.skin = theme.textBox(value.color != null ? value.color : theme.colors.text);
slotLabel.font.color = value.color;
select.selected = control.controller;
return control;
}
private function onControllerSelect(value:Controller):Void {
select.currentView.style = switch value {
case HUMAN(_): "button.active";
case _: "button";
}
}
}

View File

@@ -10,6 +10,7 @@ views:
geometry.width: 150
- id: select
$type: haxework.view.form.SelectView<ru.m.tankz.control.Controller>
geometry.width: 150
labelBuilder: |
~function(controller) {
var result = ControllerParser.defaultName(controller);
@@ -20,3 +21,4 @@ views:
- ~ru.m.tankz.control.Controller.HUMAN(0)
- ~ru.m.tankz.control.Controller.HUMAN(1)
selected: ~ru.m.tankz.control.Controller.NONE
+onSelect: ~onControllerSelect

View File

@@ -29,10 +29,7 @@ import ru.m.tankz.proto.room.RoomSlotProto;
userView.style = (value.hasUser() && value.user.uuid == network.user.uuid) ? "text.box.active" : "text.box";
var config = configBundle.get(network.room.game.type);
var color = config.getColor([value.slot.team, value.slot.index]);
if (color != null) {
// ToDo: style
//typeView.skin = theme.textBox(color);
}
typeView.font.color = color;
return data;
}

View File

@@ -4,8 +4,10 @@ layout.vAlign: middle
view:
$type: haxework.view.group.VGroupView
layout.hAlign: center
geometry.width: 400
geometry.height: 400
geometry.width: 100%
geometry.height: 100%
# geometry.width: 400
# geometry.height: 400
geometry.margin: 10
style: window
views:
@@ -30,6 +32,8 @@ view:
id: slots
$type: haxework.view.data.DataView
geometry.padding: 10
geometry.width: 100%
layout.hAlign: center
factory: ~slotViewFactory
layout:
$type: haxework.view.layout.VerticalLayout

View File

@@ -4,14 +4,9 @@ import haxework.color.Color;
import ru.m.tankz.control.Controller;
import ru.m.tankz.Type;
typedef CompleteRule = {
@:optional var team:TeamId;
}
typedef GameConfig = {
var levels: Int;
var friendlyFire:Bool;
var complete:Array<CompleteRule>;
}
typedef SpawnPoint = {

View File

@@ -1,7 +1,5 @@
game:
friendlyFire: false
complete:
- team: human
map:
cell:

View File

@@ -1,7 +1,5 @@
game:
friendlyFire: true
complete:
- team: alpha
map:
cell:

View File

@@ -1,7 +1,5 @@
game:
friendlyFire: true
complete:
- team: radiant
map:
cell: