示例#1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (startSwap)
        {
            if (jewel1 == null || jewel2 == null)
            {
                return;
            }
            jewel1.transform.Translate(new Vector3(-(jewel1.transform.position.x - jewelTwoOriginalPos.x) * translationMultiplier, -(jewel1.transform.position.y - jewelTwoOriginalPos.y) * translationMultiplier, 0));
            jewel2.transform.Translate(new Vector3(-(jewel2.transform.position.x - jewelOneOriginalPos.x) * translationMultiplier, -(jewel2.transform.position.y - jewelOneOriginalPos.y) * translationMultiplier, 0));
            if (Mathf.Abs(jewel1.transform.position.x - jewelTwoOriginalPos.x) < distanceToTarget && Mathf.Abs(jewel1.transform.position.y - jewelTwoOriginalPos.y) < distanceToTarget &&
                Mathf.Abs(jewel2.transform.position.x - jewelOneOriginalPos.x) < distanceToTarget && Mathf.Abs(jewel2.transform.position.y - jewelOneOriginalPos.y) < distanceToTarget)
            {
                jewel1.transform.position = jewelTwoOriginalPos;
                jewel2.transform.position = jewelOneOriginalPos;
                jewel1.layer = secondJewelLayer;
                jewel2.layer = firstJewelLayer;
                startSwap    = false;
                //				firstJewelBlockMovement.moving = false;
                //				secondJewelBlockMovement.moving = false;
                pauseTouchForSwap = false;
            }
            if (!startSwap)
            {
                jewel1.GetComponent <Rigidbody2D>().isKinematic = false;
                jewel2.GetComponent <Rigidbody2D>().isKinematic = false;
                instantiator.SetJewelGridGameObject(jewelOneMovement.GetRow(), jewelOneMovement.GetCol(), jewel1);
                instantiator.SetJewelGridGameObject(jewelTwoMovement.GetRow(), jewelTwoMovement.GetCol(), jewel2);
                jewelOneMovement = jewel1.GetComponent <RockLevelJewelMovement> ();
                jewelTwoMovement = jewel2.GetComponent <RockLevelJewelMovement> ();
                jewelOneMovement.SetMoving(false);
                jewelTwoMovement.SetMoving(false);
                if (jewelOneMovement.GetRow() < jewelTwoMovement.GetRow())
                {
                    if (!checkForMatches.CheckForSwapBack(jewel1, jewelOneMovement.GetRow(), jewelOneMovement.GetCol()) && !checkForMatches.CheckForSwapBack(jewel2, jewelTwoMovement.GetRow(), jewelTwoMovement.GetCol()))
                    {
                        if (!swapJewelsBack && restrictMovements)
                        {
                            Swap(jewel1, jewel2, true);
                        }
                        else
                        {
                            if (jewel1 != null)
                            {
                                PowerStarTracker.RemoveFromHashSet(jewel1);
                                jewel1 = null;
                                jewelOneMovement.SetSwappingJewel(false);
                            }
                            if (jewel2 != null)
                            {
                                PowerStarTracker.RemoveFromHashSet(jewel2);
                                jewel2 = null;
                                jewelTwoMovement.SetSwappingJewel(false);
                            }
                        }
                        return;
                    }
                    deleteJewels.SetSwapComplete(true);
                    if (!timeBombLevel && !jewelCollectorLevel)
                    {
                        bombHandler.DecreaseAllBombsInList();
                    }
                    else if (jewelCollectorLevel)
                    {
                        Debug.Log("Calling moveNumberHandler.SubtractOneFromMoveNumber ()");
                        moveNumberHandler.SubtractOneFromMoveNumber();
                    }
                    if (!firstSwapPerformed)
                    {
                        GameObject.Find("Game Manager").GetComponent <GameManagerScript> ().SetFirstMoveMade(true);
                        firstSwapPerformed = true;
                        //Debug.Log ("First Swap Performed");
                    }
                    if (jewel1 != null)
                    {
                        PowerStarTracker.RemoveFromHashSet(jewel1);
                        jewel1 = null;
                        jewelOneMovement.SetSwappingJewel(false);
                    }
                    if (jewel2 != null)
                    {
                        PowerStarTracker.RemoveFromHashSet(jewel2);
                        jewel2 = null;
                        jewelTwoMovement.SetSwappingJewel(false);
                    }
//					stoppedMoving.SetGridStaticToFalse ();
                }
                else
                {
                    if (!checkForMatches.CheckForSwapBack(jewel2, jewelTwoMovement.GetRow(), jewelTwoMovement.GetCol()) && !checkForMatches.CheckForSwapBack(jewel1, jewelOneMovement.GetRow(), jewelOneMovement.GetCol()))
                    {
                        if (!swapJewelsBack && restrictMovements)
                        {
                            Swap(jewel1, jewel2, true);
                        }
                        else
                        {
                            if (jewel1 != null)
                            {
                                PowerStarTracker.RemoveFromHashSet(jewel1);
                                jewel1 = null;
                                jewelOneMovement.SetSwappingJewel(false);
                            }
                            if (jewel2 != null)
                            {
                                PowerStarTracker.RemoveFromHashSet(jewel2);
                                jewel2 = null;
                                jewelTwoMovement.SetSwappingJewel(false);
                            }
                        }
                        checkForMatches.deleteList.Clear();
                        return;
                    }
                    deleteJewels.SetSwapComplete(true);
                    if (!timeBombLevel && !jewelCollectorLevel)
                    {
                        bombHandler.DecreaseAllBombsInList();
                    }
                    else if (jewelCollectorLevel)
                    {
                        moveNumberHandler.SubtractOneFromMoveNumber();
                    }
                    if (!firstSwapPerformed)
                    {
                        GameObject.Find("Game Manager").GetComponent <GameManagerScript> ().SetFirstMoveMade(true);
                        firstSwapPerformed = true;
                        //Debug.Log ("First Swap Performed");
                    }
                    if (jewel1 != null)
                    {
                        PowerStarTracker.RemoveFromHashSet(jewel1);
                        jewel1 = null;
                        jewelOneMovement.SetSwappingJewel(false);
                    }
                    if (jewel2 != null)
                    {
                        PowerStarTracker.RemoveFromHashSet(jewel2);
                        jewel2 = null;
                        jewelTwoMovement.SetSwappingJewel(false);
                    }
//					stoppedMoving.SetGridStaticToFalse ();
                }
            }
        }
    }
    public void DeleteAllJewelsInList(HashSet <GameObject> deleteList, bool powerUpDelete)
    {
        removeList = new HashSet <GameObject> ();
        if (deleteList.Count >= 3)
        {
            soundHandler.PlayJewelBreak();
        }
        assistanceTimeStamp = Time.time;
        timeStamp           = Time.time;
        okayToMoveTimeStamp = Time.time;
        okayToMoveAgain     = false;
        matchAssistant.SetResetRandoms(true);
        movementChecker.SetGridStaticToFalse();
        GameObject tempJewel;

        if (deleteList.Count == 4)
        {
            soundHandler.PlayPowerUpSound();
            fourInARowScript.ActivateFourInARowPower(deleteList);
//			scoreKeeper.IncreaseScoreByFourJewelBonus ();
        }
        foreach (GameObject a in deleteList)
        {
            if (a != null)
            {
                if (!powerUpDelete && a.tag != "Boulder")
                {
                    jewelMovement = a.GetComponent <RockLevelJewelMovement> ();
                    if (jewelMovement.GetRow() + 1 < 9)
                    {
                        CheckForBoulders(jewelMovement.GetRow() + 1, jewelMovement.GetCol());
                    }
                    if (jewelMovement.GetRow() - 1 >= 0)
                    {
                        CheckForBoulders(jewelMovement.GetRow() - 1, jewelMovement.GetCol());
                    }
                    if (jewelMovement.GetCol() + 1 < 9)
                    {
                        CheckForBoulders(jewelMovement.GetRow(), jewelMovement.GetCol() + 1);
                    }
                    if (jewelMovement.GetCol() - 1 >= 0)
                    {
                        CheckForBoulders(jewelMovement.GetRow(), jewelMovement.GetCol() - 1);
                    }
                }
                if (a.tag == "Boulder")
                {
                    jewelMovement = a.GetComponent <RockLevelJewelMovement> ();
                    if (CheckForBoulders(jewelMovement.GetRow(), jewelMovement.GetCol()))
                    {
                        removeList.Add(a);
                    }
                }
            }
        }


        foreach (GameObject a in removeList)
        {
            deleteList.Remove(a);
        }

        foreach (GameObject a in boulderDeleteList)
        {
            deleteList.Add(a);
        }

        foreach (GameObject a in deleteList)
        {
            if (a != null)
            {
                deleteListCopy = deleteList;
                if (a != null && a.tag == "Steel Block")
                {
                    PowerStarTracker.RemoveFromHashSet(a);
                }
                if (a != null && a.tag != "Steel Block" && a.name != "Rock 3 Chain(Clone)" && a.name != "Rock 2 Chain(Clone)" && a.name != "Rock 1 Chain(Clone)")
                {
                    jewelMovement = a.GetComponent <RockLevelJewelMovement> ();
                    //				moveJewelsDown.MoveJewelsAboveDown(a);
//					if (GameObject.Find ("Time Bomb ID") != null) {
//						if (addJewels == null)
//							addJewels = GameObject.Find ("Time Bomb ID").GetComponent<AddTimeLevelOneJewels> ();
//						if (Bomb(a) && !bombHandler.TimeBombIsExploded ()) {
//							bombHandler.RemoveFromBombList (a);
//							addJewels.InstantiateSingleJewels (jewelMovement.GetCol (), true);
//						} else if (!bombHandler.TimeBombIsExploded ())
//							addJewels.InstantiateSingleJewels (jewelMovement.GetCol (), false);
//						else if (bombHandler.TimeBombIsExploded ()) {
//							addJewels.InstantiateOnlyJewels (jewelMovement.GetCol ());
//						}
//					}
                    //				else
                    //					instantiator.InstantiateSingleJewels (jewelMovement.GetRow (), jewelMovement.GetCol ());


                    if (Bomb(a) && GameObject.Find("Time Bomb ID") == null)
                    {
                        GameObject tempNumber = null;
                        for (int i = 0; i < a.transform.childCount; i++)
                        {
                            if (a.transform.GetChild(i).tag == "Bomb Number")
                            {
                                tempNumber = a.transform.GetChild(i).gameObject;
                                break;
                            }
                        }
                        if (tempNumber != null)
                        {
                            tempNumber.transform.parent = null;
                            tempNumber.GetComponent <BombNumberHandler> ().SetBombDestroyed(true);
                        }
                        if (bombHandler.GetBombListCount() == 1)
                        {
                            //Debug.Log ("Setting touch to fault");
                            touchHandler.SetGameStarted(false);
                        }
//						bombInfo = a.GetComponent<LevelTwoBombInfo> ();
//						Instantiate (bombInfo.GetBombNumberSprite (), a.transform.position, Quaternion.identity);
                    }
                    else if (Bomb(a) && GameObject.Find("Time Bomb ID") != null)
                    {
                        GameObject tempBomb;
//						bombInfo = a.GetComponent<LevelTwoBombInfo> ();
                        a.GetComponent <Rigidbody2D>().isKinematic = true;
//						bombInfo.SetBombDestroyed (true);
                    }
                }
            }
        }

        boulderDeleteList.Clear();

        foreach (GameObject a in deleteList)
        {
            if (a != null)
            {
                if (explosionsOn)
                {
                    InstantiateExplosions(a);
                }
                if (a.tag != "Steel Block")
                {
                    scoreKeeper.IncreaseScoreByOneJewel();
                    if (bombHandler.BombListContains(a))
                    {
                        jewelMovement = a.GetComponent <RockLevelJewelMovement> ();
                        bombHandler.RemoveFromBombList(a);
                        bombHandler.DecreaseBombCounterByOne();
//						scoreKeeper.IncreaseScoreByOneBomb ();
                    }
                    if (/*(GameObject.Find ("Time Bomb ID") == null || (GameObject.Find ("Time Bomb ID") != null && !Bomb (a))) &&*/ a.name != "Rock 3 Chain(Clone)" && a.name != "Rock 2 Chain(Clone)" && a.name != "Rock 1 Chain(Clone)")
                    {
                        if (GameObject.Find("Time Bomb ID") != null && Bomb(a))
                        {
                            bombDestroyed = true;
                        }
                        tempPositionHolder = new PositionHolder(a.GetComponent <RockLevelJewelMovement> ().GetRow(), a.GetComponent <RockLevelJewelMovement> ().GetCol());
                        deletedPositions.Add(tempPositionHolder);
                        int row = a.GetComponent <RockLevelJewelMovement> ().GetRow();
                        int col = a.GetComponent <RockLevelJewelMovement> ().GetCol();
                        a.GetComponent <RockLevelJewelMovement> ().StartDestroyCountdown();
                        PowerStarTracker.RemoveFromHashSet(a);
                        if (a.name == "Slug(Clone)")
                        {
                            SlugListManager.RemoveFromSlugList(a);
                        }
                        if (GameObject.Find("Jewel Collection Level ID") != null && !endOfLevelJewelSprayer.GetSprayingInProgress())
                        {
                            InstantiateStaticJewel(a);
                        }
                        Destroy(a);
                        instantiator.SetJewelGridGameObject(row, col, null);
//						moveJewelsDown.MoveJewelsAboveDown (tempPositionHolder.GetCol (), tempPositionHolder.GetRow ());
//						instantiator.InstantiateSingleJewels (tempPositionHolder.GetRow (), tempPositionHolder.GetCol ());
                    }
                }
            }
        }

//		deleteCount++;
//
//		if (deleteCount == 3) {
//			deleteCount = 0;
//			GameObject.Find ("Pump Up Word Holder").GetComponent<PumpUpWordHolder> ().InstantiateWow ();
//		}
        powerTrackerTimestamp = Time.time;
        swapMadeTimestamp     = Time.time;
//		if (swapComplete) {
//			swapComplete = false;
//			SlugListManager.MoveAllSlugs ();
//		}
        deleteList.Clear();

        foreach (PositionHolder a in deletedPositions)
        {
//			//Debug.Log ("deletePositions.Size = " + deletedPositions.Count);
            int row = a.GetRow();
            int col = a.GetCol();
            moveJewelsDown.MoveJewelsAboveDown(col, row);
//			instantiator.InstantiateSingleJewels (row, col);
////			while (row >= 0 && instantiator.GetJewelGridGameObject (row, col) == null)
////				row--;
////			if (instantiator.GetJewelGridGameObject (row, col) != null)
////				instantiator.GetJewelGridGameObject (row, col).GetComponent<RockLevelJewelMovement> ().MoveDown (false);
        }

        List <PositionHolder> nullPositions = null;

        if (!starShooter.GetStartLaunchingStars())
        {
            nullPositions = new List <PositionHolder> ();
            int  positionTotal = deletedPositions.Count, nullCount = 0;
            bool breakSecondLoop = false;

            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    if (instantiator.GetJewelGridGameObject(i, j) == null)
                    {
                        nullCount++;
                        nullPositions.Add(new PositionHolder(i, j));
                        if (nullCount >= positionTotal)
                        {
                            breakSecondLoop = true;
                        }
                    }
                }
                if (breakSecondLoop)
                {
                    break;
                }
            }
        }

        foreach (PositionHolder a in deletedPositions)
        {
            if (tutorialLevel1)
            {
                instantiator.InstantiateLevelOneTutorialJewels(a.GetRow(), a.GetCol());
            }
            else if (tutorialLevel2)
            {
                instantiator.InstantiateLevelTwoTutorialJewels(a.GetRow(), a.GetCol());
            }
            else if (tutorialLevel3)
            {
                instantiator.InstantiateLevelThreeTutorialJewels(a.GetRow(), a.GetCol());
            }
            else if (tutorialLevel4)
            {
                instantiator.InstantiateLevelFourTutorialJewels(a.GetRow(), a.GetCol());
            }
            else
            {
                instantiator.InstantiateSingleJewels(a.GetRow(), a.GetCol());
            }
        }

        if (!starShooter.GetStartLaunchingStars())
        {
            int whileCount = 0;
            if (!tutorialLevel1 && !tutorialLevel2 && !tutorialLevel3 && noMatchChecker.CheckForNoMatchesWithoutShuffle() && noMatchCount < 3)
            {
                Debug.Log("MAKING A NEW MATCH");
                noMatchCount++;
                do
                {
                    foreach (PositionHolder a in nullPositions)
                    {
                        Destroy(instantiator.GetJewelGridGameObject(a.GetRow(), a.GetCol()));
                        instantiator.SetJewelGridGameObject(a.GetRow(), a.GetCol(), null);
                        instantiator.InstantiateSingleJewels(a.GetRow(), a.GetCol());
                    }
                    if (whileCount > 100)
                    {
                        Debug.Log("WHILECOUNT BREAK");
                        break;
                    }
                    whileCount++;
                } while (noMatchChecker.CheckForNoMatchesWithoutShuffle());
            }
            else
            {
                noMatchCount = 0;
            }
        }

        deletedPositions.Clear();

