Example #1
0
 private void collisionCheck()
 {
     if (CollisionCheck.collisionCheck(m_Animate.DestinationRectangle, Player.collisionRectangle()))
     {
         Player.takeDamage();
     }
 }
Example #2
0
        public void update(GameTime gameTime)
        {
            if (m_IsActive == true)
            {
                float elapsedTime = (float)gameTime.ElapsedGameTime.Milliseconds / 1000;

                m_Position.X -= m_Speed * elapsedTime;

                Rectangle temp = m_Animate.DestinationRectangle;

                if (temp.Width < MAX_WIDTH)
                {
                    temp.Width += (int)(MAX_WIDTH * INCREMENT_AMOUNT);
                }

                if (temp.Height < MAX_HEIGHT)
                {
                    temp.Height += (int)(MAX_HEIGHT * INCREMENT_AMOUNT);
                }

                m_Animate.DestinationRectangle = temp;

                m_Position.Y = m_StartIngPos.Y - m_Animate.DestinationRectangle.Height / 2;

                m_Animate.updatePosition(m_Position);

                if (CollisionCheck.collisionCheck(m_Animate.DestinationRectangle, m_LevelBounds) == false)
                {
                    m_IsActive = false;
                    reset();
                }

                collisionCheck();
            }
        }
Example #3
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);
        }
Example #4
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();
                }
            }
        }
Example #5
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);
        }
Example #6
0
        public static CollisionType[,] backgroundCollisionCheck(Rectangle objectDestinationRectangle)
        {
            CollisionType[,] temp = new CollisionType[10, 10];

            Vector2 tempy = new Vector2(objectDestinationRectangle.X + objectDestinationRectangle.Width / 2, objectDestinationRectangle.Y + objectDestinationRectangle.Height / 2);

            int posX = (int)(tempy.X / 32);

            if (posX < 5)
            {
                posX = 5;
            }

            int posY = (int)(tempy.Y / 32);

            if (posY < 5)
            {
                posY = 5;
            }

            for (int i = 0; i < temp.GetLength(0); i++)
            {
                for (int j = 0; j < temp.GetLength(1); j++)
                {
                    temp[i, j] = new CollisionType();
                }
            }

            int x = 0;
            int y = 0;

            Rectangle tempRect = Rectangle.Empty;

            for (int i = posY - 5; i < m_TileData.GetLength(0) && i < posY + 5; i++)
            {
                for (int j = posX - 5; j < m_TileData.GetLength(1) && j < posX + 5; j++)
                {
                    if (Level.isTileCollideable(i, j) == true)
                    {
                        tempRect.Width  = m_DestinationRectangle.Width;
                        tempRect.Height = m_DestinationRectangle.Height;

                        tempRect.X = j * m_DestinationRectangle.Width;
                        tempRect.Y = i * m_DestinationRectangle.Height;

                        if (j < (m_TileData.GetLength(1) - 1))
                        {
                            j++;
                            magicRectangleExtentionFunctionWithExtraRecursionForTheHellOfItButNotReallySinceWithoutThisRecursionThenTheCollisionWouldStillBeBrokenAndABrokenCollisionIsntAnyFunForAnyoneUnlessYoureAGhostSinceGhostsDontNeedCollisionButIfAGhostCouldCollideWithThingsThenSaidGhostWouldAlsoApreciateThisFunctionAndAllOfItsGlory(ref tempRect, i, ref j);
                        }

                        CollisionCheck.collisionCheck(objectDestinationRectangle, tempRect, ref temp[y, x]);
                    }
                    x++;
                }
                x = 0;
                y++;
            }
            return(temp);
        }
Example #7
0
        public CollisionType keyCollision(Rectangle playerRect)
        {
            CollisionType collision = new CollisionType();

            if (CollisionCheck.collisionCheck(playerRect, Destination, ref collision))
            {
                //TODO::add type of object that player collided with
            }
            return(collision);
        }
 public bool collisionCheck(Rectangle playerRect)
 {
     for (int i = 0; i < m_undeadUnicornList.Count; i++)
     {
         if (CollisionCheck.collisionCheck(m_undeadUnicornList[i].Destination, playerRect))
         {
             return true;
         }
     }
     return false;
 }
