Beispiel #1
0
        float viewOffset; // view offset moves sprite in direction of camera

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Create a new animated sprite
        /// </summary>
        public AnimSprite(
                AnimSpriteType type,
                Vector3 position, float radius, float viewOffset,
                Texture2D texture, int frameSizeX, int frameSizeY,
                float frameRate, DrawMode mode, int player)
        {
            if (texture == null)
            {
                throw new ArgumentNullException("texture");
            }

            spriteType = type;
            this.position = position;
            this.radius = radius;
            this.viewOffset = viewOffset;
            this.texture = texture;
            this.player = player;
            this.frameRate = frameRate;
            this.drawMode = mode;

            // frame size
            float sizeX = (float)frameSizeX / (float)texture.Width;
            float sizeY = (float)frameSizeY / (float)texture.Height;
            frameSize = new Vector2(sizeX, sizeY);

            // number of frames
            numberFramesX = texture.Width / frameSizeX;
            numberFramesY = texture.Height / frameSizeY;
            numberFrames = numberFramesX * numberFramesY;

            // total animation time
            totalTime = (float)numberFrames / frameRate;
            elapsedTime = 0;
        }
Beispiel #2
0
        /// <summary>
        /// Create a new animated sprite
        /// </summary>
        public AnimSprite(
            AnimSpriteType type,
            Vector3 position, float radius, float viewOffset,
            Texture2D texture, int frameSizeX, int frameSizeY,
            float frameRate, DrawMode mode, int player)
        {
            if (texture == null)
            {
                throw new ArgumentNullException("texture");
            }

            spriteType      = type;
            this.position   = position;
            this.radius     = radius;
            this.viewOffset = viewOffset;
            this.texture    = texture;
            this.player     = player;
            this.frameRate  = frameRate;
            this.drawMode   = mode;

            // frame size
            float sizeX = (float)frameSizeX / (float)texture.Width;
            float sizeY = (float)frameSizeY / (float)texture.Height;

            frameSize = new Vector2(sizeX, sizeY);

            // number of frames
            numberFramesX = texture.Width / frameSizeX;
            numberFramesY = texture.Height / frameSizeY;
            numberFrames  = numberFramesX * numberFramesY;

            // total animation time
            totalTime   = (float)numberFrames / frameRate;
            elapsedTime = 0;
        }
Beispiel #3
0
 /// <summary>
 /// Set projectile explosion parameters
 /// </summary>
 public void SetExplosion(
     AnimSpriteType sprite, float size, float frameRate, DrawMode mode,
     float damage, float damageRadius, String sound)
 {
     animatedSprite          = sprite;
     animatedSpriteSize      = size;
     animatedSpriteFrameRate = frameRate;
     animatedSpriteDrawMode  = mode;
     explosionDamage         = damage;
     explosionDamageRadius   = damageRadius;
     explosionSound          = sound;
 }
Beispiel #4
0
 /// <summary>
 /// Set projectile explosion parameters
 /// </summary>
 public void SetExplosion(
     AnimSpriteType sprite, float size, float frameRate, DrawMode mode,
     float damage, float damageRadius, String sound)
 {
     animatedSprite = sprite;
     animatedSpriteSize = size;
     animatedSpriteFrameRate = frameRate;
     animatedSpriteDrawMode = mode;
     explosionDamage = damage;
     explosionDamageRadius = damageRadius;
     explosionSound = sound;
 }
Beispiel #5
0
        /// <summary>
        /// Create a new animated sprite and add it to the animated sprite manager
        /// </summary>
        public AnimSprite AddAnimSprite(
            AnimSpriteType type,
            Vector3 position,
            float radius,
            float viewOffset,
            float frameRate,
            DrawMode mode,
            int player)
        {
            // create animated sprite
            AnimSprite a = new AnimSprite(type, position, radius, viewOffset,
                animatedSpriteTextures[(int)type], 256, 256,
                frameRate, mode, player);

            // add it to the animated sprite manager
            animatedSprite.Add(a);

            return a;
        }