示例#1
0
    private void CheckTouch(Vector3 pos)
    {
        Vector3 wp       = Camera.main.ScreenToWorldPoint(pos);
        Vector2 touchPos = new Vector2(wp.x, wp.y);

        hit = Physics2D.OverlapPoint(touchPos);

        if (swapCooldown)
        {
            return;
        }

        if (/*!swapJewels.GetPauseTouchForSwap () &&*/ hit != null && !PowerStarTracker.ContainsJewel(hit.gameObject) /*&& !checkForMatches.JewelOkayToMove (hit.gameObject)*/ && HasCorrectTags(hit.gameObject) && hit.gameObject.name != "Slug Meal" && fiveInARow.GetMotherStarList().Count == 0 && corners.GetCornerStarGreaterThan10() && fiveInARow.GetChildStarList().Count == 0 && fourInARow.GetHomingStarList().Count == 0 && firstPressed == null /*&& deleteJewels.OkayToMoveAgain ()*/)
        {
            jewelMovement = hit.gameObject.GetComponent <RockLevelJewelMovement> ();
            if (!jewelMovement.GetToBeDestroyed() && !jewelMovement.GetMoving() && jewelMovement.GetOnPlatform() && !checkForMatches.deleteList.Contains(hit.gameObject))
            {
                if (tutorialLevel2 && hit.gameObject.name != "Level Two Tutorial Jewel")
                {
                    return;
                }
                firstPressed = hit.gameObject;
            }
        }
        else if (/*!swapJewels.GetPauseTouchForSwap () &&*/ hit != null && !PowerStarTracker.ContainsJewel(hit.gameObject) /*&& !checkForMatches.JewelOkayToMove (hit.gameObject) */ && HasCorrectTags(hit.gameObject) && hit.gameObject.name != "Slug Meal" /*&& deleteJewels.OkayToMoveAgain () */ && corners.GetCornerStarGreaterThan10() && fiveInARow.GetMotherStarList().Count == 0 && fiveInARow.GetChildStarList().Count == 0 && firstPressed != null && secondPressed == null && hit.gameObject != firstPressed && fourInARow.GetHomingStarList().Count == 0 &&
                 //((jewelMovement.GetRow () == hit.gameObject.GetComponent<RockLevelJewelMovement> ().GetRow () && Mathf.Abs (jewelMovement.GetCol () - hit.gameObject.GetComponent<RockLevelJewelMovement> ().GetCol ()) == 1) ||
                 //(jewelMovement.GetCol () == hit.gameObject.GetComponent<RockLevelJewelMovement> ().GetCol () && Mathf.Abs (jewelMovement.GetRow () - hit.gameObject.GetComponent<RockLevelJewelMovement> ().GetRow ()) == 1)))
                 Mathf.Abs(hit.gameObject.transform.position.x - firstPressed.transform.position.x) < .66 &&
                 Mathf.Abs(hit.gameObject.transform.position.y - firstPressed.transform.position.y) < .66 && (Mathf.Abs(hit.gameObject.transform.position.x - firstPressed.transform.position.x) < .1 || Mathf.Abs(hit.gameObject.transform.position.y - firstPressed.transform.position.y) < .1))
        {
            //{

            jewelMovement = hit.gameObject.GetComponent <RockLevelJewelMovement> ();
            if (!jewelMovement.GetToBeDestroyed() && !jewelMovement.GetMoving() && jewelMovement.GetOnPlatform() && !checkForMatches.deleteList.Contains(hit.gameObject))
            {
                if (tutorialLevel2 && hit.gameObject.name != "Level Two Tutorial Jewel")
                {
                    return;
                }
                secondPressed = hit.gameObject;
                swapCooldown  = true;
                timeStamp     = Time.time;
                swapJewels.Swap(firstPressed, secondPressed, false);
            }
        }
    }
    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--;
//		}
    }