Exemplo n.º 1
0
        //-----------------------------------------------------------------------------
        // Internal methods
        //-----------------------------------------------------------------------------

        private void Explode()
        {
            BombExplosion bombExplosion = new BombExplosion();

            RoomControl.SpawnEntity(bombExplosion, Center, zPosition);
            AudioSystem.PlaySound(GameData.SOUND_BOMB_EXPLODE);

            // Explode nearby top tiles.
            if (zPosition < 4)
            {
                Rectangle2F tileExplodeArea = Rectangle2F.Zero.Inflated(12, 12);
                tileExplodeArea.Point += Center;

                Rectangle2I area = RoomControl.GetTileAreaFromRect(tileExplodeArea);

                for (int x = area.Left; x < area.Right; x++)
                {
                    for (int y = area.Top; y < area.Bottom; y++)
                    {
                        Tile        tile     = RoomControl.GetTopTile(x, y);
                        Rectangle2F tileRect = new Rectangle2F(x * 16, y * 16, 16, 16);
                        if (tile != null && tileRect.Intersects(tileExplodeArea))
                        {
                            tile.OnBombExplode();
                        }
                    }
                }
            }

            DestroyAndTransform(bombExplosion);
        }