/// <summary>
 /// Make sure there is ground in the direction we want to move, and there is no wall in the way.
 /// If there is, go the other direction.
 /// If the other direction is also blocked, don't move at all.
 /// </summary>
 private static CharacterInput.Direction CheckMovementDirection(SideChecks checks, SideChecks oppositeChecks, CharacterInput.Direction dir, CharacterInput.Direction oppositeDir)
 {
     if (MovementCheck(checks))
     {
         return(dir);
     }
     else if (MovementCheck(oppositeChecks))
     {
         return(oppositeDir);
     }
     return(CharacterInput.Direction.None);
 }
        private void SetMove(float moveTime, CharacterInput.Direction direction)
        {
            directionTimer = 0f;
            moveTimer      = moveTime;
            this.direction = direction;
            switch (this.direction)
            {
            case CharacterInput.Direction.Right:
                currentChecks = RightSide;
                return;

            default:
                currentChecks = LeftSide;
                return;
            }
        }
        /// <summary>
        /// If there is ground ahead or below, move to it.
        /// Otherwise, if there is ground above or across, jump to it.
        /// </summary>
        public bool MovementAndJumpExecution(SideChecks checks, out CharacterInput.Direction dir, ref bool jumpRequest, float dirY = 1f)
        {
            bool groundCheck = checks.GroundCheck.Evaluate();

            if ((groundCheck || checks.FallCheck.Evaluate()) && !checks.WallCheck.Evaluate())
            {
                dir = checks.Direction;
                if (dirY > 0f && !groundCheck && checks.JumpAboveCheck.Evaluate() && !checks.FreeGroundAboveCheck.Evaluate())
                {
                    jumpRequest = true;
                }
            }
            else if ((checks.JumpAboveCheck.Evaluate() && !checks.FreeGroundAboveCheck.Evaluate()) || (checks.JumpAcrossCheck.Evaluate() && !checks.FreeGroundAcrossCheck.Evaluate()))
            {
                dir         = checks.Direction;
                jumpRequest = true;
            }
            else
            {
                dir = CharacterInput.Direction.None;
                return(false);
            }
            return(true);
        }
 /// <summary>
 /// There is no wall ahead, or there is ground above!
 /// </summary>
 public static bool StrictMovementCheck(SideChecks checks)
 {
     return(!checks.WallCheck.Evaluate() || !checks.FreeGroundAboveCheck.Evaluate());
 }
 /// <summary>
 /// There is no wall ahead, and there is ground ahead or below which can be fallen upon.
 /// </summary>
 private static bool MovementCheck(SideChecks checks)
 {
     return(StrictMovementCheck(checks) && (checks.GroundCheck.Evaluate() || checks.FallCheck.Evaluate()));
 }