Example #1
0
 public void Climb(ClimbingDirection direction)
 {
     if (canAnimate && CanClimb(direction))
     {
         canAnimate = false;
         ClimbWithAnimation(direction);
     }
 }
Example #2
0
		} // FixedUpdate

		void PlayerClimb(float inHorizontal, float inVertical)
		{
			ClimbingDirection climbingDirection = GetClimbingDirection(inHorizontal, inVertical);
			float currentClimbSpeed = (ClimbingDirection.UP == climbingDirection)? climbSpeed : -climbSpeed;
			Vector3 currentPosition = playerRigidbody.position;
			float newY = Mathf.Max(0.0f, currentPosition.y + (currentClimbSpeed * Time.deltaTime));
			Vector3 newPosition = new Vector3(currentPosition.x, newY, currentPosition.z);

			animator.SetFloat(ANIMATION_SPEED, climbSpeed, playerScript.movementInfo.speedDampTime, Time.deltaTime);
			playerRigidbody.MovePosition(newPosition);
		} // PlayerClimb
Example #3
0
        private void ClimbWithAnimation(ClimbingDirection direction)
        {
            var newRow = CaluculateNewRow(direction);

            Storyboard sb = PlayerAnimationHelper
                            .GetClimbingAnimation(UIElement, newRow, new Duration(TimeSpan.FromMilliseconds(100)));

            sb.Begin();
            sb.Completed += (_, __) =>
            {
                Row        = newRow;
                canAnimate = true;
            };
        }
Example #4
0
		} // isClimbingDirection

		public ClimbingDirection GetClimbingDirection(float inHorizontal, float inVertical)
		{
			ClimbingDirection climbingDirection = ClimbingDirection.NONE;

			if ((0.2f < inHorizontal)
		    && (0.2f < playerRigidbody.transform.forward.x))
			{
				climbingDirection = ClimbingDirection.UP;
			} // if
			else if ((-0.2f > inHorizontal)
		    && (-0.2f > playerRigidbody.transform.forward.x))
			{
				climbingDirection = ClimbingDirection.DOWN;
			} // else if
			else if ((0.2f < inVertical)
		    && (0.2f < playerRigidbody.transform.forward.z))
			{
				climbingDirection = ClimbingDirection.UP;
			} // else if
			else if ((-0.2f > inVertical)
		    && (-0.2f > playerRigidbody.transform.forward.z))
			{
				climbingDirection = ClimbingDirection.DOWN;
			} // else if
			else if ((0 != inVertical)
		    || (0 != inHorizontal))
			{
				climbingDirection = ClimbingDirection.DROP;
			} // else if

			if ((ClimbingDirection.DOWN == climbingDirection)
		    && (0 >= playerRigidbody.position.y))
			{
				climbingDirection = ClimbingDirection.NONE;
			} // if
			if ((ClimbingDirection.DROP == climbingDirection)
		    && (0 >= playerRigidbody.position.y))
			{
				climbingDirection = ClimbingDirection.NONE;
			} // if

            General.Logger.LogDetail("Climb", "GetClimbingDirection", "inHorizontal: " + inHorizontal + ", inVertical: " + inVertical + ", playerRigidbody.transform.forward.x: " + playerRigidbody.transform.forward.x + ", playerRigidbody.transform.forward.z: " + playerRigidbody.transform.forward.z + ".");
            General.Logger.LogDetail("Climb", "GetClimbingDirection", "climbingDirection: " + climbingDirection.ToString() + ".");
			return climbingDirection;
		} // GetClimbingDirection
Example #5
0
 private int CaluculateNewRow(ClimbingDirection direction)
 => Row + (direction == ClimbingDirection.Up ? -1 : 1);
Example #6
0
        private bool CanClimb(ClimbingDirection direction)
        {
            var newRow = CaluculateNewRow(direction);

            return(newRow > -1 && newRow < GameConstants.NUMBEROFROWS);
        }
Example #7
0
		public bool isClimbingDirection(float inHorizontal, float inVertical)
		{
			ClimbingDirection climbingDirection = GetClimbingDirection(inHorizontal, inVertical);

			return ((ClimbingDirection.UP == climbingDirection) || (ClimbingDirection.DOWN == climbingDirection));
		} // isClimbingDirection