示例#1
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);
        }
示例#2
0
        public override void update(GameTime gameTime)
        {
            m_LastFacing = m_Facing;

            float elapsedTime = (float)gameTime.ElapsedGameTime.Milliseconds / 1000;

            m_Timer += elapsedTime;

            m_HealthTimer += elapsedTime;

            m_StarTimer += elapsedTime;

            m_RechargeTimer += elapsedTime;

            //Added November 27, 2013
            Vector2 oldPos = new Vector2(m_PlayerPosition.X, m_PlayerPosition.Y);

            //Added November 26, 2013
            KeyboardState keyboardState = Keyboard.GetState();
            GamePadState  gamePadState  = GamePad.GetState(PlayerIndex.One);
            MouseState    mouseState    = Mouse.GetState();
            CollisionType collisionType = new CollisionType();

            if (m_Health == 0)
            {
                instantDeath();
            }

            if (m_HealthTimer < HEALTH_DELAY_TIMER)
            {
                //TODO: RED SCREEN GET HIT
            }

            crossState(gameTime);

            rechargeLaser(gameTime);

            m_LaserManager.update(gameTime);

            getInput(keyboardState, gamePadState, mouseState, gameTime);

            levelBounds();

            runState(gameTime);

            collectedHeart();

            collectedStars();

            jumpState(gameTime);

            m_Position = m_PlayerPosition;
            //Added November 27, 2013
            base.update(gameTime);
            m_PlayerPosition = m_Position;

            m_collisionRectangle = Destination;

            //Added November 27,2013
            m_Particles.update(gameTime);

            m_Particles.SpawnPoint        = m_PlayerPosition;
            m_Particles.DominantDirection = new Vector2(oldPos.X - m_PlayerPosition.X, oldPos.Y - m_PlayerPosition.Y);
        }