[client] use class provide macro
This commit is contained in:
@@ -3,46 +3,12 @@ package ru.m.animate;
|
|||||||
import flash.display.Bitmap;
|
import flash.display.Bitmap;
|
||||||
import flash.display.BitmapData;
|
import flash.display.BitmapData;
|
||||||
import flash.display.PixelSnapping;
|
import flash.display.PixelSnapping;
|
||||||
import haxe.Timer;
|
|
||||||
|
|
||||||
typedef Frame = {
|
typedef Frame = {
|
||||||
var image:BitmapData;
|
var image:BitmapData;
|
||||||
var length:Int;
|
var length:Int;
|
||||||
}
|
}
|
||||||
|
|
||||||
class AnimateManager {
|
|
||||||
public var playing(default, default):Bool;
|
|
||||||
|
|
||||||
private var timer:Timer;
|
|
||||||
private var animations:Array<Animate>;
|
|
||||||
|
|
||||||
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 {
|
class Animate extends Bitmap {
|
||||||
|
|
||||||
public var playing(default, default):Bool;
|
public var playing(default, default):Bool;
|
||||||
|
|||||||
34
src/client/haxe/ru/m/animate/AnimateManager.hx
Normal file
34
src/client/haxe/ru/m/animate/AnimateManager.hx
Normal file
@@ -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<Animate>;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,8 @@
|
|||||||
package ru.m.tankz;
|
package ru.m.tankz;
|
||||||
|
|
||||||
import ru.m.animate.Animate.AnimateManager;
|
|
||||||
import flash.Lib;
|
import flash.Lib;
|
||||||
import haxework.animate.FadeAnimate;
|
import haxework.animate.FadeAnimate;
|
||||||
import haxework.animate.UnFadeAnimate;
|
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.storage.SharedObjectStorage;
|
||||||
import haxework.view.popup.PopupManager;
|
import haxework.view.popup.PopupManager;
|
||||||
import haxework.view.theme.ITheme;
|
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.ConfigBundle;
|
||||||
import ru.m.tankz.bundle.IConfigBundle;
|
import ru.m.tankz.bundle.IConfigBundle;
|
||||||
import ru.m.tankz.bundle.ILevelBundle;
|
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.Request;
|
||||||
import ru.m.tankz.proto.pack.Response;
|
import ru.m.tankz.proto.pack.Response;
|
||||||
import ru.m.tankz.sound.SoundManager;
|
|
||||||
import ru.m.tankz.storage.GameStorage;
|
import ru.m.tankz.storage.GameStorage;
|
||||||
import ru.m.tankz.storage.NetworkStorage;
|
import ru.m.tankz.storage.NetworkStorage;
|
||||||
import ru.m.tankz.storage.RecordStorage;
|
import ru.m.tankz.storage.RecordStorage;
|
||||||
@@ -36,21 +29,16 @@ import ru.m.update.Updater;
|
|||||||
class Init {
|
class Init {
|
||||||
|
|
||||||
@:provide static var theme:ITheme;
|
@:provide static var theme:ITheme;
|
||||||
@:provide static var resources:IResources;
|
|
||||||
@:provide static var levelBundle:ILevelBundle;
|
@:provide static var levelBundle:ILevelBundle;
|
||||||
@:provide static var configBundle:IConfigBundle;
|
@:provide static var configBundle:IConfigBundle;
|
||||||
@:provide static var settingsStorage:SettingsStorage;
|
@:provide static var settingsStorage:SettingsStorage;
|
||||||
@:provide static var multiplayerStorage:NetworkStorage;
|
@:provide static var multiplayerStorage:NetworkStorage;
|
||||||
@:provide static var gameStorage:GameStorage;
|
@:provide static var gameStorage:GameStorage;
|
||||||
@:provide static var recordStorage:RecordStorage;
|
@:provide static var recordStorage:RecordStorage;
|
||||||
@:provide static var soundManager:SoundManager;
|
|
||||||
@:provide static var networkManager:NetworkManager;
|
|
||||||
@:provide static var popupManager:PopupManager;
|
@:provide static var popupManager:PopupManager;
|
||||||
@:provide static var connection:IConnection<Request, Response>;
|
@:provide static var connection:IConnection<Request, Response>;
|
||||||
@:provide static var bus:IControlBus;
|
@:provide static var bus:IControlBus;
|
||||||
@:provide static var loaderManager:ILoaderManager;
|
|
||||||
@:provide static var updater:Updater;
|
@:provide static var updater:Updater;
|
||||||
@:provide static var animateManager:AnimateManager;
|
|
||||||
|
|
||||||
private static function buildConnection():IConnection<Request, Response> {
|
private static function buildConnection():IConnection<Request, Response> {
|
||||||
var host:String = CompilationOption.get("host");
|
var host:String = CompilationOption.get("host");
|
||||||
@@ -67,7 +55,6 @@ class Init {
|
|||||||
|
|
||||||
public static function init():Void {
|
public static function init():Void {
|
||||||
theme = new AppTheme();
|
theme = new AppTheme();
|
||||||
resources = new Resources();
|
|
||||||
levelBundle = new CachedLevelBundle(new ClientLevelSource(), new SharedObjectStorage());
|
levelBundle = new CachedLevelBundle(new ClientLevelSource(), new SharedObjectStorage());
|
||||||
levelBundle.load();
|
levelBundle.load();
|
||||||
configBundle = new ConfigBundle();
|
configBundle = new ConfigBundle();
|
||||||
@@ -75,20 +62,15 @@ class Init {
|
|||||||
multiplayerStorage = new NetworkStorage();
|
multiplayerStorage = new NetworkStorage();
|
||||||
gameStorage = new GameStorage();
|
gameStorage = new GameStorage();
|
||||||
recordStorage = new RecordStorage();
|
recordStorage = new RecordStorage();
|
||||||
soundManager = new SoundManager();
|
|
||||||
popupManager = new PopupManager();
|
|
||||||
animateManager = new AnimateManager();
|
|
||||||
|
|
||||||
popupManager.showAnimateFactory = function(v) return new UnFadeAnimate(v, 100);
|
popupManager.showAnimateFactory = function(v) return new UnFadeAnimate(v, 100);
|
||||||
popupManager.closeAnimateFactory = function(v) return new FadeAnimate(v, 100);
|
popupManager.closeAnimateFactory = function(v) return new FadeAnimate(v, 100);
|
||||||
|
|
||||||
connection = buildConnection();
|
connection = buildConnection();
|
||||||
networkManager = new NetworkManager();
|
|
||||||
|
|
||||||
bus = new ControlBus();
|
bus = new ControlBus();
|
||||||
bus.connect(new KeyboardDevice(Lib.current.stage));
|
bus.connect(new KeyboardDevice(Lib.current.stage));
|
||||||
|
|
||||||
loaderManager = new LoaderManager();
|
|
||||||
updater = new Updater(Const.VERSION, "https://shmyga.ru/repo/tankz/packages.json");
|
updater = new Updater(Const.VERSION, "https://shmyga.ru/repo/tankz/packages.json");
|
||||||
|
|
||||||
for (device in Gamepad.devices) {
|
for (device in Gamepad.devices) {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ enum ConnectionState {
|
|||||||
ERROR(error:Dynamic);
|
ERROR(error:Dynamic);
|
||||||
}
|
}
|
||||||
|
|
||||||
class NetworkManager {
|
@:provide class NetworkManager {
|
||||||
|
|
||||||
private static inline var TAG = "NetworkManager";
|
private static inline var TAG = "NetworkManager";
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import haxework.view.form.LabelView;
|
|||||||
import haxework.view.SpriteView;
|
import haxework.view.SpriteView;
|
||||||
import promhx.Promise;
|
import promhx.Promise;
|
||||||
import ru.m.animate.Animate;
|
import ru.m.animate.Animate;
|
||||||
|
import ru.m.animate.AnimateManager;
|
||||||
import ru.m.animate.OnceAnimate;
|
import ru.m.animate.OnceAnimate;
|
||||||
import ru.m.geom.Point;
|
import ru.m.geom.Point;
|
||||||
import ru.m.tankz.config.Config;
|
import ru.m.tankz.config.Config;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import ru.m.tankz.config.Config;
|
|||||||
import ru.m.tankz.game.GameEvent;
|
import ru.m.tankz.game.GameEvent;
|
||||||
import ru.m.tankz.game.IGame;
|
import ru.m.tankz.game.IGame;
|
||||||
|
|
||||||
class SoundManager implements GameListener {
|
@:provide class SoundManager implements GameListener {
|
||||||
private static var TAG(default, never):String = "SoundManager";
|
private static var TAG(default, never):String = "SoundManager";
|
||||||
|
|
||||||
#if flash
|
#if flash
|
||||||
|
|||||||
Reference in New Issue
Block a user