Example #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);
        }
Example #2
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 #3
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);
        }