//		foreach (PositionHolder a in boulderHolder) {
//			if (instantiator.GetJewelGridGameObject (a.GetRow (), a.GetCol ()) != null) {
//				checkForMatches.CheckForSwapBack (instantiator.GetJewelGridGameObject (a.GetRow (), a.GetCol ()), a.GetRow (), a.GetCol ());
//			}
//		}
//		boulderHolder.Clear ();
        //		if (shadeCount == 0 || shadeCount == 1) {
        //			shadeController = controller.GetCurrentTutorialShade ().GetComponent<LevelTwoTutorialShadeController> ();
        //			shadeController.MakeInvisible ();
        //			shadeCount++;
        //		}
//		if (swapComplete) {
//			swapComplete = false;
//			SlugListManager.MoveAllSlugs ();
//		}
    }
    public void MoveJewelsAboveDown(int col, int row)
    {
//		int movableObjectPlaceHolder = 0, immovableObjectCount = 0;
//		bool jewelFound = false, bombFound = false;
//		GameObject tempObject = null;
//
//		for (int i = 0; i < 9; i++) {
//			if ((instantiator.GetJewelGridGameObject(i, col) != null && IsJewel (instantiator.GetJewelGridGameObject (i, col).tag)) && tempObject == null) {
//				tempObject = instantiator.GetJewelGridGameObject (i, col);
//				continue;
//			}
//			else if ((instantiator.GetJewelGridGameObject (i, col) == null || (instantiator.GetJewelGridGameObject (i, col) != null && IsJewel (instantiator.GetJewelGridGameObject (i, col).tag))) && tempObject != null) {
//				jewelMovement = tempObject.GetComponent<RockLevelJewelMovement> ();
//				tempObject.layer = 17 + i;
//				tempObject.transform.Translate (new Vector3 (0, 0, -(i - jewelMovement.GetRow ())));
//				instantiator.SetJewelGridGameObject (i, col, tempObject);
//				instantiator.SetJewelGridGameObject (jewelMovement.GetRow (), col, null);
//				jewelMovement.SetRow (i);
//				tempObject = null;
//			}
//		}
        int  nullObjectCount = 0;
        int  movedPassedImmovableObjects = 0;
        int  immovableObjectCount = 0;
        bool lastBlockWasBoulder = false;
        int  i = row, returnRow = 0;

        for (; i >= 0; i--)
        {
            if (instantiator.GetJewelGridGameObject(i, col) != null && (instantiator.GetJewelGridGameObject(i, col).tag == "Boulder" || instantiator.GetJewelGridGameObject(i, col).tag == "Steel Block" /*||
                                                                                                                                                                                                          * (PowerStarTracker.ContainsJewel (instantiator.GetJewelGridGameObject (i, col)) && swapJewel.IsASwapJewel (instantiator.GetJewelGridGameObject (i, col))) /*|| swapJewel.IsASwapJewel (instantiator.GetJewelGridGameObject (i, col))
                                                                                                                                                                                                          || instantiator.GetJewelGridGameObject (i, col).GetComponent<RockLevelJewelMovement> ().GetToBeDestroyed () ||
                                                                                                                                                                                                          ||checkForMatches.deleteList.Contains (instantiator.GetJewelGridGameObject (i, col)*/))
            {
                lastBlockWasBoulder = true;
                immovableObjectCount++;
            }
            if (lastBlockWasBoulder && instantiator.GetJewelGridGameObject(i, col) != null && IsBomb(instantiator.GetJewelGridGameObject(i, col)))
            {
                immovableObjectCount++;
            }
            if (instantiator.GetJewelGridGameObject(i, col) == null)
            {
                nullObjectCount++;
            }
            if (nullObjectCount > 0 && instantiator.GetJewelGridGameObject(i, col) != null && instantiator.GetJewelGridGameObject(i, col).tag != "Boulder" && instantiator.GetJewelGridGameObject(i, col).tag != "Steel Block")
            {
                if ((PowerStarTracker.ContainsJewel(instantiator.GetJewelGridGameObject(i, col)) && swapJewel.IsASwapJewel(instantiator.GetJewelGridGameObject(i, col))))
                {
                    break;
                }
                if (IsBomb(instantiator.GetJewelGridGameObject(i, col)) && lastBlockWasBoulder)
                {
                    lastBlockWasBoulder = true;
                    continue;
                }
//				else if (immovableObjectCount > 0 && movedPassedImmovableObjects < nullObjectCount) {
                instantiator.GetJewelGridGameObject(i, col).layer = instantiator.GetJewelGridGameObject(i, col).layer + nullObjectCount + immovableObjectCount;
                jewelMovement = instantiator.GetJewelGridGameObject(i, col).GetComponent <RockLevelJewelMovement> ();
                jewelMovement.SetMoving(true);
                instantiator.GetJewelGridGameObject(i, col).transform.Translate(new Vector3(0, 0, -(nullObjectCount + immovableObjectCount)));
                instantiator.SetJewelGridGameObject(i + nullObjectCount + immovableObjectCount, col, instantiator.GetJewelGridGameObject(i, col));
                instantiator.SetJewelGridGameObject(i, col, null);
                jewelMovement.SetRow(i + nullObjectCount + immovableObjectCount);
                movedPassedImmovableObjects++;
                //				if (immovableObjectCount > 0 && movedPassedImmovableObjects >= nullObjectCount) {
                immovableObjectCount        = 0;
                movedPassedImmovableObjects = 0;
                nullObjectCount             = 0;
                i = i + 1;
                //				}
                lastBlockWasBoulder = false;
//					if (movedPassedImmovableObjects >= nullObjectCount) {
//						immovableObjectCount = 0;
//						movedPassedImmovableObjects = 0;
//					}
//				} else {
//						immovableObjectCount = 0;
////						movedPassedImmovableObjects = 0;
//					instantiator.GetJewelGridGameObject (i, col).layer = instantiator.GetJewelGridGameObject (i, col).layer + nullObjectCount;
//					jewelMovement = instantiator.GetJewelGridGameObject (i, col).GetComponent<RockLevelJewelMovement> ();
//					instantiator.GetJewelGridGameObject (i, col).transform.Translate (new Vector3 (0, 0, - (nullObjectCount)));
//					instantiator.SetJewelGridGameObject (i + nullObjectCount, col, instantiator.GetJewelGridGameObject (i, col));
//					instantiator.SetJewelGridGameObject (i, col, null);
//					jewelMovement.SetRow (i + nullObjectCount);
//					lastBlockWasBoulder = false;
//				}
                //				lastBlockWasBoulder = false;
            }
        }
//		for (int j = 0; j < nullObjectCount; j++) {
//			instantiator.InstantiateSingleJewels (j, col);
//		}
//		jewelMovement = jewel.GetComponent<RockLevelJewelMovement> ();
//		if (jewel.name == ("Rock Blocked(Clone)")) {
//			jewelMovement.AddToRocksToBeDestroyed (jewel);
//		}
//		int i = jewelMovement.GetRow () - 1;
//		int j = jewelMovement.GetCol ();
//		immovableObjectCount = 0;
//		while (i >= 0) {
//			if (!NeverMoveDownObject (instantiator.GetJewelGridGameObject (i, j))) {
//				if (IsBomb (instantiator.GetJewelGridGameObject (i, j)) && (instantiator.GetJewelGridGameObject (i + 1, j) != null && NeverMoveDownObject (instantiator.GetJewelGridGameObject (i + 1, j)) && SometimesMoveDownObject (instantiator.GetJewelGridGameObject (i + 1, j))))
//				{}
////				if (SometimesMoveDownObject (instantiator.GetJewelGridGameObject (i, j))
////				    || ((IsBomb (instantiator.GetJewelGridGameObject (i, j)) &&
////				     (NeverMoveDownObject (instantiator.GetJewelGridGameObject (i + 1, j)) ||
////				 SometimesMoveDownObject (instantiator.GetJewelGridGameObject (i + 1, j))))))
////				{}
//				else {
//					int k = i + 1;
//					instantiator.GetJewelGridGameObject (i, j).GetComponent<RockLevelJewelMovement> ().MoveDown (true);
//
////					immovableObjectCount = 0;
////					while (k < 9 && !deleteJewels.IsContainedInDeleteList (instantiator.GetJewelGridGameObject (k, j)) && (instantiator.GetJewelGridGameObject (k, j).tag == "Boulder" || instantiator.GetJewelGridGameObject (k, j).tag == "Steel Block")) {
////						k++;
////						immovableObjectCount++;
////					}
////					instantiator.GetJewelGridGameObject (i, j).layer = (instantiator.GetJewelGridGameObject (i, j).layer + 1 + immovableObjectCount);
////					jewelMovement = instantiator.GetJewelGridGameObject (i, j).GetComponent<RockLevelJewelMovement> ();
////					instantiator.GetJewelGridGameObject (i, j).transform.Translate (new Vector3 (0, 0, -(1 + immovableObjectCount)));
////					instantiator.SetJewelGridGameObject (jewelMovement.GetRow () + 1 + immovableObjectCount, jewelMovement.GetCol (), tempJewel);
////					jewelMovement.SetRow (jewelMovement.GetRow () + 1 + immovableObjectCount);
//				}
//			}
//			i--;
//		}
    }
    public void MoveDown()
    {
        //Debug.Log ("Jewel row = " + row + " col = " + col + " is attempting to move down");
        for (int i = row; i < 9; i++)
        {
            if (IsJewel(gameObject.tag) && (instantiator.GetJewelGridGameObject(i, col) == null || IsJewel(instantiator.GetJewelGridGameObject(i, col).tag)))
            {
                instantiator.SetJewelGridGameObject(row, col, null);
                gameObject.layer = gameObject.layer + (i - row);
                transform.Translate(new Vector3(0, 0, -(i - row)));
                instantiator.SetJewelGridGameObject(i, col, gameObject);
                row = i;
                return;
            }
        }
//		//Debug.Log ("Called MoveDown for row = " + row + " col = " + col);
//		bool jewelMovedDown = false, nextJewelFound = false;;
//		int tempRow = row - 1;
//		int tempCol = col;
//		int i = 8;
//		while (i >= 0) {
//			if (gameObject.tag == "Boulder" || (IsBomb (gameObject) && previousWasBoulder)) {
//				jewelMovedDown = true;
//				previousWasBoulder = true;
//			}
//			if (!jewelMovedDown && instantiator.GetJewelGridGameObject (i, col) == null) {
//				//Debug.Log ("Moving Jewel Down");
//				instantiator.SetJewelGridGameObject (row, col, null);
//				gameObject.layer = gameObject.layer + (i - row);
//				transform.Translate (new Vector3 (0, 0, -(i - row)));
//				instantiator.SetJewelGridGameObject (i, col, gameObject);
//				row = i;
//				jewelMovedDown = true;
//				previousWasBoulder = false;
//			}
//			if (jewelMovedDown && !nextJewelFound && tempRow >= 0) {
//				if (instantiator.GetJewelGridGameObject (tempRow, tempCol) == null)
//					tempRow--;
//				else {
//					instantiator.GetJewelGridGameObject (tempRow, tempCol).GetComponent<RockLevelJewelMovement> ().MoveDown (previousWasBoulder);
//					nextJewelFound = true;
//				}
//			}
//			i--;
//		}

//		if (k < 9 && (!deleteJewels.IsContainedInDeleteList (instantiator.GetJewelGridGameObject (k, col)) && !deleteJewels.IsElementOfBoulderDeleteList (instantiator.GetJewelGridGameObject (k, col)) &&
//	                 !instantiator.GetJewelGridGameObject (k, col).GetComponent<RockLevelJewelMovement> ().GetInDeleteList ())&& (instantiator.GetJewelGridGameObject (k, col).tag == "Boulder" || instantiator.GetJewelGridGameObject (k, col).tag == "Steel Block")) {
//			MoveDown (k + 1);
//			return;
//		}
//		if (instantiator.GetJewelGridGameObject(k, col) == null)  {
//			k++;
//		}
//		gameObject.layer = gameObject.layer + (k - row);
//		transform.Translate (new Vector3 (0, 0, -(k - row)));
//		instantiator.SetJewelGridGameObject (k, col, gameObject);
//		row = k;
//		int immovableObjectCount = 0;
//		if (IsBomb (gameObject)) {
//			int currentBombCount = 0;
//			bool lastBlockWasBomb = false;
////			while (k < 9 && ImmovableObject (instantiator.GetJewelGridGameObject (k + 1, col))) {
////				//Debug.Log ("Moving Bomb Down");
////				if (IsBomb (instantiator.GetJewelGridGameObject (k + 1, col))) {
////					currentBombCount++;
////				} else {
////					currentBombCount = 0;
////				}
////				k++;
////				immovableObjectCount++;
////			}
////			immovableObjectCount -= currentBombCount;
//			gameObject.layer = gameObject.layer + 1 + immovableObjectCount;
//			transform.Translate (new Vector3 (0, 0, -(1 + immovableObjectCount)));
//			instantiator.SetJewelGridGameObject (row + 1 + immovableObjectCount, col, gameObject);
//			row = (row + 1 + immovableObjectCount);
//		}
//		else {
//			while (k < 9 && !rocksToBeDestroyed.Contains (instantiator.GetJewelGridGameObject (k, col)) && (instantiator.GetJewelGridGameObject (k, col).tag == "Boulder" || instantiator.GetJewelGridGameObject (k, col).tag == "Steel Block" ||
//			                                                                                                (IsBomb (instantiator.GetJewelGridGameObject (k, col)) && (k + 1 < 9 && instantiator.GetJewelGridGameObject (k + 1, col).tag == "Boulder" ||
//			                                                           instantiator.GetJewelGridGameObject (k + 1, col).tag == "Steel Block")))) { /*&&*/
//				//		                 !instantiator.GetJewelGridGameObject (k, col).GetComponent<RockLevelJewelMovement> ().GetInDeleteList ()*/) && (instantiator.GetJewelGridGameObject (k, col).tag == "Boulder" || instantiator.GetJewelGridGameObject (k, col).tag == "Steel Block")) {
//				k++;
//				immovableObjectCount++;
//			}
//			gameObject.layer = gameObject.layer + 1 + immovableObjectCount;
//			transform.Translate (new Vector3 (0, 0, -(1 + immovableObjectCount)));
//			instantiator.SetJewelGridGameObject (row + 1 + immovableObjectCount, col, gameObject);
//			row = (row + 1 + immovableObjectCount);
//		}
    }