[server] GameManager restore
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
package ru.m.draw;
|
||||
|
||||
abstract Color(Int) {
|
||||
public var alpha(get, never):Int;
|
||||
public var red(get, never):Int;
|
||||
public var green(get, never):Int;
|
||||
public var blue(get, never):Int;
|
||||
public var zero(get, never):Bool;
|
||||
|
||||
public inline function new(value:Int) {
|
||||
this = value;
|
||||
}
|
||||
|
||||
private inline function get_alpha():Int {
|
||||
return (this >> 24) & 255;
|
||||
}
|
||||
|
||||
private inline function get_red():Int {
|
||||
return (this >> 16) & 255;
|
||||
}
|
||||
|
||||
private inline function get_green():Int {
|
||||
return (this >> 8) & 255;
|
||||
}
|
||||
|
||||
private inline function get_blue():Int {
|
||||
return this & 255;
|
||||
}
|
||||
|
||||
private inline function get_zero():Bool {
|
||||
return this == 0;
|
||||
}
|
||||
|
||||
@:from
|
||||
static public inline function fromInt(value:Int):Color {
|
||||
return new Color(value);
|
||||
}
|
||||
|
||||
@:from
|
||||
static public inline function fromString(value:String):Color {
|
||||
return new Color(Std.parseInt('0x${value.split('#').pop()}'));
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
return 'Color(${red},${green},${blue})';
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,12 @@ package ru.m.tankz;
|
||||
import haxework.provider.Provider;
|
||||
import haxework.resources.IResources;
|
||||
import haxework.resources.Resources;
|
||||
import ru.m.tankz.bundle.ConfigBundle;
|
||||
import ru.m.tankz.bundle.IConfigBundle;
|
||||
import ru.m.tankz.bundle.ILevelBundle;
|
||||
import ru.m.tankz.bundle.LevelBundle;
|
||||
import ru.m.tankz.control.ClientControlFactory;
|
||||
import ru.m.tankz.control.IControlFactory;
|
||||
import ru.m.tankz.game.ClassicGame;
|
||||
import ru.m.tankz.game.DotaGame;
|
||||
import ru.m.tankz.game.Game;
|
||||
@@ -19,11 +23,12 @@ class Init {
|
||||
public static function init():Void {
|
||||
Provider.setFactory(IResources, Resources);
|
||||
Provider.setFactory(ILevelBundle, LevelBundle);
|
||||
Provider.setFactory(ILevelBundle, LevelBundle);
|
||||
Provider.setFactory(IConfigBundle, ConfigBundle);
|
||||
Provider.setFactory(SaveStorage, SaveStorage);
|
||||
Provider.setFactory(UserStorage, UserStorage);
|
||||
Provider.setFactory(SoundManager, SoundManager);
|
||||
Provider.setFactory(NetworkManager, NetworkManager);
|
||||
Provider.setFactory(IControlFactory, ClientControlFactory);
|
||||
Provider.setFactory(Game, ClassicGame, ClassicGame.TYPE);
|
||||
Provider.setFactory(Game, DotaGame, DotaGame.TYPE);
|
||||
}
|
||||
|
||||
23
src/client/haxe/ru/m/tankz/control/ClientControlFactory.hx
Normal file
23
src/client/haxe/ru/m/tankz/control/ClientControlFactory.hx
Normal file
@@ -0,0 +1,23 @@
|
||||
package ru.m.tankz.control;
|
||||
|
||||
import ru.m.tankz.game.Player;
|
||||
import ru.m.tankz.bot.BotControl;
|
||||
|
||||
|
||||
class ClientControlFactory implements IControlFactory {
|
||||
|
||||
private var humanControlIndex:Int;
|
||||
|
||||
public function new() {
|
||||
humanControlIndex = 0;
|
||||
}
|
||||
|
||||
public function build(player:Player):Control {
|
||||
return switch (player.config.control) {
|
||||
case Control.HUMAN: new HumanControl(player.id, humanControlIndex++);
|
||||
case Control.BOT: new BotControl(player.id);
|
||||
case Control.NONE: null;
|
||||
case _: throw 'Unsupported control type: "${player.config.control}"';
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user