示例#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);
        }