Exemple #1
0
 /// <summary>
 /// Creates a new instance of <see cref="Animation"/> for the given <see cref="AnimPlayer"/>, using the given <see cref="AnimationSource"/> and
 /// rendering with <see cref="PlayerLayer"/>.
 /// </summary>
 /// <param name="controller"><see cref="AnimationController"/> instance this will belong to.</param>
 /// <param name="source"><see cref="AnimationSource"/> to determine which sprite is drawn.</param>
 /// <exception cref="System.InvalidOperationException">Animation classes are not allowed to be constructed on a server.</exception>
 internal Animation([NotNull] AnimationController controller, [NotNull] AnimationSource source)
 {
     if (!AnimLoader.UseAnimations)
     {
         throw new InvalidOperationException("Animation classes are not allowed to be constructed on servers.");
     }
     this.controller = controller;
     this.source     = source;
     CheckIfValid(controller.TrackName);
 }
Exemple #2
0
        /// <summary>
        /// Gets a <see cref="Rectangle"/> that represents the sprite in the <see cref="AnimationSource"/>.
        /// </summary>
        /// <param name="source">The <see cref="AnimationSource"/>.</param>
        /// <returns></returns>
        public Rectangle ToRectangle(AnimationSource source)
        {
            PointByte size = source.spriteSize;

            return(new Rectangle(tile.x * size.x, tile.y * size.y, size.x, size.y));
        }