// Decompiled by AS3 Sorcerer 6.78
// www.buraks.com/as3sorcerer

//Game

package 
{
    import flash.display.MovieClip;
    import flash.display.Stage;
    import alternativa.init.OSGi;
    import alternativa.init.Main;
    import alternativa.init.BattlefieldModelActivator;
    import alternativa.init.BattlefieldSharedActivator;
    import alternativa.init.PanelModelActivator;
    import alternativa.init.TanksLocaleActivator;
    import alternativa.init.TanksServicesActivator;
    import alternativa.init.TanksWarfareActivator;
    import alternativa.init.BattlefieldGUIActivator;
    import alternativa.init.TanksLocaleRuActivator;
    import alternativa.init.TanksLocaleEnActivator;
    import alternativa.init.TanksFonts;
    import alternativa.object.ClientObject;
    import flash.display.BitmapData;
    import alternativa.tanks.models.battlefield.BattlefieldModel;
    import alternativa.tanks.models.tank.TankModel;
    import scpacker.networking.Network;
    import flash.text.TextField;
    import scpacker.networking.INetworker;
    import com.reygazu.anticheat.events.CheatManagerEvent;
    import flash.display.StageScaleMode;
    import flash.display.StageAlign;
	import specter.utils.Logger;
    import flash.net.SharedObject;
    import alternativa.tanks.loader.LoaderWindow;
    import alternativa.tanks.loader.ILoaderWindowService;
    import scpacker.SocketListener;
    import alternativa.register.ObjectRegister;
    import scpacker.gui.IGTanksLoader;
    import scpacker.gui.GTanksLoaderWindow;
    import alternativa.osgi.service.storage.IStorageService;
    import scpacker.resource.ResourceUtil;
    import scpacker.tanks.turrets.TurretsConfigLoader;
    import scpacker.tanks.hulls.HullsConfigLoader;
    import scpacker.networking.connecting.ServerConnectionServiceImpl;
    import scpacker.networking.connecting.ServerConnectionService;
    import alternativa.tanks.model.panel.PanelModel;
    import alternativa.tanks.model.panel.IPanel;

    public class Game extends MovieClip 
    {

        public static var getInstance:Game;
        public static var currLocale:String;
        public static var local:Boolean = false;
        public static var _stage:Stage;

        public var osgi:OSGi;
        public var main:Main;
        public var battlefieldModel:BattlefieldModelActivator;
        public var battlefieldShared:BattlefieldSharedActivator;
        public var panel:PanelModelActivator;
        public var locale:TanksLocaleActivator;
        public var services:TanksServicesActivator;
        public var warfare:TanksWarfareActivator;
        public var battleGui:BattlefieldGUIActivator;
        public var localeRu:TanksLocaleRuActivator = new TanksLocaleRuActivator();
        public var localeEn:TanksLocaleEnActivator = new TanksLocaleEnActivator();
        public var fonts:TanksFonts = new TanksFonts();
        public var classObject:ClientObject;
        public var colorMap:BitmapData = new BitmapData(100, 100);
        public var battleModel:BattlefieldModel;
        public var tankModel:TankModel;
        public var loaderObject:Object;

        public function Game()
        {
            if (numChildren > 1)
            {
                removeChildAt(0);
                removeChildAt(0);
            };
        }

        public static function onUserEntered(e:CheatManagerEvent):void
        {
            var network:Network;
            var cheaterTextField:TextField;
            var osgi:OSGi = Main.osgi;
            if (osgi != null)
            {
                network = (osgi.getService(INetworker) as Network);
            };
            if (network != null)
            {
                network.send("system;c01");
            }
            else
            {
                while (_stage.numChildren > 0)
                {
                    _stage.removeChildAt(0);
                };
                cheaterTextField = new TextField();
                cheaterTextField.textColor = 0xFF0000;
                cheaterTextField.text = "CHEATER!";
                _stage.addChild(cheaterTextField);
            };
        }


        public function activateAllModels():void
        {
            var localize:String;
            this.main.start(this.osgi);
            this.fonts.start(this.osgi);
            try
            {
                localize = root.loaderInfo.url.split("?")[1].split("&")[0].split("=")[1];
            }
            catch(e:Error)
            {
                localize = null;
            };
            if (((localize == null) || (localize == "ru")))
            {
                this.localeRu.start(this.osgi);
                currLocale = "RU";
            }
            else
            {
                this.localeEn.start(this.osgi);
                currLocale = "EN";
            };
            this.panel.start(this.osgi);
            this.locale.start(this.osgi);
            this.services.start(this.osgi);
        }

        public function SUPER(stage:Stage):void
        {
            _stage = stage;
            this.focusRect = false;
            stage.focus = this;
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            _stage = stage;
            this.osgi = OSGi.init(false, stage, this, "127.0.0.1", [12345], "127.0.0.1", 12345, "res/", new Logger(), SharedObject.getLocal("gtanks"), "RU", Object);
            this.main = new Main();
            this.battlefieldModel = new BattlefieldModelActivator();
            this.panel = new PanelModelActivator();
            this.locale = new TanksLocaleActivator();
            this.services = new TanksServicesActivator();
            getInstance = this;
            this.activateAllModels();
			specter.utils.Logger.init();
            var loaderService:LoaderWindow = (Main.osgi.getService(ILoaderWindowService) as LoaderWindow);
            this.loaderObject = new Object();
            var listener:SocketListener = new SocketListener();
            var objectRegister:ObjectRegister = new ObjectRegister(listener);
            this.classObject = new ClientObject("sdf", null, "GTanks", listener);
            this.classObject.register = objectRegister;
            objectRegister.createObject("sdfsd", null, "GTanks");
            Main.osgi.registerService(IGTanksLoader, new GTanksLoaderWindow(IStorageService(Main.osgi.getService(IStorageService)).getStorage().data["use_new_loader"]));
            ResourceUtil.addEventListener(function ():void
            {
                var l:TurretsConfigLoader = new TurretsConfigLoader("turretConfig.json");
                (Main.osgi.getService(IGTanksLoader) as GTanksLoaderWindow).addProgress(100);
                l.addListener(function ():void
                {
                    (Main.osgi.getService(IGTanksLoader) as GTanksLoaderWindow).addProgress(300);
                    var h:HullsConfigLoader = new HullsConfigLoader("hullsConfig.json");
                    h.addListener(function ():void
                    {
                        (Main.osgi.getService(IGTanksLoader) as GTanksLoaderWindow).addProgress(300);
                        onResourceLoaded();
                    });
                    h.load();
                });
                l.load();
            });
            ResourceUtil.loadResource();
            if (IStorageService(Main.osgi.getService(IStorageService)).getStorage().data["k_V"] == null)
            {
                IStorageService(Main.osgi.getService(IStorageService)).getStorage().setProperty("k_V", 0.02);
            };
            if (IStorageService(Main.osgi.getService(IStorageService)).getStorage().data["k_AV"] == null)
            {
                IStorageService(Main.osgi.getService(IStorageService)).getStorage().setProperty("k_AV", 6);
            };
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
			specter.utils.Logger.log(("Loader url: " + stage.loaderInfo.url));
        }

        private function onResourceLoaded():void
        {
            var serverConnectionServie:ServerConnectionService = new ServerConnectionServiceImpl();
            serverConnectionServie.connect(("socket.cfg?rand=" + Math.random()));
            var lobbyServices:Lobby = new Lobby();
            var panel:PanelModel = new PanelModel();
            Main.osgi.registerService(IPanel, panel);
            Main.osgi.registerService(ILobby, lobbyServices);
            (Main.osgi.getService(IGTanksLoader) as GTanksLoaderWindow).setFullAndClose(null);
            var auth:Authorization = new Authorization();
            Main.osgi.registerService(IAuthorization, auth);
			specter.utils.Logger.log("Game::onResourceLoaded()");
        }


    }
}//package 

как убрать hullsConfig.json и turretConfig.json