[common] add BaseControlFactory
This commit is contained in:
30
src/common/haxe/ru/m/tankz/control/BaseControlFactory.hx
Normal file
30
src/common/haxe/ru/m/tankz/control/BaseControlFactory.hx
Normal file
@@ -0,0 +1,30 @@
|
||||
package ru.m.tankz.control;
|
||||
|
||||
import ru.m.tankz.bot.HardBotControl;
|
||||
import ru.m.tankz.bot.StupidBotControl;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
class BaseControlFactory implements IControlFactory {
|
||||
|
||||
public function new() {}
|
||||
|
||||
public function build(id:PlayerId, controller:Controller):Control {
|
||||
return switch controller {
|
||||
case Controller.HUMAN(index): buildHuman(id, index);
|
||||
case Controller.BOT(type): buildBot(id, type);
|
||||
case Controller.NONE: null;
|
||||
}
|
||||
}
|
||||
|
||||
private function buildHuman(id:PlayerId, index:Int):Control {
|
||||
return null;
|
||||
}
|
||||
|
||||
private function buildBot(id:PlayerId, type:String):Control {
|
||||
return switch type {
|
||||
case StupidBotControl.BOT_TYPE: new StupidBotControl(id);
|
||||
case HardBotControl.BOT_TYPE: new HardBotControl(id);
|
||||
case _: null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ class EntityBuilder {
|
||||
|
||||
public function new(config:Config) {
|
||||
this.config = config;
|
||||
this.entityId = 0;
|
||||
this.entityId = 1;
|
||||
}
|
||||
|
||||
public function buildRect(point:EntityPoint, width:Float, height:Float):Rectangle {
|
||||
|
||||
@@ -306,7 +306,7 @@ class GameRunner extends Game implements EngineListener {
|
||||
super.onGameEvent(event);
|
||||
switch event {
|
||||
case GameEvent.START(_):
|
||||
timer = new Timer(10);
|
||||
timer = new Timer(30);
|
||||
timer.run = update;
|
||||
case GameEvent.COMPLETE(_, _):
|
||||
if (timer != null) {
|
||||
|
||||
Reference in New Issue
Block a user