Esempio n. 1
0
        public void update(GameTime gameTime)
        {
            if (IsActive == true)
            {
                if (m_BossState != BossState.DYING && m_BossState != BossState.DEAD)
                {
                    float elapsedTime = (float)gameTime.ElapsedGameTime.Milliseconds / 1000;

                    if (m_BossState == BossState.IDLE)
                    {
                        Vector2 temp;
                        Vector2.Subtract(ref m_Position, ref m_StartPos, out temp);
                        if (temp.Length() > (m_IdleMoveDist - (m_IdleMoveDist * m_LerpDist)))
                        {
                            do
                            {
                                m_TargetPos = new Vector2(m_Random.Next(100) - 50, m_Random.Next(100) - 50);
                            } while (m_TargetPos.X == 0 && m_TargetPos.Y == 0);
                            m_TargetPos.Normalize();
                            m_TargetPos.X = m_TargetPos.X * m_IdleMoveDist;
                            m_TargetPos.Y = m_TargetPos.Y * m_IdleMoveDist;
                        }
                        m_Position = Vector2.Lerp(m_Position, m_StartPos + m_TargetPos, m_LerpAmount);
                        Position   = m_Position;

                        m_StateChangeTimer += elapsedTime;

                        if (m_StateChangeTimer > m_StateDelay)
                        {
                            m_StateChangeTimer = 0.0f;
                            do
                            {
                                m_BossState = (BossState)(m_Random.Next((int)BossState.COUNT));
                                //m_BossState = BossState.CHARGING;
                            } while (m_BossState == BossState.LAVA_WAVE && m_LavaWave.IsActive == true);
                        }
                        m_Animate.changAnimation(1);
                    }
                    else if (m_BossState == BossState.CHARGING)
                    {
                        //boss is charging here ------------------------------------------------------------------------------------------------

                        for (int i = 0; i < m_Particles.Length; i++)
                        {
                            Vector2 temp;
                            temp = new Vector2(m_Random.Next(100) - 50, m_Random.Next(100) - 50);
                            temp.Normalize();
                            temp.X = temp.X * m_ChargeDist;
                            temp.Y = temp.Y * m_ChargeDist;

                            m_Particles[i].SpawnPoint        = new Vector2(m_Animate.DestinationRectangle.X, m_Animate.DestinationRectangle.Y) + temp;
                            m_Particles[i].DominantDirection = new Vector2(m_Animate.DestinationRectangle.X, m_Animate.DestinationRectangle.Y) - m_Particles[i].SpawnPoint;

                            m_Particles[i].Stop = false;

                            m_BossLaserPlayed = false;
                            if (m_BossChargingSoundPlayer == false)
                            {
                                Sounds.playSound("BossCharging", 1.0f);
                                m_BossChargingSoundPlayer = true;
                            }
                        }

                        m_StateChangeTimer += elapsedTime;

                        if (m_StateChangeTimer > m_StateDelay)
                        {
                            m_StateChangeTimer = 0.0f;

                            m_BossState = BossState.FIRING;

                            for (int i = 0; i < m_Particles.Length; i++)
                            {
                                m_Particles[i].Stop = true;
                            }

                            m_PlayerPos = new Vector2(Player.collisionRectangle().Center.X, Player.collisionRectangle().Center.Y);
                            if (m_Animate.DestinationRectangle.Y < m_PlayerPos.Y)
                            {
                                m_Direction = MovementValue.DOWN;
                            }
                            else
                            {
                                m_Direction = MovementValue.UP;
                            }
                        }
                    }
                    else if (m_BossState == BossState.FIRING)
                    {
                        m_Position.Y += m_Speed * elapsedTime * (int)m_Direction;
                        Position      = m_Position;

                        m_BossChargingSoundPlayer = false;

                        if (m_Direction == MovementValue.DOWN && m_Animate.DestinationRectangle.Y > m_PlayerPos.Y || m_Direction == MovementValue.UP && m_Animate.DestinationRectangle.Y < m_PlayerPos.Y)
                        {
                            //boss shoots here ---------------------------------------------------------------------------
                            if (m_BossLaserPlayed == false)
                            {
                                Sounds.playSound("BossLaser", 1.0f);
                                m_BossLaserPlayed = true;
                            }

                            m_BeamManager.addBeam(new Vector2(m_Animate.DestinationRectangle.X, m_Animate.DestinationRectangle.Y), m_PlayerPos);

                            m_BossState = BossState.IDLE;
                            m_Direction = MovementValue.NONE;
                        }
                    }
                    else if (m_BossState == BossState.LAVA_WAVE)
                    {
                        if (m_Position.X < m_StartPos.X + m_RetreatPos.X)
                        {
                            m_Position.X += m_Speed * elapsedTime;
                        }
                        else if ((m_Position.Y - m_Animate.DestinationRectangle.Height / 2 > m_StartPos.Y + m_RetreatPos.Y) && m_Drop == false)
                        {
                            m_Position.Y -= m_Speed * elapsedTime;


                            if (m_Position.Y - m_Animate.DestinationRectangle.Height / 2 < m_StartPos.Y + m_RetreatPos.Y)
                            {
                                m_Drop = true;
                            }
                        }
                        else if (m_Position.Y < m_StartPos.Y && m_Drop == true)
                        {
                            m_Position.Y += m_Speed * elapsedTime;
                            if (m_BossWavePlayed == false)
                            {
                                Sounds.playSound("Wave", 1.0f);
                                m_BossWavePlayed = true;
                            }

                            if (m_Position.Y > m_StartPos.Y)
                            {
                                m_LavaWave.SpawnTheWave(new Vector2(m_Position.X, Level.getHeightOfArray() * 32 - 2));
                                m_Drop           = false;
                                m_BossState      = BossState.IDLE;
                                m_BossWavePlayed = false;
                            }
                        }
                        Position = m_Position;
                    }
                    else if (m_BossState == BossState.NARWHAL)
                    {
                        if (Vector2.Subtract(m_Position, m_StartPos + m_RainPos).Length() > m_RainJumpDist)
                        {
                            Vector2 temp = new Vector2(m_StartPos.X + m_RainPos.X - m_Position.X, m_StartPos.Y + m_RainPos.Y - m_Position.Y);
                            temp.Normalize();
                            m_Position += temp * m_Speed / 4.0f * elapsedTime;
                        }
                        else
                        {
                            if (m_BossRoarPlayed == false)
                            {
                                Sounds.playSound("BossRoar", 1.0f);
                                m_BossRoarPlayed = true;
                            }
                            m_StateChangeTimer += elapsedTime;

                            Vector2 temp;
                            do
                            {
                                temp = new Vector2(m_Random.Next(100) - 50, m_Random.Next(100) - 50);
                            } while (temp.X == 0 && temp.Y == 0);

                            temp.Normalize();
                            temp.X *= m_RainJumpDist;
                            temp.Y *= m_RainJumpDist;

                            m_Position = m_StartPos + m_RainPos + temp;

                            m_NarwhalGun.NARWHAL(new Vector2(m_Position.X + m_GunPos.X, m_Position.Y + m_GunPos.Y));

                            //spitting narwhals here------------------------------------------------------------------------



                            if (m_StateChangeTimer > RAIN_LENGTH)
                            {
                                m_StateChangeTimer = 0.0f;
                                m_BossState        = BossState.IDLE;
                                m_BossRoarPlayed   = false;
                            }
                        }
                        Position = m_Position;
                    }
                }
                else if (m_BossState == BossState.DYING)
                {
                    m_Position = Vector2.Lerp(m_Position, m_StartPos + m_Hidden, m_LerpAmount);

                    //boss is dead here------------------------------------------------------------------------------------------
                    if (m_BossDeathPlayed == false)
                    {
                        Sounds.playSound("BossDeath", 1.0f);
                        m_BossDeathPlayed = true;
                    }

                    Vector2 temp;
                    do
                    {
                        temp = new Vector2(m_Random.Next(100) - 50, m_Random.Next(100) - 50);
                    } while (temp.X == 0 && temp.Y == 0);

                    temp.Normalize();
                    temp.X *= m_RainJumpDist / 2;
                    temp.Y *= m_RainJumpDist / 2;

                    m_Position += temp;
                    Position    = m_Position;

                    if (m_Position.Y > m_StartPos.Y + m_Hidden.Y)
                    {
                        m_BossState = BossState.DEAD;
                    }
                }
                else
                {
                    if (m_Position.Y < m_StartPos.Y + m_Hidden.Y + m_MoreHidden.Y)
                    {
                        m_Position.Y++;
                        Position = m_Position;
                        Vector2 tempy = m_Lava.Pos;
                        tempy.Y++;
                        m_Lava.Pos = tempy;
                    }
                }

                collisioncheck();

                m_NarwhalGun.update(gameTime);
                m_BeamManager.update(gameTime);
                m_LavaWave.update(gameTime);
                m_Animate.update(gameTime);

                m_Lava.update(gameTime);

                for (int i = 0; i < m_Particles.Length; i++)
                {
                    m_Particles[i].update(gameTime);
                }
            }
        }
