Exemplo n.º 1
0
        public bool CheckTurnAround()
        {
            // Don't turn around if he's falling
            if (IsFalling())
            {
                return Movement.CheckTurnAround(false);
            }

            if (this.PhysicsContainer.Object.CheckIfNotMovingVertically())
            {
                // Check if he's at the edge of the platform
                if (!this.PhysicsContainer.Object.CheckForGroundAhead(this.FacingRight, sightForGroundDistance))
                {
                    return Movement.CheckTurnAround(true);
                }

                // Check if he hit a wall
                if (this.FacingRight)
                {
                    if (this.PhysicsContainer.Object.OnRightWall)
                        return Movement.CheckTurnAround(true);
                }
                else
                {
                    if (this.PhysicsContainer.Object.OnLeftWall)
                        return Movement.CheckTurnAround(true);
                }
            }

            // Check if he hit an enemy?

            return Movement.CheckTurnAround(false);
        }
Exemplo n.º 2
0
        public bool CheckTurnAround()
        {
            // Check if he's going to hit a wall ahead
            if (this.PhysicsContainer.Object.CheckForWallAhead(this.FacingRight, sightForWallDistance))
            {
                return(Movement.CheckTurnAround(true));
            }

            // Check if he hit a wall
            if (this.FacingRight)
            {
                if (this.PhysicsContainer.Object.OnRightWall)
                {
                    return(Movement.CheckTurnAround(true));
                }
            }
            else
            {
                if (this.PhysicsContainer.Object.OnLeftWall)
                {
                    return(Movement.CheckTurnAround(true));
                }
            }

            return(Movement.CheckTurnAround(false));
        }