diff --git a/src/client/haxe/ru/m/animate/Animate.hx b/src/client/haxe/ru/m/animate/Animate.hx index 428252f..57a7596 100644 --- a/src/client/haxe/ru/m/animate/Animate.hx +++ b/src/client/haxe/ru/m/animate/Animate.hx @@ -3,46 +3,12 @@ package ru.m.animate; import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.PixelSnapping; -import haxe.Timer; typedef Frame = { var image:BitmapData; var length:Int; } -class AnimateManager { - public var playing(default, default):Bool; - - private var timer:Timer; - private var animations:Array; - - public function new() { - animations = []; - timer = new Timer(30); - timer.run = update; - } - - public function update():Void { - if (playing) { - for (animation in animations) { - if (animation.playing) { - animation.update(); - } - } - } - } - - public function add(animate:Animate):Void { - animations.push(animate); - } - - public function remove(animate:Animate):Void { - if (animations.indexOf(animate) > -1) { - animations.remove(animate); - } - } -} - class Animate extends Bitmap { public var playing(default, default):Bool; diff --git a/src/client/haxe/ru/m/animate/AnimateManager.hx b/src/client/haxe/ru/m/animate/AnimateManager.hx new file mode 100644 index 0000000..9082a56 --- /dev/null +++ b/src/client/haxe/ru/m/animate/AnimateManager.hx @@ -0,0 +1,34 @@ +package ru.m.animate; + +@:provide class AnimateManager { + public var playing(default, default):Bool; + + private var timer:Timer; + private var animations:Array; + + public function new() { + animations = []; + timer = new Timer(30); + timer.run = update; + } + + public function update():Void { + if (playing) { + for (animation in animations) { + if (animation.playing) { + animation.update(); + } + } + } + } + + public function add(animate:Animate):Void { + animations.push(animate); + } + + public function remove(animate:Animate):Void { + if (animations.indexOf(animate) > -1) { + animations.remove(animate); + } + } +} diff --git a/src/client/haxe/ru/m/tankz/Init.hx b/src/client/haxe/ru/m/tankz/Init.hx index e47dc44..de1102b 100644 --- a/src/client/haxe/ru/m/tankz/Init.hx +++ b/src/client/haxe/ru/m/tankz/Init.hx @@ -1,13 +1,8 @@ package ru.m.tankz; -import ru.m.animate.Animate.AnimateManager; import flash.Lib; import haxework.animate.FadeAnimate; import haxework.animate.UnFadeAnimate; -import haxework.net.manage.ILoaderManager; -import haxework.net.manage.LoaderManager; -import haxework.resources.IResources; -import haxework.resources.Resources; import haxework.storage.SharedObjectStorage; import haxework.view.popup.PopupManager; import haxework.view.theme.ITheme; @@ -23,10 +18,8 @@ import ru.m.tankz.bundle.ClientLevelSource; import ru.m.tankz.bundle.ConfigBundle; import ru.m.tankz.bundle.IConfigBundle; import ru.m.tankz.bundle.ILevelBundle; -import ru.m.tankz.network.NetworkManager; import ru.m.tankz.proto.pack.Request; import ru.m.tankz.proto.pack.Response; -import ru.m.tankz.sound.SoundManager; import ru.m.tankz.storage.GameStorage; import ru.m.tankz.storage.NetworkStorage; import ru.m.tankz.storage.RecordStorage; @@ -36,21 +29,16 @@ import ru.m.update.Updater; class Init { @:provide static var theme:ITheme; - @:provide static var resources:IResources; @:provide static var levelBundle:ILevelBundle; @:provide static var configBundle:IConfigBundle; @:provide static var settingsStorage:SettingsStorage; @:provide static var multiplayerStorage:NetworkStorage; @:provide static var gameStorage:GameStorage; @:provide static var recordStorage:RecordStorage; - @:provide static var soundManager:SoundManager; - @:provide static var networkManager:NetworkManager; @:provide static var popupManager:PopupManager; @:provide static var connection:IConnection; @:provide static var bus:IControlBus; - @:provide static var loaderManager:ILoaderManager; @:provide static var updater:Updater; - @:provide static var animateManager:AnimateManager; private static function buildConnection():IConnection { var host:String = CompilationOption.get("host"); @@ -67,7 +55,6 @@ class Init { public static function init():Void { theme = new AppTheme(); - resources = new Resources(); levelBundle = new CachedLevelBundle(new ClientLevelSource(), new SharedObjectStorage()); levelBundle.load(); configBundle = new ConfigBundle(); @@ -75,20 +62,15 @@ class Init { multiplayerStorage = new NetworkStorage(); gameStorage = new GameStorage(); recordStorage = new RecordStorage(); - soundManager = new SoundManager(); - popupManager = new PopupManager(); - animateManager = new AnimateManager(); popupManager.showAnimateFactory = function(v) return new UnFadeAnimate(v, 100); popupManager.closeAnimateFactory = function(v) return new FadeAnimate(v, 100); connection = buildConnection(); - networkManager = new NetworkManager(); bus = new ControlBus(); bus.connect(new KeyboardDevice(Lib.current.stage)); - loaderManager = new LoaderManager(); updater = new Updater(Const.VERSION, "https://shmyga.ru/repo/tankz/packages.json"); for (device in Gamepad.devices) { diff --git a/src/client/haxe/ru/m/tankz/network/NetworkManager.hx b/src/client/haxe/ru/m/tankz/network/NetworkManager.hx index ccbf667..dbc88c8 100644 --- a/src/client/haxe/ru/m/tankz/network/NetworkManager.hx +++ b/src/client/haxe/ru/m/tankz/network/NetworkManager.hx @@ -36,7 +36,7 @@ enum ConnectionState { ERROR(error:Dynamic); } -class NetworkManager { +@:provide class NetworkManager { private static inline var TAG = "NetworkManager"; diff --git a/src/client/haxe/ru/m/tankz/render/Render.hx b/src/client/haxe/ru/m/tankz/render/Render.hx index 7ee9cdf..14120e5 100755 --- a/src/client/haxe/ru/m/tankz/render/Render.hx +++ b/src/client/haxe/ru/m/tankz/render/Render.hx @@ -9,6 +9,7 @@ import haxework.view.form.LabelView; import haxework.view.SpriteView; import promhx.Promise; import ru.m.animate.Animate; +import ru.m.animate.AnimateManager; import ru.m.animate.OnceAnimate; import ru.m.geom.Point; import ru.m.tankz.config.Config; diff --git a/src/client/haxe/ru/m/tankz/sound/SoundManager.hx b/src/client/haxe/ru/m/tankz/sound/SoundManager.hx index 6245c2e..9137dc5 100644 --- a/src/client/haxe/ru/m/tankz/sound/SoundManager.hx +++ b/src/client/haxe/ru/m/tankz/sound/SoundManager.hx @@ -9,7 +9,7 @@ import ru.m.tankz.config.Config; import ru.m.tankz.game.GameEvent; import ru.m.tankz.game.IGame; -class SoundManager implements GameListener { +@:provide class SoundManager implements GameListener { private static var TAG(default, never):String = "SoundManager"; #if flash