public void DrawPart(BufferedGraphics currBuffer, List <Bitmap> images, PartExplosion partExplosion) { lock (currBuffer) { lock (images) { lock (images[(int)partExplosion.kindExplosion]) { currBuffer.Graphics.DrawImage(images[(int)partExplosion.kindExplosion], partExplosion.location.X, partExplosion.location.Y, new Rectangle(new Point(partExplosion.currSpriteOffset, 0), partExplosion.size), GraphicsUnit.Pixel); } } } }
private void InitExplosion ( Size size, Point location, int radius, PhysicalMap map ) { const int countStates = 7; partsExplosionBottom = new List <PartExplosion>(); partsExplosionLeft = new List <PartExplosion>(); partsExplosionRight = new List <PartExplosion>(); partsExplosionUp = new List <PartExplosion>(); countParts = 0; for (int i = 0; i < radius; i++) { if ((location.X - size.Width * (i + 1)) > 0) { if (!canWePlaceExplosion(location.X - size.Width * (i), location.Y, map, ExplosionDirection.LEFT)) { if (i < radius - 1) { partsExplosionLeft.Add(new PartExplosion(KindExplosionTexture.explosionTextureHorizontalMiddle, size, new Point((location.X - size.Width * (i + 1)), location.Y), countStates, onEndExplosionFunc)); } else { partsExplosionLeft.Add(new PartExplosion(KindExplosionTexture.explosionTextureLeftEdge, size, new Point((location.X - size.Width * (i + 1)), location.Y), countStates, onEndExplosionFunc)); } countParts++; } else { partsExplosionLeft.Add(new PartExplosion(KindExplosionTexture.explosionTextureHorizontalMiddle, size, new Point(newLocation.X, newLocation.Y), countStates, onEndExplosionFunc)); break; } } else { if (i < radius - 1) { partsExplosionLeft.Add(new PartExplosion(KindExplosionTexture.explosionTextureHorizontalMiddle, size, new Point(0, location.Y), countStates, onEndExplosionFunc)); } else { partsExplosionLeft.Add(new PartExplosion(KindExplosionTexture.explosionTextureLeftEdge, size, new Point(0, location.Y), countStates, onEndExplosionFunc)); } countParts++; break; } } for (int i = 0; i < radius; i++) { if ((location.X + size.Width * (i + 1)) < map.Width) { if (!canWePlaceExplosion(location.X + size.Width * (i), location.Y, map, ExplosionDirection.RIGHT)) { if (i < radius - 1) { partsExplosionRight.Add(new PartExplosion(KindExplosionTexture.explosionTextureHorizontalMiddle, size, new Point((location.X + size.Width * (i + 1)), location.Y), countStates, onEndExplosionFunc)); } else { partsExplosionRight.Add(new PartExplosion(KindExplosionTexture.explosionTextureRightEdge, size, new Point((location.X + size.Width * (i + 1)), location.Y), countStates, onEndExplosionFunc)); } countParts++; } else { partsExplosionLeft.Add(new PartExplosion(KindExplosionTexture.explosionTextureHorizontalMiddle, size, new Point(newLocation.X, newLocation.Y), countStates, onEndExplosionFunc)); break; } } else { if (i < radius - 1) { partsExplosionRight.Add(new PartExplosion(KindExplosionTexture.explosionTextureHorizontalMiddle, size, new Point((map.Width - size.Width), location.Y), countStates, onEndExplosionFunc)); } else { partsExplosionRight.Add(new PartExplosion(KindExplosionTexture.explosionTextureRightEdge, size, new Point(map.Width - size.Width, location.Y), countStates, onEndExplosionFunc)); } countParts++; break; } } for (int i = 0; i < radius; i++) { if ((location.Y - size.Height * (i + 1)) > 0) { if (!canWePlaceExplosion(location.X, location.Y - size.Height * (i), map, ExplosionDirection.UP)) { if (i < radius - 1) { partsExplosionUp.Add(new PartExplosion(KindExplosionTexture.explosionTextureVerticalMiddle, size, new Point(location.X, location.Y - size.Height * (i + 1)), countStates, onEndExplosionFunc)); } else { partsExplosionUp.Add(new PartExplosion(KindExplosionTexture.explosionTextureUpEdge, size, new Point(location.X, location.Y - size.Height * (i + 1)), countStates, onEndExplosionFunc)); } countParts++; } else { partsExplosionUp.Add(new PartExplosion(KindExplosionTexture.explosionTextureVerticalMiddle, size, new Point(newLocation.X, newLocation.Y), countStates, onEndExplosionFunc)); break; } } else { if (i < radius - 1) { partsExplosionUp.Add(new PartExplosion(KindExplosionTexture.explosionTextureVerticalMiddle, size, new Point(location.X, 0), countStates, onEndExplosionFunc)); } else { partsExplosionUp.Add(new PartExplosion(KindExplosionTexture.explosionTextureUpEdge, size, new Point(location.X, 0), countStates, onEndExplosionFunc)); } countParts++; break; } } for (int i = 0; i < radius; i++) { if ((location.Y + size.Height * (i + 1)) < map.Height) { if (!canWePlaceExplosion(location.X, location.Y + size.Height * (i), map, ExplosionDirection.DOWN)) { if (i < radius - 1) { partsExplosionBottom.Add(new PartExplosion(KindExplosionTexture.explosionTextureVerticalMiddle, size, new Point(location.X, location.Y + size.Height * (i + 1)), countStates, onEndExplosionFunc)); } else { partsExplosionBottom.Add(new PartExplosion(KindExplosionTexture.explosionTextureBottomEdge, size, new Point(location.X, location.Y + size.Height * (i + 1)), countStates, onEndExplosionFunc)); } countParts++; } else { partsExplosionUp.Add(new PartExplosion(KindExplosionTexture.explosionTextureVerticalMiddle, size, new Point(newLocation.X, newLocation.Y), countStates, onEndExplosionFunc)); break; } } else { if (i < radius - 1) { partsExplosionBottom.Add(new PartExplosion(KindExplosionTexture.explosionTextureVerticalMiddle, size, new Point(location.X, map.Height - size.Height), countStates, onEndExplosionFunc)); } else { partsExplosionBottom.Add(new PartExplosion(KindExplosionTexture.explosionTextureBottomEdge, size, new Point(location.X, map.Height - size.Height), countStates, onEndExplosionFunc)); } countParts++; break; } } partExplosionCenter = new PartExplosion(KindExplosionTexture.explosionTextureCenter, size, location, countStates, onEndExplosionFunc); countParts++; }