示例#1
0
        /// <summary>
        /// Creates a new instance of the BladeSpinner Class
        /// </summary>
        /// <param name="id">the ID for the base enemy class</param>
        /// <param name="content">A ContentManager to load resources with</param>
        /// <param name="position">The position of the Dart ship in the game world</param>
        public BladeSpinner(uint id, ContentManager content, Vector2 position)
            : base(id)
        {
            spritesheet = content.Load <Texture2D>("Spritesheets/newsh#.shp.000000");

            //Moves frame initialization to a separate function to make the constructor cleaner
            initializeFrames();

            this.position = position;

            //initial directiion and state settings
            horDir       = flightDirection.positive;
            vertDir      = flightDirection.positive;
            patrolVector = new Vector2(50, 1);

            state = spinnerState.flying;
            frame = animationFrame.flying1;

            frameTimer = 0;
        }
        /// <summary>
        /// Creates a new instance of the BladeSpinner Class
        /// </summary>
        /// <param name="id">the ID for the base enemy class</param>
        /// <param name="content">A ContentManager to load resources with</param>
        /// <param name="position">The position of the Dart ship in the game world</param>
        public BladeSpinner(uint id, ContentManager content, Vector2 position)
            : base(id)
        {
            spritesheet = content.Load<Texture2D>("Spritesheets/newsh#.shp.000000");

            //Moves frame initialization to a separate function to make the constructor cleaner
            initializeFrames();

            this.position = position;

            //initial directiion and state settings
            horDir = flightDirection.positive;
            vertDir = flightDirection.positive;
            patrolVector = new Vector2(50, 1);

            state = spinnerState.flying;
            frame = animationFrame.flying1;

            frameTimer = 0;
        }
示例#3
0
        /// <summary>
        /// Draw the BladeSpinner on screen
        /// </summary>
        /// <param name="elapsedTime">The in-game time between the previous and current frame</param>
        /// <param name="spriteBatch">An already initialized SpriteBatch, ready for Draw() commands</param>
        public override void Draw(float elapsedTime, SpriteBatch spriteBatch)
        {
            //If the spinner is dead there is nothing to draw
            if (state == spinnerState.dead)
            {
                return;
            }

            //slow down the animation using the frame timer
            frameTimer += elapsedTime;

            //conditions to determine the animation frames to use.
            //There is likely a much more efficient way to do this
            if (frameTimer > .05f)
            {
                switch (state)
                {
                case spinnerState.flying:
                    frameTimer = 0;
                    switch (frame)
                    {
                    case animationFrame.flying1:
                    case animationFrame.flying2:
                    case animationFrame.flying3:
                        frame++;
                        break;

                    default:
                        frame = 0;
                        break;
                    }
                    break;

                case spinnerState.attacking:
                    frameTimer = 0;
                    switch (frame)
                    {
                    case animationFrame.attacking1:
                        frame++;
                        break;

                    default:
                        frame = animationFrame.attacking1;
                        break;
                    }
                    break;

                case spinnerState.dying:
                    //slow down dying annimation
                    frameTimer = -.1f;
                    switch (frame)
                    {
                    case animationFrame.dying1:
                    case animationFrame.dying2:
                    case animationFrame.dying3:
                    case animationFrame.dying4:
                        frame++;
                        break;

                    case animationFrame.dying5:
                        state = spinnerState.dead;
                        break;

                    default:
                        frame = animationFrame.dying1;
                        break;
                    }
                    break;
                }
            }
            spriteBatch.Draw(spritesheet, Bounds, spriteBounds[(int)frame], Color.White);
        }
        /// <summary>
        /// Draw the BladeSpinner on screen
        /// </summary>
        /// <param name="elapsedTime">The in-game time between the previous and current frame</param>
        /// <param name="spriteBatch">An already initialized SpriteBatch, ready for Draw() commands</param>
        public override void Draw(float elapsedTime, SpriteBatch spriteBatch)
        {
            //If the spinner is dead there is nothing to draw
            if (state == spinnerState.dead)
                return;

            //slow down the animation using the frame timer
            frameTimer += elapsedTime;

            //conditions to determine the animation frames to use.
            //There is likely a much more efficient way to do this
            if (frameTimer > .05f)
            {
                switch (state)
                {
                    case spinnerState.flying:
                        frameTimer = 0;
                        switch (frame)
                        {
                            case animationFrame.flying1:
                            case animationFrame.flying2:
                            case animationFrame.flying3:
                                frame++;
                                break;
                            default:
                                frame = 0;
                                break;
                        }
                        break;
                    case spinnerState.attacking:
                        frameTimer = 0;
                        switch (frame)
                        {
                            case animationFrame.attacking1:
                                frame++;
                                break;
                            default:
                                frame = animationFrame.attacking1;
                                break;
                        }
                        break;
                    case spinnerState.dying:
                        //slow down dying annimation
                        frameTimer = -.1f;
                        switch (frame)
                        {
                            case animationFrame.dying1:
                            case animationFrame.dying2:
                            case animationFrame.dying3:
                            case animationFrame.dying4:
                                frame++;
                                break;
                            case animationFrame.dying5:
                                state = spinnerState.dead;
                                break;
                            default:
                                frame = animationFrame.dying1;
                                break;
                        }
                        break;
                }
            }
            spriteBatch.Draw(spritesheet, Bounds, spriteBounds[(int)frame], Color.White);
        }