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);
        }
示例#2
0
 public DrawTile(CanvasInformation canvas, int x, int y, JsonTileMap jsonMap)
     : base(x, y, jsonMap)
 {
     var imageData = canvas.Context.GetImageData(x, y, jsonMap.TileWidth, jsonMap.TileHeight);
     var data = CanvasInformation.Create(imageData);
     Image = data;
 }
        public void Clear(CanvasInformation canv)
        {
            Point w;
            if (canv == gameCanvas)
                w = gameGoodSize;
            else
                w = uiGoodSize;
            //canv.DomCanvas[0].Me().width = w.width;

            canv.Context.ClearRect(0, 0, w.X, w.Y);
        }
示例#4
0
 private static void drawImage(CanvasContext2D context, CanvasInformation inf, double size)
 {
     if (inf.ImageReady)
         context.DrawImage(inf.Image, 0, 0);
     else context.DrawImage(inf.Canvas, 0, 0);
 }