Exemple #1
0
 public void ChangeSet()
 {
     App.AppXC.ContentManager.Dispose();
     atlas.Dispose();
     atlas = null;
     App.AppXC.LoadContent.Invoke(App.AppXC.ContentManager);
 }
        // Protected implementation of Dispose pattern.
        protected override void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                // Dispose managed state (managed objects).
                if (_effect != null)
                {
                    _effect.Dispose();
                }
                if (_atlas != null)
                {
                    _atlas.Dispose();
                }
                _effect = null;
                _atlas  = null;
                _state  = null;
                //skeletonData = null;
                _skeleton         = null;
                _skeletonRenderer = null;
            }

            _disposed = true;

            // Call base class implementation.
            base.Dispose(disposing);
        }
Exemple #3
0
        public override void Dispose()
        {
            if (_matHblur != null)
            {
                _matHblur.Dispose();
            }
            if (_matVblur != null)
            {
                _matVblur.Dispose();
            }
            if (_sprites != null)
            {
                _sprites.Dispose();
            }
            if (_fb != null)
            {
                _fb.Dispose();
            }
            if (_quad != null)
            {
                _quad.Dispose();
            }

            base.Dispose();
        }
 public void Clear()
 {
     if (atlas != null)
     {
         atlas.Dispose();
         atlas = null;
     }
 }
Exemple #5
0
 public override void Dispose()
 {
     if (_atlas != null)
     {
         _atlas.Dispose();
     }
     base.Dispose();
 }
 public void Dispose()
 {
     if (!disposed)
     {
         disposed = true;
         Sources.Dispose();
         Atlas.Dispose();
         AtlasSRV.Dispose();
     }
 }
Exemple #7
0
        public override void Dispose()
        {
            if (_cam != null)
            {
                _cam.Dispose();
            }
            if (_coin != null)
            {
                _coin.Dispose();
            }

            base.Dispose();
        }
Exemple #8
0
        public override void Dispose()
        {
            if (_cam != null)
            {
                _cam.Dispose();
            }
            if (_numbers != null)
            {
                _numbers.Dispose();
            }

            base.Dispose();
        }
Exemple #9
0
        public override void Dispose()
        {
            if (_sprites != null)
            {
                _sprites.Dispose();
            }
            if (_font != null)
            {
                _font.Dispose();
            }

            base.Dispose();
        }
Exemple #10
0
        public override void Dispose()
        {
            if (_sprites != null)
            {
                _sprites.Dispose();
            }

            if (_batch != null)
            {
                _batch.Dispose();
            }

            base.Dispose();
        }
        public static SkeletonData LoadSkeleton(Wz_Node atlasNode, SkeletonLoadType loadType, TextureLoader textureLoader)
        {
            string atlasData = atlasNode.GetValueEx <string>(null);

            if (string.IsNullOrEmpty(atlasData))
            {
                return(null);
            }
            StringReader atlasReader = new StringReader(atlasData);

            Atlas        atlas = new Atlas(atlasReader, "", textureLoader);
            SkeletonData skeletonData;

            //加载skeleton
            switch (loadType)
            {
            case SkeletonLoadType.Json:
                if (!TryLoadSkeletonJson(atlasNode, atlas, out skeletonData))
                {
                    goto _failed;
                }
                break;

            case SkeletonLoadType.Binary:
                if (!TryLoadSkeletonBinary(atlasNode, atlas, out skeletonData))
                {
                    goto _failed;
                }
                break;

            default:
            case SkeletonLoadType.Auto:
                if (!TryLoadSkeletonJson(atlasNode, atlas, out skeletonData) &&
                    !TryLoadSkeletonBinary(atlasNode, atlas, out skeletonData))
                {
                    goto _failed;
                }
                break;
            }

            return(skeletonData);

_failed:
            if (atlas != null)
            {
                atlas.Dispose();
            }
            return(null);
        }
Exemple #12
0
        private void Dispose(bool isDisposing)
        {
            if (_disposed)
            {
                return;
            }

            if (isDisposing)
            {
                _disposed = true;

                if (Atlas != null)
                {
                    Atlas.Dispose();
                    Atlas = null;
                }
            }
        }
        /// <summary>
        /// Loads skeleton
        /// </summary>
        /// <param name="atlasNode"></param>
        /// <param name="textureLoader"></param>
        /// <returns></returns>
        public static SkeletonData LoadSkeleton(WzStringProperty atlasNode, TextureLoader textureLoader)
        {
            string atlasData = atlasNode.GetString();

            if (string.IsNullOrEmpty(atlasData))
            {
                return(null);
            }
            StringReader atlasReader = new StringReader(atlasData);

            Atlas        atlas = new Atlas(atlasReader, string.Empty, textureLoader);
            SkeletonData skeletonData;

            if (!TryLoadSkeletonJsonOrBinary(atlasNode, atlas, out skeletonData))
            {
                atlas.Dispose();
                return(null);
            }
            return(skeletonData);
        }
