Example #1
0
        public override void Fall(bool isSuperFlash)
        {
            recoverTimer = 0;

            if (charState != StreakerState.FALL)
            {
                draw.Reset();
            }

            charState = StreakerState.FALL;

            physics.SetTargetValues(true, null, null, null);

            return;
        }
Example #2
0
        public void GetHit()
        {
            if (stayDown)
            {
                return;
            }
            if (!isSlickBoost && charState != StreakerState.FALL && charState != StreakerState.GET_UP
                && recoverTimer > TIME_TO_RECOVER)
            {
                SoundManager.GetInstance().PlaySound("Common", "Hit");
                recoverTimer = 0;
                draw.Reset();
                charState = StreakerState.FALL;

                HUD.getInstance().decreaseHealth(10);

                physics.SetTargetValues(true, null, null, null);
            }
        }
Example #3
0
        public void UpdateStates(bool animComplete)
        {
            switch (charState)
            {
                case StreakerState.STATIC:
                    draw.animation = SpriteDatabase.GetAnimation("streaker_static");
                    draw.Play();
                    break;
                case StreakerState.WALK:
                    if (flip)
                    {
                        draw.SpriteEffect = SpriteEffects.FlipHorizontally;
                    }
                    else
                    {
                        draw.SpriteEffect = SpriteEffects.None;
                    }
                    draw.animation = SpriteDatabase.GetAnimation("streaker_walk");
                    draw.Play();
                    break;
                case StreakerState.FALL:
                    if (animComplete)
                    {
                        SoundManager.GetInstance().PlaySound("Common", "Fall", Position, Position);
                        draw.animation = SpriteDatabase.GetAnimation("streaker_getup");
                        charState = StreakerState.GET_UP;
                        draw.Reset();
                    }
                    else
                    {
                        draw.animation = SpriteDatabase.GetAnimation("streaker_fall");
                        draw.Play();
                    }
                    break;
                case StreakerState.GET_UP:

                    if (animComplete)
                    {
                        draw.animation = SpriteDatabase.GetAnimation("streaker_static");
                        charState = StreakerState.STATIC;
                        draw.Reset();
                    }
                    else
                    {
                        draw.animation = SpriteDatabase.GetAnimation("streaker_getup");
                        draw.Play();
                    }

                    if (isDead)
                    {
                        stayDown = true;
                    }
                    break;
                case StreakerState.DANCE:
                    draw.animation = SpriteDatabase.GetAnimation("streaker_dance");
                    break;
                case StreakerState.SUPERFLASH:
                    if (animComplete)
                    {
                        superFlashTimer = 0;
                        superFlash();
                        draw.animation = SpriteDatabase.GetAnimation("streaker_static");
                        charState = StreakerState.STATIC;
                        draw.Reset();
                    }
                    else
                    {
                        if (draw.CurrentFrame == 4)
                            superFlashParticles.Start();

                        draw.animation = SpriteDatabase.GetAnimation("streaker_flash");
                        draw.Play();
                    }
                    break;
            }
        }
Example #4
0
 /// <summary>
 /// Move up
 /// </summary>
 private void moveUp()
 {
     direction += -Vector2.UnitY;
     charState = StreakerState.WALK;
 }
Example #5
0
 /// <summary>
 /// Move right
 /// </summary>
 private void moveRight()
 {
     direction += Vector2.UnitX;
     charState = StreakerState.WALK;
     flip = false;
 }
Example #6
0
 /// <summary>
 /// Move left
 /// </summary>
 private void moveLeft()
 {
     direction += -Vector2.UnitX;
     charState = StreakerState.WALK;
     flip = true;
 }
Example #7
0
        /// <summary>
        /// Deals with the user input from gamepad or keyboard
        /// </summary>
        /// <param name="gameTime">Game time</param>
        private void handleUserInput(GameTime gameTime)
        {
            inputTimer += gameTime.ElapsedGameTime.Milliseconds;
            superFlashTimer += gameTime.ElapsedGameTime.Milliseconds;
            recoverTimer += gameTime.ElapsedGameTime.Milliseconds;

            if (inputTimer < inputDelay)
            {
                return;
            }
            else
            {
                inputTimer = 0;
            }

            // Reset direction
            direction = Vector2.Zero;

            // Get input manager instance
            InputManager input = InputManager.GetInstance();

            // Check input
            // Dance takes precedence
            if (input.IsDoing("Dance", PlayerIndex.One))
            {
                HUD.getInstance().DanceNotify = false;
                if (charState != StreakerState.DANCE)
                {
                    draw.Reset();
                    SoundManager.GetInstance().PlaySound("Streaker", "Dance", Position, Position);
                }

                charState = StreakerState.DANCE;

                physics.SetTargetValues(true, null, null, null);
            }
            // Dance takes precedence
            else if (input.IsDoing("Superflash", PlayerIndex.One) && superFlashTimer > superFlashDelay)
            {
                if (charState != StreakerState.SUPERFLASH)
                {
                    draw.Reset();
                    SoundManager.GetInstance().PlaySound("Streaker", "SuperFlash", Position, Position);
                }

                charState = StreakerState.SUPERFLASH;

                physics.SetTargetValues(true, null, null, null);
            }
            // Else check movement
            else
            {
                if (input.IsDoing("Left", PlayerIndex.One))
                {
                    moveLeft();
                }
                if (input.IsDoing("Right", PlayerIndex.One))
                {
                    moveRight();
                }
                if (input.IsDoing("Up", PlayerIndex.One))
                {
                    moveUp();
                }
                if (input.IsDoing("Down", PlayerIndex.One))
                {
                    moveDown();
                }

                // If no movement, static
                if (direction == Vector2.Zero)
                {
                    if (charState != StreakerState.STATIC)
                    {
                        draw.Reset();
                    }

                    charState = StreakerState.STATIC;

                    physics.SetTargetValues(true, null, null, null);
                }
                else
                {
                    physics.SetTargetValues(false, direction, null, null);
                }
            }
        }