Exemplo n.º 1
0
        private void collisioncheck()
        {
            if (IsActive == true)
            {
                if (m_BossState == BossState.CHARGING)
                {
                    if (LaserManager.collisionCheck(m_HornDamageRect))
                    {
                        //take damge
                        m_Health--;
                        if (m_Health <= 0)
                        {
                            m_BossState = BossState.DYING;

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

                if (CollisionCheck.collisionCheck(m_CollisionRect, Player.collisionRectangle()))
                {
                    //for overkill damage
                    Player.instantDeath();
                }
            }
        }
Exemplo n.º 2
0
        public override void update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            float elapsedTime = (float)gameTime.ElapsedGameTime.Milliseconds / 1000;

            if (m_State == ImpState.ALIVE)
            {
                move(gameTime);
                animationRow(gameTime);

                if (CollisionCheck.collisionCheck(Destination, Player.collisionRectangle()))
                {
                    Player.takeDamage();
                }
            }
            else
            {
                m_Timer += elapsedTime;
                m_Animate.changAnimation((int)ImpAnimations.IDLEDYING);
                if (m_ImpDeathSoundPlayed == false)
                {
                    Sounds.playSound("ImpDeath", 0.5f);
                    m_ImpDeathSoundPlayed = true;
                }
            }

            base.update(gameTime);
        }
Exemplo n.º 3
0
 private void collisionCheck()
 {
     if (CollisionCheck.collisionCheck(m_Animate.DestinationRectangle, Player.collisionRectangle()))
     {
         Player.takeDamage();
     }
 }
Exemplo n.º 4
0
        public override void update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            float elapsedTime = (float)gameTime.ElapsedGameTime.Milliseconds / 1000;

            if (m_State == PixieState.ALIVE)
            {
                move(gameTime);

                if (Destination.Intersects(Player.collisionRectangle()) == true)
                {
                }
                else
                {
                    animationRow(gameTime);
                }

                if (CollisionCheck.collisionCheck(Destination, Player.collisionRectangle()))
                {
                    Player.takeDamage();
                }
            }
            else
            {
                m_Timer += elapsedTime;
                m_Animate.changAnimation((int)PixieAnimations.POOF);
                if (m_PixieDeathPlayed == false)
                {
                    Sounds.playSound("PixieDeath", 0.50f);
                    m_PixieDeathPlayed = true;
                }
            }

            base.update(gameTime);
        }
Exemplo n.º 5
0
        private void animationRow(GameTime gameTime)
        {
            float elapsedTime = (float)gameTime.ElapsedGameTime.Milliseconds / 1000;

            if (m_IsAggroed == true)
            {
                if (m_Position.X <= Player.collisionRectangle().Center.X)
                {
                    m_Animate.changAnimation((int)UndeadUnicornAnimations.LEFT);
                    m_LastAnimation = UndeadUnicornAnimations.LEFT;
                }
                else if (m_Position.X >= Player.collisionRectangle().Center.X)
                {
                    m_Animate.changAnimation((int)UndeadUnicornAnimations.RIGHT);
                    m_LastAnimation = UndeadUnicornAnimations.RIGHT;
                }
            }
            else if (m_LastAnimation == UndeadUnicornAnimations.RIGHT)
            {
                m_Animate.changAnimation((int)UndeadUnicornAnimations.IDLERIGHT);
            }
            else if (m_LastAnimation == UndeadUnicornAnimations.LEFT)
            {
                m_Animate.changAnimation((int)UndeadUnicornAnimations.IDLELEFT);
            }
        }
Exemplo n.º 6
0
        private void move(GameTime gameTime)
        {
            float elapsedTime = (float)gameTime.ElapsedGameTime.Milliseconds / 1000;

            float m_aggroRange = 300.0f;

            Vector2 m_distanceFromPlayer = new Vector2(m_Position.X - Player.collisionRectangle().Center.X, m_Position.Y - Player.collisionRectangle().Center.Y);

            if (m_distanceFromPlayer.Length() <= m_aggroRange)
            {
                m_distanceFromPlayer.Normalize();
                m_Position.Y -= m_distanceFromPlayer.Y * m_Speed * elapsedTime;
                m_Position.X -= m_distanceFromPlayer.X * m_Speed * elapsedTime;

                if (m_PixieAggroPlayed == false)
                {
                    Sounds.playSound("PixieAggro", 0.50f);
                    m_PixieAggroPlayed = true;
                }
            }
            else
            {
                m_PixieAggroPlayed = false;
            }
        }
Exemplo n.º 7
0
 public void update(GameTime gameTime)
 {
     m_PosX += m_SourceRect.Width;
     if (m_PosX >= m_SpriteWidth)
     {
         m_PosX = 0;
     }
     if (CollisionCheck.collisionCheck(Player.collisionRectangle(), m_CollisionRect))
     {
         Player.instantDeath();
     }
 }
Exemplo n.º 8
0
        private void collisionCheck()
        {
            if (CollisionCheck.collisionCheck(m_DestinationRect, Player.collisionRectangle()))
            {
                Player.takeDamage();
            }

            if (CollisionCheck.collisionCheck(m_DestinationRect, m_LevelBounds) != true)
            {
                m_IsActive = false;
            }
        }
Exemplo n.º 9
0
        public override void update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            float elapsedTime = (float)gameTime.ElapsedGameTime.Milliseconds / 1000;

            //determine if the player is in range and the spider is in an aggroeable state
            if (Math.Abs(m_Position.X - Player.collisionRectangle().Center.X) <= m_AggroRange)
            {
                if (m_AggroState == SpiderAggroState.NONE)
                {
                    m_AggroState = SpiderAggroState.AGGROED;
                }
            }

            //move spider
            if (m_AggroState == SpiderAggroState.AGGROED || m_State == SpiderState.DYING)
            {
                m_Position.Y += m_Speed * elapsedTime;
            }
            else if (m_AggroState == SpiderAggroState.RETREATING)
            {
                m_Position.Y -= m_Speed * elapsedTime;
            }


            if (CollisionCheck.collisionCheck(Destination, m_UnAggroedRectangle))
            {
                m_AggroState = SpiderAggroState.NONE;
            }

            m_Animate.updatePosition(m_Position);

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

            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)
                    {
                        m_AggroState = SpiderAggroState.RETREATING;
                    }
                }
            }

            if (CollisionCheck.collisionCheck(Destination, Player.collisionRectangle()))
            {
                Player.takeDamage();
            }


            base.update(gameTime);
        }
