[bot] added
This commit is contained in:
@@ -12,14 +12,14 @@ import flash.Lib;
|
||||
class PlayerControl {
|
||||
|
||||
private var engine:Engine;
|
||||
private var id:Int;
|
||||
private var tankId:Int;
|
||||
|
||||
private var keyBinding:Map<Int, TankAction>;
|
||||
private var moveQueue:Array<Int>;
|
||||
private var shotTimer:Timer;
|
||||
|
||||
public function new(id:Int, engine:Engine, keyBinding:Map<Int, TankAction>) {
|
||||
this.id = id;
|
||||
public function new(tankId:Int, engine:Engine, keyBinding:Map<Int, TankAction>) {
|
||||
this.tankId = tankId;
|
||||
this.engine = engine;
|
||||
this.keyBinding = keyBinding;
|
||||
moveQueue = new Array<Int>();
|
||||
@@ -44,7 +44,7 @@ class PlayerControl {
|
||||
case _:
|
||||
}
|
||||
if (event.keyCode == Keyboard.U) {
|
||||
engine.action(id, TankAction.LEVEL_UP(1));
|
||||
engine.action(tankId, TankAction.LEVEL_UP(1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,18 +69,18 @@ class PlayerControl {
|
||||
|
||||
private function updateMove():Void {
|
||||
if (moveQueue.length == 0) {
|
||||
engine.action(id, TankAction.STOP);
|
||||
engine.action(tankId, TankAction.STOP);
|
||||
} else {
|
||||
switch (keyBinding.get(moveQueue[0])) {
|
||||
case TankAction.MOVE(direction):
|
||||
engine.action(id, TankAction.MOVE(direction));
|
||||
engine.action(tankId, TankAction.MOVE(direction));
|
||||
case _:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function shot():Void {
|
||||
engine.action(id, TankAction.SHOT);
|
||||
engine.action(tankId, TankAction.SHOT);
|
||||
}
|
||||
|
||||
public static function forPlayer(index:Int, tankId:Int, engine:Engine):PlayerControl {
|
||||
|
||||
@@ -38,7 +38,7 @@ class GameFrame extends VGroupView implements ViewBuilder implements IPacketHand
|
||||
content.addEventListener(Event.ENTER_FRAME, redraw);
|
||||
for (index in 0...game.players.length) {
|
||||
var playerId:Int = game.players[index].id;
|
||||
controls.set(playerId, PlayerControl.forPlayer(index, playerId, engine));
|
||||
controls.set(engine.playerTanks.get(playerId).id, PlayerControl.forPlayer(index, playerId, engine));
|
||||
}
|
||||
Provider.get(IConnection).packetHandler.addListener(this);
|
||||
render.draw(engine);
|
||||
|
||||
Reference in New Issue
Block a user