[common] change game team players from array to map
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -18,9 +19,9 @@ class HumanControl extends Control {
|
||||
private var moveQueue:Array<Int>;
|
||||
private var shotTimer:Timer;
|
||||
|
||||
public function new(index:Int) {
|
||||
super({type:Control.HUMAN, index:index});
|
||||
this.keyBinding = resolve(index);
|
||||
public function new(playerId:PlayerId, controlIndex:Int) {
|
||||
super(playerId);
|
||||
this.keyBinding = resolve(controlIndex);
|
||||
moveQueue = new Array<Int>();
|
||||
Lib.current.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
|
||||
Lib.current.stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
|
||||
@@ -82,8 +83,8 @@ class HumanControl extends Control {
|
||||
action(TankAction.SHOT);
|
||||
}
|
||||
|
||||
private static function resolve(index:Int):KeyBinding {
|
||||
switch (index) {
|
||||
private static function resolve(controlIndex:Int):KeyBinding {
|
||||
switch (controlIndex) {
|
||||
case 0:
|
||||
return [
|
||||
Keyboard.A => TankAction.MOVE(Direction.LEFT),
|
||||
@@ -100,8 +101,8 @@ class HumanControl extends Control {
|
||||
Keyboard.RIGHT => TankAction.MOVE(Direction.RIGHT),
|
||||
Keyboard.NUMPAD_0 => TankAction.SHOT
|
||||
];
|
||||
case _:
|
||||
throw 'Invalid control index ${index}';
|
||||
case x:
|
||||
throw 'Invalid control index ${x}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user