Exemplo n.º 10
0
 private void collisionCheck()
 {
     if (m_IsActive == true)
     {
         for (int i = 0; i < m_CollisionRects.Length; i++)
         {
             if (CollisionCheck.collisionCheck(m_CollisionRects[i], Player.collisionRectangle()))
             {
                 Player.takeDamage();
             }
         }
     }
 }
Exemplo n.º 11
0
        private void animationRow(GameTime gameTime)
        {
            float elapsedTime = (float)gameTime.ElapsedGameTime.Milliseconds / 1000;

            if (m_Position.X <= Player.collisionRectangle().Center.X&& currentHealth > 0)
            {
                m_Animate.changAnimation((int)PixieAnimations.RIGHT);
            }
            else if (m_Position.X >= Player.collisionRectangle().Center.X&& currentHealth > 0)
            {
                m_Animate.changAnimation((int)PixieAnimations.LEFT);
            }
        }
Exemplo n.º 12
0
        public void update(GameTime gameTime)
        {
            for (int i = 0; i < hearts.Count; i++)
            {
                hearts[i].update(gameTime);

                if (CollisionCheck.collisionCheck(hearts[i].Destination, Player.collisionRectangle()))
                {
                    hearts.RemoveAt(i);
                    Sounds.playSound("Pickup_Heart", 1);
                    Player.collectedHeart(true);
                }
            }
        }
Exemplo n.º 13
0
 public void update(GameTime gameTime)
 {
     for (int i = 0; i < keys.Count; i++)
     {
         keys[i].update(gameTime);
         if (CollisionCheck.collisionCheck(Player.collisionRectangle(), keys[i].Destination))
         {
             Player.m_hasKey = true;
             Player.collectedKey(true);
             Sounds.playSound("Pickup_Key", 0.10f);
             keys.RemoveAt(i);
         }
     }
 }
Exemplo n.º 14
0
        public void update(GameTime gameTime)
        {
            for (int i = 0; i < stars.Count; i++)
            {
                stars[i].update(gameTime);

                if (CollisionCheck.collisionCheck(stars[i].Destination, Player.collisionRectangle()))
                {
                    stars.RemoveAt(i);
                    Player.collectedStar(true);
                    Sounds.playSound("Pickup_Star", 0.5f);
                }
            }
        }
Exemplo n.º 15
0
        public override void  update(GameTime gameTime)
        {
            base.update(gameTime);

            if (CollisionCheck.collisionCheck(Player.collisionRectangle(), Destination))
            {
                if (Player.m_hasKey == true)
                {
                    Player.m_hasKey = false;
                    m_ScreenManager.CurrentGameState = GameState.LevelComplete;
                    Player.reset();
                    Player.setInitialPosition();
                    Level.levelIncrement();
                }
            }
        }
Exemplo n.º 16
0
        public override void update(GameTime gameTime)
        {
            float elapsedTime = (float)gameTime.ElapsedGameTime.Milliseconds / 1000;

            float aggroRange = 300.0f;

            Vector2 m_distanceFromPlayer     = new Vector2(m_Position.X - Player.collisionRectangle().Center.X, m_Position.Y - Player.collisionRectangle().Center.Y);
            Vector2 m_distanceFromResetPoint = new Vector2(m_Position.X - m_ResetPoint.X, m_Position.Y - m_ResetPoint.Y);

            if (m_distanceFromPlayer.Length() <= aggroRange)
            {
                m_distanceFromPlayer.Normalize();
                m_Position.Y -= m_distanceFromPlayer.Y * m_Speed * elapsedTime;
                m_Position.X -= m_distanceFromPlayer.X * m_Speed * elapsedTime;
                if (m_SoundPlayed == false)
                {
                    Sounds.playSound("BeeAggro", 0.25f);
                    m_SoundPlayed = true;
                }
            }
            else
            {
                if (m_distanceFromResetPoint.Length() != 0.0f)
                {
                    m_distanceFromResetPoint.Normalize();
                    m_Position.Y -= m_distanceFromResetPoint.Y * m_Speed * elapsedTime;
                    m_Position.X -= m_distanceFromResetPoint.X * m_Speed * elapsedTime;
                    m_SoundPlayed = false;
                }
            }

            if (CollisionCheck.collisionCheck(Destination, Player.collisionRectangle()))
            {
                Player.takeDamage();
            }


            base.update(gameTime);
        }
Exemplo n.º 17
0
        public override void update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            float elapsedTime = (float)gameTime.ElapsedGameTime.Milliseconds / 1000;

            if (m_State == UndeadUnicornState.ALIVE)
            {
                move(gameTime);
                animationRow(gameTime);

                if (CollisionCheck.collisionCheck(Destination, Player.collisionRectangle()))
                {
                    Player.takeDamage();
                }
            }
            else
            {
                m_Timer += elapsedTime;
                m_Animate.changAnimation((int)UndeadUnicornAnimations.DYINGRIGHT);
            }

            base.update(gameTime);
        }
Exemplo n.º 18
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);
                }
            }
        }