public void MoveSlug() { if (move || beingDeleted) { return; } directionCount = 0; movementDirection = GetRandomSlugDirection(); if (jewelMovement == null) { jewelMovement = GetComponent <RockLevelJewelMovement> (); } row = jewelMovement.GetRow(); col = jewelMovement.GetCol(); oldRow = row; oldCol = col; directionCount = 0; do { if (movementDirection == slugDirection.up) { if (row - 1 >= 0 && instantiator.GetJewelGridGameObject(row - 1, col) != null && IsJewel(instantiator.GetJewelGridGameObject(row - 1, col)) && instantiator.GetJewelGridGameObject(row - 1, col).name != "Slug Meal" && !swapJewel.IsASwapJewel(instantiator.GetJewelGridGameObject(row - 1, col))) { instantiator.GetJewelGridGameObject(row - 1, col).tag = "Slug Meal"; tempBoulder = (GameObject)Instantiate(currentBoulder, new Vector3(transform.position.x, transform.position.y, -.5f), Quaternion.identity); tempBoulder.GetComponent <RockLevelJewelMovement> ().SetBounced(true); tempBoulder.layer = gameObject.layer; tempBoulder.GetComponent <RockLevelJewelMovement> ().SetRow(row); tempBoulder.GetComponent <RockLevelJewelMovement> ().SetCol(col); instantiator.AddToJewelGrid(tempBoulder, row, col); targetX = transform.position.x; targetY = transform.position.y + .61f; jewelMovement.SetRow(row - 1); row--; destructionJewel = instantiator.GetJewelGridGameObject(row, col); instantiator.AddToJewelGrid(gameObject, row, col); gameObject.GetComponent <Rigidbody2D> ().isKinematic = true; transform.position = (new Vector3(transform.position.x, transform.position.y, -20)); move = true; return; } movementDirection = slugDirection.right; } else if (movementDirection == slugDirection.right) { if (col + 1 < 9 && instantiator.GetJewelGridGameObject(row, col + 1) != null && IsJewel(instantiator.GetJewelGridGameObject(row, col + 1)) && instantiator.GetJewelGridGameObject(row, col + 1).name != "Slug Meal" && !swapJewel.IsASwapJewel(instantiator.GetJewelGridGameObject(row, col + 1))) { instantiator.GetJewelGridGameObject(row, col + 1).tag = "Slug Meal"; tempBoulder = (GameObject)Instantiate(currentBoulder, new Vector3(transform.position.x, transform.position.y, -.5f), Quaternion.identity); tempBoulder.GetComponent <RockLevelJewelMovement> ().SetBounced(true); tempBoulder.layer = gameObject.layer; tempBoulder.GetComponent <RockLevelJewelMovement> ().SetRow(row); tempBoulder.GetComponent <RockLevelJewelMovement> ().SetCol(col); instantiator.AddToJewelGrid(tempBoulder, row, col); targetX = transform.position.x + .6125f; targetY = transform.position.y; jewelMovement.SetCol(col + 1); col++; destructionJewel = instantiator.GetJewelGridGameObject(row, col); instantiator.AddToJewelGrid(gameObject, row, col); gameObject.GetComponent <Rigidbody2D> ().isKinematic = true; transform.position = (new Vector3(transform.position.x, transform.position.y, -20)); move = true; return; } movementDirection = slugDirection.down; } else if (movementDirection == slugDirection.down) { if (row + 1 < 9 && instantiator.GetJewelGridGameObject(row + 1, col) != null && IsJewel(instantiator.GetJewelGridGameObject(row + 1, col)) && instantiator.GetJewelGridGameObject(row + 1, col).name != "Slug Meal" && !swapJewel.IsASwapJewel(instantiator.GetJewelGridGameObject(row + 1, col))) { instantiator.GetJewelGridGameObject(row + 1, col).tag = "Slug Meal"; tempBoulder = (GameObject)Instantiate(currentBoulder, new Vector3(transform.position.x, transform.position.y, -.5f), Quaternion.identity); tempBoulder.GetComponent <RockLevelJewelMovement> ().SetBounced(true); tempBoulder.layer = gameObject.layer; tempBoulder.GetComponent <RockLevelJewelMovement> ().SetRow(row); tempBoulder.GetComponent <RockLevelJewelMovement> ().SetCol(col); instantiator.AddToJewelGrid(tempBoulder, row, col); targetX = transform.position.x; targetY = transform.position.y - .61f; jewelMovement.SetRow(row + 1); row++; destructionJewel = instantiator.GetJewelGridGameObject(row, col); instantiator.AddToJewelGrid(gameObject, row, col); gameObject.GetComponent <Rigidbody2D> ().isKinematic = true; transform.position = (new Vector3(transform.position.x, transform.position.y, -20)); move = true; return; } movementDirection = slugDirection.left; } else if (movementDirection == slugDirection.left) { if (col - 1 >= 0 && instantiator.GetJewelGridGameObject(row, col - 1) != null && IsJewel(instantiator.GetJewelGridGameObject(row, col - 1)) && instantiator.GetJewelGridGameObject(row, col - 1).name != "Slug Meal" && !swapJewel.IsASwapJewel(instantiator.GetJewelGridGameObject(row, col - 1))) { instantiator.GetJewelGridGameObject(row, col - 1).tag = "Slug Meal"; tempBoulder = (GameObject)Instantiate(currentBoulder, new Vector3(transform.position.x, transform.position.y, -.5f), Quaternion.identity); tempBoulder.GetComponent <RockLevelJewelMovement> ().SetBounced(true); tempBoulder.layer = gameObject.layer; tempBoulder.GetComponent <RockLevelJewelMovement> ().SetRow(row); tempBoulder.GetComponent <RockLevelJewelMovement> ().SetCol(col); instantiator.AddToJewelGrid(tempBoulder, row, col); targetX = transform.position.x - .6125f; targetY = transform.position.y; jewelMovement.SetCol(col - 1); col--; destructionJewel = instantiator.GetJewelGridGameObject(row, col); instantiator.AddToJewelGrid(gameObject, row, col); gameObject.GetComponent <Rigidbody2D> ().isKinematic = true; transform.position = (new Vector3(transform.position.x, transform.position.y, -20)); move = true; return; } movementDirection = slugDirection.up; } directionCount++; } while (directionCount < 4); MoveNonJewelDirection(); }