Example #9
0
 public bool collisionCheck(Rectangle playerRect)
 {
     for (int i = 0; i < m_spiderList.Count; i++)
     {
         if (CollisionCheck.collisionCheck(m_spiderList[i].Destination, playerRect))
         {
             return(true);
         }
     }
     return(false);
 }
Example #10
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();
     }
 }
Example #11
0
        private void collisionCheck()
        {
            if (CollisionCheck.collisionCheck(m_DestinationRect, Player.collisionRectangle()))
            {
                Player.takeDamage();
            }

            if (CollisionCheck.collisionCheck(m_DestinationRect, m_LevelBounds) != true)
            {
                m_IsActive = false;
            }
        }
Example #12
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);
        }
Example #13
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();
             }
         }
     }
 }
Example #14
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);
         }
     }
 }
Example #15
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);
                }
            }
        }
Example #16
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);
                }
            }
        }
Example #17
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();
                }
            }
        }
Example #18
0
 public bool collisionCheck(Rectangle target)
 {
     if (m_IsActive == true)
     {
         if (CollisionCheck.collisionCheck(m_CollitionRect, target) == true)
         {
             m_IsActive       = false;
             m_Particles.Stop = true;
             return(true);
         }
         else
         {
             return(false);
         }
     }
     return(false);
 }
Example #19
0
        public void update(GameTime gameTime)
        {
            float elapsedTime = (float)gameTime.ElapsedGameTime.Milliseconds / 1000;

            if (IsActive == true)
            {
                Vector2 temp = m_Position;

                m_Direction.Normalize();

                temp.X += m_Direction.X * m_Speed * elapsedTime;
                temp.Y += m_Direction.Y * m_Speed * elapsedTime;

                Position = temp;


                if (CollisionCheck.collisionCheck(m_CollitionRect, m_LevelBoundries) != true)
                {
                    m_IsActive       = false;
                    m_Particles.Stop = true;
                }

                CollisionType[,] tempy = Level.backgroundCollisionCheck(m_CollitionRect);

                for (int i = 0; i < tempy.GetLength(0); i++)
                {
                    for (int j = 0; j < tempy.GetLength(1); j++)
                    {
                        if (tempy[i, j].m_WasThereACollision == true)
                        {
                            m_IsActive       = false;
                            m_Particles.Stop = true;
                        }
                    }
                }
            }
            m_Particles.update(gameTime);
            m_Particles.update(gameTime);
            m_Particles.update(gameTime);
        }
Example #20
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);
        }
Example #21
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);
        }
Example #22
0
        public void update(GameTime gameTime)
        {
            float elapsedTime = (float)gameTime.ElapsedGameTime.Milliseconds / 1000;

            Vector2[] oldPos = m_Positions;

            for (int i = 0; i < m_Positions.Length; i++)
            {
                m_PosXInFunction += m_Speed * elapsedTime * (int)m_Direction;

                m_Positions[i].X = m_PosXInFunction;

                m_Positions[i].Y = m_Sin[i].getYAtPosX(m_Positions[i].X);

                m_CollisionRects[i].X = (int)m_Positions[i].X - m_CollisionRects[i].Width;
                m_CollisionRects[i].Y = (int)m_Positions[i].Y - m_CollisionRects[i].Height;
            }

            for (int i = 0; i < m_Particles.Length; i++)
            {
                m_Particles[i].SpawnPoint = m_Positions[i % 2];

                m_Particles[i].DominantDirection = (oldPos[i % 2] - m_Positions[i % 2]);

                //did this to make the beam spawn more particles
                m_Particles[i].update(gameTime);
                m_Particles[i].update(gameTime);
                m_Particles[i].update(gameTime);

                if (CollisionCheck.collisionCheck(m_CollisionRects[i % 2], m_Boundries) == false)
                {
                    m_IsActive          = false;
                    m_Particles[i].Stop = true;
                }
            }
            collisionCheck();
        }