public void UpdateDynamic() { Bitmap TmpLayer; if (StaticLayer != null) { TmpLayer = (Bitmap)StaticLayer.Clone(); } else { TmpLayer = new Bitmap(Width, Height); } Shapes.DrawTmp(Graphics.FromImage(TmpLayer)); DynamicLayer = TmpLayer; }
public override void build() { base.build(); layerManager = new LayerManager(); //loadAlpha = 1; levelModel = (GameModel.levelsModels.ElementAt(GameModel.currentLevelID).behaviour as LevelBehaviour).levelModel; //loadScreen.init(content); backColor = levelModel.color; clouds = new LinkedList <Clouds>(); if (levelModel.clouds != null) { for (int i = 0; i < levelModel.clouds.Count; i++) { Clouds tempCloud = new Clouds(); tempCloud.texture = content.Load <Texture2D>(levelModel.clouds.ElementAt(i)); Vector2 temp = new Vector2((i + 1) % 2 == 0 ? -100 : 600, (float)new Random().Next(0, 50)); tempCloud.position = temp; clouds.AddLast(tempCloud); } } /*Cria as layers*/ environment = new StaticLayer("ENVIRONMENT"); for (int i = 0; i < levelModel.levelLayers.Count; i++) { environment.add(new StaticObject(levelModel.levelLayers.ElementAt(i))); } FXLayer = new Layer("FX"); BackEntityFXLayer = new Layer("BACK ENTITY FX"); entityLayer = new Layer("ENTITY LAYER"); rufus = new Rufus(400 - 30); rufus.position.Y = 200; rufus.dieCallback = endGame; entityLayer.add(rufus); /*Adiciona as layers*/ layerManager.add(environment); layerManager.add(BackEntityFXLayer); layerManager.add(entityLayer); layerManager.add(FXLayer); layerManager.init(content); baseHUD = new BaseHUD(); baseHUD.init(content); baseHUD.position.X = 6; baseHUD.position.Y = 444; baseHUD.start(); addChild(baseHUD); pauseButton = new PauseButton(pauseGame); pauseButton.init(content); pauseButton.position.X = 732; pauseButton.position.Y = 410; pauseButton.scale = new Vector2(1f); addChild(pauseButton); gameLoop = new GameLoop(content, rufus); gameLoop.beginGame(entityLayer); pause = false; comboBar = new ComboBar(rufus.setOnInvencible, rufus.setOffInvencible); comboBar.init(content); comboBar.updateScale(0); addChild(comboBar); inGameMenu = new InGameMenu(); inGameMenu.init(content, menuPlayCallback, backToMenu, reinitGame); inGameMenu.hide(); addChild(inGameMenu); endGameMenu = new EndGameMenu(); endGameMenu.init(content, menuPlayCallback, backToMenu, reinitGame, goShop, goPreGame); endGameMenu.hide(); addChild(endGameMenu); totMush = 0; rufus.collideCallback = collideCallback; //endGame(); }
public override void Render(System.Drawing.Graphics g, SharpMap.Map map) { base.Render(g, map); Ptv.Controls.Map.XMap.XMapWSService svcMap = new Ptv.Controls.Map.XMap.XMapWSService(); svcMap.Url = m_Url; if (!string.IsNullOrEmpty(User) && !string.IsNullOrEmpty(Password)) svcMap.Credentials = new NetworkCredential(User, Password); BoundingBox bb = new BoundingBox(); bb.leftTop = new Point(); bb.leftTop.point = new PlainPoint(); bb.leftTop.point.x = map.Envelope.Min.X; bb.leftTop.point.y = map.Envelope.Max.Y; bb.rightBottom = new Point(); bb.rightBottom.point = new PlainPoint(); bb.rightBottom.point.x = map.Envelope.Max.X; bb.rightBottom.point.y = map.Envelope.Min.Y; MapParams mapParams = new MapParams(); mapParams.showScale = true; mapParams.useMiles = false; ImageInfo imageInfo = new ImageInfo(); imageInfo.format = ImageFileFormat.PNG; imageInfo.height = map.Size.Height; imageInfo.width = map.Size.Width; switch (m_xMapServerMode) { case XMapServerMode.All: { Ptv.Controls.Map.XMap.Map xmap = svcMap.renderMapBoundingBox(bb, mapParams, imageInfo, null, true, null); MemoryStream imageStream = new MemoryStream(xmap.image.rawImage); System.Drawing.Image image = System.Drawing.Image.FromStream(imageStream); System.Drawing.Bitmap bmp = image as System.Drawing.Bitmap; bmp.MakeTransparent(System.Drawing.Color.FromArgb(255, 254, 185)); g.DrawImageUnscaled(image, 0, 0); return; } case XMapServerMode.BackGround: { // render only backgound and street StaticLayer slTown = new StaticLayer(); slTown.visible = false; slTown.name = "town"; slTown.detailLevel = 0; slTown.category = -1; StaticLayer slStreet = new StaticLayer(); slStreet.visible = true; slStreet.name = "street"; slStreet.detailLevel = 0; slStreet.category = -1; StaticLayer slBackground = new StaticLayer(); slBackground.visible = true; slBackground.name = "background"; slBackground.detailLevel = 0; slBackground.category = -1; Ptv.Controls.Map.XMap.Layer[] arrLayer = new Ptv.Controls.Map.XMap.Layer[] { slBackground, slStreet, slTown }; Ptv.Controls.Map.XMap.Map xmap = svcMap.renderMapBoundingBox(bb, mapParams, imageInfo, arrLayer, true, null); MemoryStream imageStream = new MemoryStream(xmap.image.rawImage); System.Drawing.Image image = System.Drawing.Image.FromStream(imageStream); System.Drawing.Bitmap bmp = image as System.Drawing.Bitmap; g.DrawImageUnscaled(image, 0, 0); return; } case XMapServerMode.Overlay: { // render only town StaticLayer slTown = new StaticLayer(); slTown.visible = true; slTown.name = "town"; slTown.detailLevel = 0; slTown.category = -1; StaticLayer slStreet = new StaticLayer(); slStreet.visible = false; slStreet.name = "street"; slStreet.detailLevel = 0; slStreet.category = -1; StaticLayer slBackground = new StaticLayer(); slBackground.visible = false; slBackground.name = "background"; slBackground.detailLevel = 0; slBackground.category = -1; Ptv.Controls.Map.XMap.Layer[] arrLayer = new Ptv.Controls.Map.XMap.Layer[] { slBackground, slStreet, slTown }; Ptv.Controls.Map.XMap.Map xmap = svcMap.renderMapBoundingBox(bb, mapParams, imageInfo, arrLayer, true, null); MemoryStream imageStream = new MemoryStream(xmap.image.rawImage); System.Drawing.Image image = System.Drawing.Image.FromStream(imageStream); System.Drawing.Bitmap bmp = image as System.Drawing.Bitmap; // make map background color transparent bmp.MakeTransparent(System.Drawing.Color.FromArgb(255, 254, 185)); g.DrawImageUnscaled(image, 0, 0); return; } } }