private void ExecuteAscendMove() { Enemy enemy = null; Vector3 target; if (IsOnLadder(Vector2.up, RaycastPoint.position, 1f)) { enemy = GetSquareEnemy(Vector2.up, RaycastPoint.position, 1f); if (enemy != null) { AttackEnemy(Vector2.up, enemy); } else { transform.DOMoveY(transform.position.y + 1f, MoveDelay).OnComplete(() => StartCoroutine(EnableMovement())); } AudioSource.PlayOneShot(AscendLadderAudioClip); return; } DoorExit door = GetSquareDoor(); if (door != null) { door.LoadScene(); return; } enemy = GetSquareEnemy(LastMoveDirection, RaycastPoint.position, 1f); if (enemy != null) { // We are adjacent to an enemy, so treat the jump as a regular move action. ExecuteRegularMove(new Vector2(LastMoveDirection.x, 0f)); return; } enemy = GetSquareEnemy(LastMoveDirection, RaycastPoint.position, 2f); if (enemy != null) { // An enemy is at our target jump location, so we will attack the enemy and land one space ahead. AttackEnemy(LastMoveDirection, enemy); target = new Vector3(transform.position.x + LastMoveDirection.x, transform.position.y, 0f); PerformMove(target, 1f); return; } bool isFarSquareOpen = IsSquareOpen(LastMoveDirection, RaycastPoint.position, 2f); bool isNearSquareOpen = IsSquareOpen(LastMoveDirection, RaycastPoint.position, 1f); Vector2 raycastTarget; float moveTargetPositionX; if (isFarSquareOpen) { raycastTarget = new Vector2(RaycastPoint.position.x + (LastMoveDirection.x * 2), RaycastPoint.position.y); moveTargetPositionX = transform.position.x + (LastMoveDirection.x * 2); } else { raycastTarget = new Vector2(RaycastPoint.position.x + LastMoveDirection.x, RaycastPoint.position.y); moveTargetPositionX = transform.position.x + LastMoveDirection.x; } // The jump target is open, so do a two space move. target = new Vector3(moveTargetPositionX, transform.position.y, 0f); PerformMove(target, 1f); }