예제 #1
0
        virtual public void update(GameTime gameTime)
        {
            m_Animate.updatePosition(m_Position);

            CollisionType[,] temp = Level.backgroundCollisionCheck(Destination);

            int count = 0;

            for (int i = 0; i < temp.GetLength(0); i++)
            {
                for (int j = 0; j < temp.GetLength(1); j++)
                {
                    if (temp[i, j].m_WasThereACollision == true)
                    {
                        count++;
                        switch (temp[i, j].m_FirstObjectSideCollided)
                        {
                        case SideCollided.BOTTOM:
                            if (this is Player)
                            {
                                Player.setIsOnGround(true);
                            }
                            m_Position.Y -= temp[i, j].m_OverlapArea.Height;
                            break;

                        case SideCollided.TOP:
                            if (this is Player)
                            {
                                Player.setIsJumping(false);
                            }
                            m_Position.Y += temp[i, j].m_OverlapArea.Height;
                            break;

                        case SideCollided.LEFT:
                            m_Position.X += temp[i, j].m_OverlapArea.Width;
                            break;

                        case SideCollided.RIGHT:
                            m_Position.X -= temp[i, j].m_OverlapArea.Width;
                            break;
                        }
                        if (count >= 3)
                        {
                            break;
                        }
                    }
                }
                if (count >= 3)
                {
                    break;
                }
            }
            m_Animate.update(gameTime);
            m_Animate.updatePosition(m_Position);
        }
예제 #2
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);
                }
            }
        }