Exemple #14
0
        /// <summary>
        /// Draws this map.
        /// </summary>
        /// <param name="layer">Layer to draw.</param>
        /// <param name="game">Game class.</param>
        /// <param name="rectangle">The cropped part of the map to draw. null - draw whole map</param>
        public void Draw(Tile.MapLayer layer, Game game, Rectangle?rectangle = null)
        {
            if (Atlas != null && Atlas.Game != game)
            {
                Atlas.Dispose();
                Atlas = null;
            }

            if (Atlas == null)
            {
                Atlas = new TileAtlas(game);
            }

            if (TransitionCache != null && TransitionCache.Game != game)
            {
                TransitionCache.Dispose();
                TransitionCache = null;
            }

            if (TransitionCache == null)
            {
                TransitionCache = new TileTransitionCache(game);
            }

            int xMin = 0;
            int yMin = 0;
            int xMax = Width - 1;
            int yMax = Height - 1;

            if (rectangle.HasValue)
            {
                xMin = Math.Max(0, (int)Math.Floor(rectangle.Value.X / 16.0));
                yMin = Math.Max(0, (int)Math.Floor(rectangle.Value.Y / 16.0));
                xMax = Math.Min(Width - 1, (int)Math.Ceiling((rectangle.Value.X + rectangle.Value.Width - 1) / 16.0));
                yMax = Math.Min(Height - 1, (int)Math.Ceiling((rectangle.Value.Y + rectangle.Value.Height - 1) / 16.0));
            }

            // Add one more to allow for transitions outside the rectangle.
            if (xMin > 0)
            {
                xMin--;
            }
            if (yMin > 0)
            {
                yMin--;
            }

            if (xMax < Width - 1)
            {
                xMax++;
            }
            if (yMax < Height - 1)
            {
                yMax++;
            }

            Rectangle drawRectangle = new Rectangle(xMin, yMin, xMax - xMin, yMax - yMin);

            drawRectangle.X      *= 16;
            drawRectangle.Y      *= 16;
            drawRectangle.Width  *= 16;
            drawRectangle.Height *= 16;
            drawRectangle.Width  += 16;
            drawRectangle.Height += 16;

            if (layer == Tile.MapLayer.Terrain)
            {
                (WaterTiles.DeepWaterOrVoid as AnimatedTile).UpdateCurrentFrameWithGame(game, new Point(0, 0));

                if (Info.Environment == Environment.Inside)
                {
                    game.Batch.Rectangle(drawRectangle, Color.Black);
                }
                else
                {
                    game.Batch.Texture(drawRectangle, game.Assets.Get <Texture2D>(WaterTiles.DeepWaterOrVoid.TextureName()), Color.White, drawRectangle);
                }
            }

            int x, y;

            for (x = xMin; x <= xMax; x++)
            {
                for (y = yMin; y <= yMax; y++)
                {
                    Tile tile = this[layer, x, y];
                    if (tile.ID != "") // water will be drawn by the map manually here
                    {
                        tile.Draw(game, new Point(x, y), this, GetMetadata(layer, x, y), Info.Environment);
                    }
                }
            }

            for (x = xMin; x <= xMax; x++)
            {
                for (y = yMin; y <= yMax; y++)
                {
                    Tile tile = this[layer, x, y];
                    if (layer == Tile.MapLayer.Terrain || tile.ID != "")
                    {
                        Point p1 = new Point(x - 1, y);
                        Point p2 = new Point(x + 1, y);
                        Point p3 = new Point(x, y - 1);
                        Point p4 = new Point(x, y + 1);

                        for (int i = 0; i < 4; i++)
                        {
                            Point point = i == 0 ? p1 :
                                          i == 1 ? p2 :
                                          i == 2 ? p3 :
                                          p4;

                            if (point.X >= 0 && point.Y >= 0 && point.X < Width && point.Y < Height &&
                                tile.UseTransition(
                                    new Point(x, y),
                                    point,
                                    this,
                                    this[layer, point.X, point.Y],
                                    GetMetadata(layer, x, y),
                                    GetMetadata(layer, point.X, point.Y)))
                            {
                                Point     transitionPoint;
                                Texture2D transitionTexture = TransitionCache.TextureForTile(
                                    tile,
                                    GetMetadata(layer, x, y),
                                    Info.Environment,
                                    out transitionPoint);

                                float         rotation = 0;
                                SpriteEffects effects  = SpriteEffects.None;

                                if (point == new Point(x + 1, y))
                                {
                                    effects = SpriteEffects.FlipHorizontally;
                                }
                                if (point == new Point(x, y - 1))
                                {
                                    rotation = MathHelper.PiOver2;
                                }
                                if (point == new Point(x, y + 1))
                                {
                                    rotation = MathHelper.Pi + MathHelper.PiOver2;
                                }

                                Rectangle textureRectangle = new Rectangle(
                                    transitionPoint.X * 16,
                                    transitionPoint.Y * 16,
                                    16,
                                    16);

                                game.Batch.Texture(
                                    new Vector2(
                                        point.X * 16 + (rotation == MathHelper.PiOver2 ? 16 : 0),
                                        point.Y * 16 + (rotation == MathHelper.Pi + MathHelper.PiOver2 ? 16 : 0)),
                                    transitionTexture,
                                    Color.White,
                                    Vector2.One,
                                    textureRectangle,
                                    rotation,
                                    null,
                                    effects);
                            }
                        }
                    }
                }
            }

            for (x = xMin; x <= xMax; x++)
            {
                for (y = yMin; y <= yMax; y++)
                {
                    Tile tile = this[layer, x, y];
                    if (layer == Tile.MapLayer.Terrain || tile.ID != "")
                    {
                        tile.DrawAfterTransition(game, new Point(x, y), this, GetMetadata(layer, x, y), Info.Environment);
                    }
                }
            }
        }
 public override void Dispose()
 {
     atlas.Dispose();
     base.Dispose();
 }