Exemplo n.º 1
0
        public ClientManager(string gatewayServerAddress)
        {
            var elem = Document.GetElementById("loading");
            elem.ParentNode.RemoveChild(elem);

            var stats = new XStats();
            Document.Body.AppendChild(stats.Element);

            gameCanvas = CanvasInformation.Create((CanvasElement) Document.GetElementById(gameCanvasName), 0, 0);
            uiCanvas = CanvasInformation.Create((CanvasElement) Document.GetElementById(uiCanvasName), 0, 0);
            UIManager = new UIManager();
            gateway = new Gateway(gatewayServerAddress);

            gameManager = new GameManager(gateway.On, gateway.Emit);
            gateway.On("Area.Main.Login.Response", (user,data) => {
                Window.Alert(Json.Stringify(data));
                                                   });
            gateway.Login(randomName());

            bindInput();
            Window.AddEventListener("resize", e => resizeCanvas());
            jQuery.Document.Resize(e => resizeCanvas());
            int a = 0;
            //Window.SetInterval(() => {},1000 / 60);
            Window.SetInterval(GameTick, 1000 / 10);
            Window.SetInterval(Tick, 1000 / 60);
            Window.SetInterval(GameDraw, 1000 / 60);
            Window.SetInterval(UIDraw, 1000 / 10);

            gameManager.Start(gameCanvas.Context);
            resizeCanvas();
            gameManager.BuildUI(UIManager);
        }
        public static GameObject AddSelectionManagerCompnent(GameObject goTo, GameManager gameManager)
        {
            goTo.SetActive(false);

            SelectionManager selectionManager = goTo.AddComponent<SelectionManager>() as SelectionManager;
            selectionManager._gameManager = gameManager;
            goTo.SetActive(true);

            return goTo;
        }