update worklist
This commit is contained in:
@@ -10,8 +10,8 @@ class BotControl extends Control {
|
||||
public static var TYPE(default, never):ControlType = 'bot';
|
||||
|
||||
private var shotTimer:Timer;
|
||||
private var turnRandomTimer:Timer;
|
||||
private var turnTimer:Timer;
|
||||
private var turnDelayTimer:Timer;
|
||||
|
||||
public function new(index:Int) {
|
||||
super({type:TYPE, index:index});
|
||||
@@ -33,9 +33,9 @@ class BotControl extends Control {
|
||||
shotTimer = new Timer(1000);
|
||||
shotTimer.run = shot;
|
||||
}
|
||||
if (turnTimer == null) {
|
||||
turnTimer = new Timer(2000);
|
||||
turnTimer.run = turn;
|
||||
if (turnRandomTimer == null) {
|
||||
turnRandomTimer = new Timer(2000);
|
||||
turnRandomTimer.run = turn;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,9 +44,9 @@ class BotControl extends Control {
|
||||
shotTimer.stop();
|
||||
shotTimer = null;
|
||||
}
|
||||
if (turnTimer != null) {
|
||||
turnTimer.stop();
|
||||
turnTimer = null;
|
||||
if (turnRandomTimer != null) {
|
||||
turnRandomTimer.stop();
|
||||
turnRandomTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,17 +55,16 @@ class BotControl extends Control {
|
||||
}
|
||||
|
||||
public function turnAfter(delay:Int):Void {
|
||||
if (turnDelayTimer == null) {
|
||||
turnDelayTimer = new Timer(delay);
|
||||
turnDelayTimer.run = function() {
|
||||
turnDelayTimer.stop();
|
||||
turnDelayTimer = null;
|
||||
turn();
|
||||
}
|
||||
if (turnTimer == null) {
|
||||
turnTimer = Timer.delay(turn, delay);
|
||||
}
|
||||
}
|
||||
|
||||
public function turn():Void {
|
||||
if (turnTimer != null) {
|
||||
turnTimer.stop();
|
||||
turnTimer = null;
|
||||
}
|
||||
action(TankAction.MOVE(randomDirection()));
|
||||
}
|
||||
|
||||
|
||||
@@ -119,8 +119,8 @@ class Game implements EngineListener {
|
||||
if (trySpawn(task.playerId, true)) {
|
||||
var tank = buildTank(task.playerId, task.point);
|
||||
var player:Player = getPlayer(task.playerId);
|
||||
engine.spawn(tank);
|
||||
player.tankId = tank.id;
|
||||
Timer.delay(function() engine.spawn(tank), 500);
|
||||
} else if (!isTeamAlive(task.playerId.team)) {
|
||||
state.teams[task.playerId.team].lose = true;
|
||||
complete();
|
||||
@@ -135,12 +135,10 @@ class Game implements EngineListener {
|
||||
player.control.dispose();
|
||||
}
|
||||
}
|
||||
var timer = new Timer(5000);
|
||||
timer.run = function() {
|
||||
timer.stop();
|
||||
Timer.delay(function() {
|
||||
deferred.resolve(state);
|
||||
stream.end();
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
public function setControl(playerId:PlayerId, control:Control):Void {
|
||||
@@ -159,7 +157,11 @@ class Game implements EngineListener {
|
||||
|
||||
|
||||
public function onSpawn(entity:EntityType):Void {
|
||||
|
||||
switch (entity) {
|
||||
case EntityType.TANK(tank):
|
||||
getPlayer(tank.playerId).control.start();
|
||||
case x:
|
||||
}
|
||||
}
|
||||
|
||||
public function onCollision(entity:EntityType, with:EntityType):Void {
|
||||
@@ -210,7 +212,8 @@ class Game implements EngineListener {
|
||||
public function onDestroy(entity:EntityType):Void {
|
||||
switch (entity) {
|
||||
case EntityType.TANK(tank):
|
||||
getPlayer(tank.playerId).tankId = 0;
|
||||
getPlayer(tank.playerId).control.stop();
|
||||
getPlayer(tank.playerId).tankId = 0; //ToDo: ?
|
||||
var respawn:Bool = trySpawn(tank.playerId);
|
||||
if (respawn) {
|
||||
spawners.get(tank.playerId.team).push(tank.playerId);
|
||||
|
||||
@@ -19,11 +19,6 @@ class Player {
|
||||
tankId = value;
|
||||
if (control != null) {
|
||||
control.tankId = tankId;
|
||||
if (tankId != 0) {
|
||||
control.start();
|
||||
} else {
|
||||
control.stop();
|
||||
}
|
||||
}
|
||||
return tankId;
|
||||
}
|
||||
@@ -33,9 +28,6 @@ class Player {
|
||||
control = value;
|
||||
if (control != null) {
|
||||
control.tankId = tankId;
|
||||
if (tankId != 0) {
|
||||
control.start();
|
||||
}
|
||||
}
|
||||
return control;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user