Esempio n. 2
0
        //Added November 26, 2013
        //Handles all the input for controller and keyboard
        private void getInput(KeyboardState keyboardState, GamePadState gamePadState, MouseState mouseState, GameTime gameTime)
        {
            //Horizontal movement
            float stickInput = gamePadState.ThumbSticks.Left.X * MOVE_STICK_SCALE;

            if (gamePadState.IsConnected)
            {
                m_Input.getControllerInput(gamePadState);

                if (m_Input.m_WasMoveRightButtonDown == true || m_Input.m_WasMoveLeftButtonDown == true)
                {
                    if (stickInput != 0.0f)
                    {
                        m_Speed = START_SPEED * Math.Abs(stickInput);
                    }
                    else
                    {
                        m_Speed = START_SPEED;
                    }
                }
            }
            else
            {
                m_Speed = START_SPEED;
                m_Input.getKeyBoardInput(keyboardState, mouseState);
            }
            #region Button Is Up
            if (m_Input.m_WasMoveLeftButtonDown == false && m_Input.m_WasMoveRightButtonDown == false && m_Input.m_WasJumpButtonDown == false)
            {
                m_Particles.Stop = true;
                if (m_LastFacing == Facing.RIGHT)
                {
                    m_Facing = Facing.RIGHT;
                    m_Animate.changAnimation((int)Animations.IDLERIGHT);
                }
                else if (m_LastFacing == Facing.LEFT)
                {
                    m_Facing = Facing.LEFT;
                    m_Animate.changAnimation((int)Animations.IDLELEFT);
                }
            }

            if (m_Input.m_WasJumpButtonDown == false)
            {
                m_IsJumping = false;

                if (m_Facing == Facing.LEFT)
                {
                    //m_Animate.changAnimation((int)Facing.LEFT);
                }
                else if (m_Facing == Facing.RIGHT)
                {
                    //m_Animate.changAnimation((int)Facing.RIGHT);
                }
            }

            if (m_Input.m_WasRainbowButtonDown == false)
            {
                //TODO: Rainbow Teleport logic
            }

            if (m_Input.m_WasAttackButtonDown == false)
            {
                //TODO: Laser Projectile logic
            }
            #endregion

            #region Button Is Down
            if (m_Input.m_WasMoveLeftButtonDown == true && m_Input.m_WasJumpButtonDown == false)
            {
                //Added November 27, 2013
                m_Particles.Stop = false;

                m_Facing = Facing.LEFT;
                m_Animate.changAnimation((int)Animations.RUNNINGLEFT);
            }
            else if (m_Input.m_WasMoveRightButtonDown == true && m_Input.m_WasJumpButtonDown == false)
            {
                //Added November 27, 2013
                m_Particles.Stop = false;

                m_Facing = Facing.RIGHT;
                m_Animate.changAnimation((int)Animations.RUNNINGRIGHT);
            }

            if (m_Input.m_WasJumpButtonDown == true && m_Input.m_WasMoveLeftButtonDown == false && m_Input.m_WasMoveRightButtonDown == false)
            {
                if (m_IsOnGround == true)
                {
                    m_IsOnGround = false;
                    m_IsJumping  = true;

                    Sounds.playSound("Jump", 1);
                }
                if (m_Facing == Facing.LEFT)
                {
                    m_Animate.changAnimation((int)Animations.JUMPLEFT);
                }
                else if (m_Facing == Facing.RIGHT)
                {
                    m_Animate.changAnimation((int)Animations.JUMPRIGHT);
                }
            }

            if (m_Input.m_WasJumpButtonDown == true && m_Input.m_WasMoveLeftButtonDown == true)
            {
                if (m_IsOnGround == true)
                {
                    m_IsOnGround = false;
                    m_IsJumping  = true;

                    Sounds.playSound("Jump", 1);
                }
                m_Facing = Facing.LEFT;
                m_Animate.changAnimation((int)Animations.JUMPLEFT);
            }
            else if (m_Input.m_WasJumpButtonDown == true && m_Input.m_WasMoveRightButtonDown == true)
            {
                if (m_IsOnGround == true)
                {
                    m_IsOnGround = false;
                    m_IsJumping  = true;

                    Sounds.playSound("Jump", 1);
                }
                m_Facing = Facing.RIGHT;
                m_Animate.changAnimation((int)Animations.JUMPRIGHT);
            }

            if (m_Input.m_WasRainbowButtonDown == true)
            {
                //TODO: Rainbow Logic
            }

            if (m_Input.m_WasAttackButtonDown == true)
            {
                laserState(gameTime);
            }
        }