Exemple #1
0
        /// <summary>
        /// Adds the specified sprite object to the specified container, using the sprite's metadata from the specified piece art.
        /// </summary>
        /// <param name="girl">The <see cref="Girl"/> instance the sprite object will be added to (only used for alt. girl checking).</param>
        /// <param name="sprite">The sprite object to add.</param>
        /// <param name="pieceArt">The piece art with metadata for the sprite object.</param>
        /// <param name="container">The container to which to add the sprite object to.</param>
        /// <param name="removeChildren">Whether to remove and destroy all existing children in the container.</param>
        /// <remarks>
        /// An alternative way to add sprites to any container, making it possible to manually manage the <see cref="tk2dBaseSprite.Collection"/>
        /// and the option to keep any existing children in the container.
        /// </remarks>
        public static void AddSpriteObjectToContainer(this Girl girl, SpriteObject sprite, GirlPieceArt pieceArt, DisplayObject container, bool removeChildren = true)
        {
            if (sprite != null && pieceArt != null && container != null && !pieceArt.spriteName.IsNullOrWhiteSpace())
            {
                if (removeChildren && container.GetChildren().Length > 0)
                {
                    container.RemoveAllChildren(true);
                }

                container.AddChild(sprite);
                sprite.sprite.FlipX = girl.flip;
                var offsetX = girl.flip ? GameCamera.SCREEN_DEFAULT_WIDTH : 0;
                sprite.SetLocalPosition(Mathf.Abs(offsetX - pieceArt.x), -pieceArt.y);
            }
        }
Exemple #2
0
 /// <summary>
 /// Creates a <see cref="SpriteObject"/> from the specified <see cref="GirlPieceArt"/> and adds it to the specified container.
 /// </summary>
 /// <param name="girl">The <see cref="Girl"/> instance the piece art will be added to.</param>
 /// <param name="girlPieceArt">The piece art to be added to the <see cref="Girl"/> instance.</param>
 /// <param name="container">The container to which to add the piece art to. All the existing children of the container will be destroyed.</param>
 /// <remarks>Note that this expects that the <see cref="GirlPieceArt.spriteName"/> value exist in <see cref="Girl.spriteCollection"/>.</remarks>
 public static void AddGirlPieceArtToContainer(this Girl girl, GirlPieceArt girlPieceArt, DisplayObject container)
 {
     AccessTools.Method(typeof(Girl), nameof(AddGirlPieceArtToContainer)).Invoke(girl, new object[] { girlPieceArt, container });
 }