// Update is called once per frame void Update() { if (!falling && GetComponent <Rigidbody2D>().velocity.y < 0) { transform.position = new Vector3(instantiator.GetJewelGridGameObject(targetRow, targetCol).transform.position.x, transform.position.y, transform.position.z); falling = true; } if (falling) { if (transform.position.y < instantiator.GetJewelGridGameObject(targetRow, targetCol).transform.position.y) { if (tag != "Bomb") { soundHandler.PlayJewelBreak(); if (PowerStarTracker.AddToHashSet(instantiator.GetJewelGridGameObject(targetRow, targetCol))) { HashSet <GameObject> deleteList = new HashSet <GameObject> (); deleteList.Add(instantiator.GetJewelGridGameObject(targetRow, targetCol)); deleteJewels.DeleteAllJewelsInList(deleteList, true); } PaidPowerTracker.RemovePowerFromList(gameObject); Destroy(gameObject); } else { DestroySurroundingJewels(); PaidPowerTracker.RemovePowerFromList(gameObject); Destroy(gameObject); } } } }
void FillDeleteRowArray() { if (directionInt == 0 || directionInt == 1) { for (int i = 0; i < 9; i++) { if (instantiator.GetJewelGridGameObject(i, targetJewelCol) != null && instantiator.GetJewelGridGameObject(i, targetJewelCol).tag != "Steel Block" && PowerStarTracker.AddToHashSet(instantiator.GetJewelGridGameObject(i, targetJewelCol))) { deleteRowArray[i] = instantiator.GetJewelGridGameObject(i, targetJewelCol); } } } else if (directionInt == 2 || directionInt == 3) { for (int i = 0; i < 9; i++) { if (instantiator.GetJewelGridGameObject(targetJewelRow, i) != null && instantiator.GetJewelGridGameObject(targetJewelRow, i).tag != "Steel Block" && PowerStarTracker.AddToHashSet(instantiator.GetJewelGridGameObject(targetJewelRow, i))) { deleteRowArray[i] = instantiator.GetJewelGridGameObject(targetJewelRow, i); } } } }
public void StageFourToStageThree() { name = "Slug Stage 3(Clone)"; currentBoulder = boulderStage3; gameObject.GetComponent <SpriteRenderer> ().sprite = redSprite; PowerStarTracker.RemoveFromHashSet(gameObject); }
// Update is called once per frame void Update() { if (!movementChecker.GetGridStatic() && Time.time > timeStamp + cooldown) { movementChecker.CheckGridForMovement(); timeStamp = Time.time; } if (Time.time > powerTrackerTimestamp + powerTrackerCooldown) { powerTrackerTimestamp = Time.time; PowerStarTracker.Clear(); } // if (!okayToMoveAgain && Time.time > okayToMoveTimeStamp + okayToMoveCooldown) { // //Debug.Log ("Okay To Move Again"); // okayToMoveAgain = true; // } if (!stopFindingMatches && Time.time > assistanceTimeStamp + assistanceCooldown) { findMatchForPlayer = true; assistanceTimeStamp = Time.time; } if (findMatchForPlayer) { matchAssistant.FindMatchForPlayer(); findMatchForPlayer = false; } }
public void StageThreeToStageTwo() { name = "Slug Stage 2(Clone)"; currentBoulder = boulderStage2; gameObject.GetComponent <SpriteRenderer> ().sprite = yellowSprite; PowerStarTracker.RemoveFromHashSet(gameObject); }
void InstantiateHomingStar() { // Debug.Log ("Instantiating Shooting Star"); tempStar = (GameObject)Instantiate(GetRandomStar(), starStartingPosition, Quaternion.identity); homingStarMovement = tempStar.GetComponent <RockLevelHomingStarMovement> (); row = Random.Range(0, 9); col = Random.Range(0, 9); jewelMovement = instantiator.GetJewelGridGameObject(row, col).GetComponent <RockLevelJewelMovement> (); while (!PowerStarTracker.AddToHashSet(instantiator.GetJewelGridGameObject(row, col))) { row = Random.Range(0, 9); col = Random.Range(0, 9); } // jewelMovement = instantiator.GetJewelGridGameObject (row, col).GetComponent<RockLevelJewelMovement> (); // while (jewelMovement.GetMoving () || !PowerStarTracker.AddToHashSet (instantiator.GetJewelGridGameObject (row, col))) { // row = Random.Range (0, 9); // col = Random.Range (0, 9); // while (instantiator.GetJewelGridGameObject (row, col) == null) { // row = Random.Range (0, 9); // col = Random.Range (0, 9); // } // jewelMovement = instantiator.GetJewelGridGameObject (row, col).GetComponent<RockLevelJewelMovement> (); // } homingStarMovement.SetRow(row); homingStarMovement.SetCol(col); }
public void IfJewelSetToNull(GameObject jewel) { if (jewel1 == jewel || jewel2 == jewel) { PowerStarTracker.RemoveFromHashSet(jewel1); PowerStarTracker.RemoveFromHashSet(jewel2); jewel1 = null; jewel2 = null; } }
public void SetStartLaunchingStars(bool startLaunchingStars) { if (startLaunchingStars) { if (GameObject.Find("Time Bomb Identification") != null) { GameObject.Find("Time Bomb Identification").GetComponent <TimeBombController> ().SetGameStarted(false); } //Debug.Log ("Setting startLaunchingStars = true"); PowerStarTracker.SetStarsShooting(true); } this.startLaunchingStars = startLaunchingStars; bombCount = bombRemainderController.GetBombRemainderTotal(); }
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 StageTwoToStageOne() { // SlugListManager.RemoveFromSlugList (gameObject); // GameObject tempSlug = (GameObject)Instantiate (slug, transform.position, Quaternion.identity); // RockLevelJewelMovement tempJewelMovement = tempSlug.GetComponent<RockLevelJewelMovement> (); // SlugListManager.AddToSlugList (tempSlug); // tempJewelMovement.SetBounced (true); // tempJewelMovement.SetRow (jewelMovement.GetRow ()); // tempJewelMovement.SetCol (jewelMovement.GetCol ()); // tempSlug.layer = gameObject.layer; // instantiator.SetJewelGridGameObject (tempJewelMovement.GetRow (), tempJewelMovement.GetCol (), tempSlug); // Destroy (gameObject); name = "Slug(Clone)"; currentBoulder = boulder; gameObject.GetComponent <SpriteRenderer> ().sprite = whiteSprite; PowerStarTracker.RemoveFromHashSet(gameObject); }
public void CheckGridForMovement() { gridStatic = false; if (GameObject.Find("Time Bomb Identification") != null) { if (GameObject.Find("Time Bomb Identification").GetComponent <TimeBombController> ().GetBombsExploding()) { return; } } for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { if (instantiator.GetJewelGridGameObject(i, j) == null) { return; } jewelMovement = instantiator.GetJewelGridGameObject(i, j).GetComponent <RockLevelJewelMovement> (); if (PaidPowerTracker.GetPowerListSize() != 0 /*|| starShooter.GetBombCount () > 0 || fourInARow.GetHomingStarList ().Count > 0 || fiveInARow.GetMotherStarList ().Count > 0 || fiveInARow.GetMotherStarList ().Count > 0 || corners.GetCornerStarList ().Count > 0*/) { gridStatic = false; deleteJewels.PunchNewTimeStamp(); return; } } } if (!shuffle.GetShuffleFinished()) { shuffle.SetShuffleFinished(true); } if (noMatchChecker.CheckForNoMatches()) { gridStatic = false; deleteJewels.PunchNewTimeStamp(); return; } if (!soundController.GetGameStarted()) { soundController.SetGameStarted(true); } CheckEveryJewelForMatch(); gridStatic = true; PowerStarTracker.Clear(); }
// Update is called once per frame void Update() { if (startDecent) { transform.Translate((targetX - transform.position.x) * Time.deltaTime * 15f, (targetY - transform.position.y) * Time.deltaTime * 15f, 0, Space.World); if (!targetJewelSet) { deleteJewels.StampTimeCard(); jewelToDestroy = instantiator.GetJewelGridGameObject(row, col); while (!PowerStarTracker.AddToHashSet(jewelToDestroy)) { row = Random.Range(0, 9); col = Random.Range(0, 9); jewelToDestroy = instantiator.GetJewelGridGameObject(row, col); crosshair.transform.position = new Vector3(-2.45f + (col * .6125f), 2.591252f - (row * .6097268f), -23); } targetJewelSet = true; } } if (startDecent && Mathf.Abs(targetX - transform.position.x) < .05f && Mathf.Abs(targetY - transform.position.y) < .05f) { if (jewelToDestroy != null) { if (IsJewel(gameObject.tag) || IsBomb(gameObject)) { jewelMovement = jewelToDestroy.GetComponent <RockLevelJewelMovement> (); jewelMovement.StartDestroyCountdown(); } if (jewelToDestroy != null && !swapJewel.IsASwapJewel(jewelToDestroy)) { deleteList.Add(jewelToDestroy); deleteJewels.DeleteAllJewelsInList(deleteList, true); } } Destroy(crosshair); fiveInARow.GetChildStarList().Remove(gameObject); if (fiveInARow.TutorialListContainsStar(gameObject)) { fiveInARow.RemoveStarFromTutorialList(gameObject); } Destroy(gameObject); } }
public void Swap(GameObject firstJewel, GameObject secondJewel, bool swapBack) { // if (!swapBack && (PowerStarTracker.ContainsJewel (firstJewel) || PowerStarTracker.ContainsJewel (secondJewel))) { // return; // } jewel1 = firstJewel; jewel2 = secondJewel; if (firstJewel == null || secondJewel == null) { return; } jewelOneMovement = firstJewel.GetComponent <RockLevelJewelMovement> (); jewelOneMovement.SetSwappingJewel(true); jewelTwoMovement = secondJewel.GetComponent <RockLevelJewelMovement> (); jewelTwoMovement.SetSwappingJewel(true); PowerStarTracker.AddToHashSet(firstJewel); PowerStarTracker.AddToHashSet(secondJewel); soundHandler.ResetJewelBreakNumber(); soundHandler.PlayJewelSwap(); deleteJewels.PunchAssistanceTimeStamp(); swapJewelsBack = swapBack; pauseTouchForSwap = true; int tempRow, tempCol; deleteJewels.StampAssistantTimeCard(); // stoppedMoving.SetGridStaticToFalse (); if (jewelOneMovement.GetMoving() || jewelTwoMovement.GetMoving() || jewelOneMovement.GetToBeDestroyed() || jewelTwoMovement.GetToBeDestroyed()) { if (jewel1 != null) { PowerStarTracker.RemoveFromHashSet(jewel1); jewel1 = null; jewelOneMovement.SetSwappingJewel(false); } if (jewel2 != null) { PowerStarTracker.RemoveFromHashSet(jewel2); jewel2 = null; jewelTwoMovement.SetSwappingJewel(false); } return; } jewelOneMovement.SetMoving(true); jewelTwoMovement.SetMoving(true); tempRow = jewelOneMovement.GetRow(); tempCol = jewelOneMovement.GetCol();; jewelOneOriginalPos = firstJewel.transform.position; jewelTwoOriginalPos = secondJewel.transform.position; if (IsBomb(firstJewel) && !IsBomb(secondJewel)) { jewelTwoOriginalPos.x = jewelTwoOriginalPos.x + .035f; jewelOneOriginalPos.x = jewelOneOriginalPos.x - .035f; } else if (IsBomb(secondJewel) && !IsBomb(firstJewel)) { jewelOneOriginalPos.x = jewelOneOriginalPos.x + .035f; jewelTwoOriginalPos.x = jewelTwoOriginalPos.x - .035f; } jewelOneMovement.SetRow(jewelTwoMovement.GetRow()); jewelOneMovement.SetCol(jewelTwoMovement.GetCol()); jewelTwoMovement.SetRow(tempRow); jewelTwoMovement.SetCol(tempCol); jewel1.GetComponent <Rigidbody2D>().isKinematic = true; jewel2.GetComponent <Rigidbody2D>().isKinematic = true; firstJewelLayer = jewel1.layer; secondJewelLayer = jewel2.layer; jewel1.layer = 0; jewel2.layer = 0; startSwap = true; }
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--; // } }
// Update is called once per frame void Update() { if (fourInARowStar) { if (!fireStar) { transform.Translate(new Vector3(oppositeX - transform.position.x, oppositeY - transform.position.y, 0) * Time.deltaTime * 8f, Space.World); if (Mathf.Abs(oppositeY - transform.position.y) < .05f) { if (!readyToFire) { readyToFire = true; } if (fourInARow.AllStarsReadyToFire()) { jewelToDestroy = instantiator.GetJewelGridGameObject(targetJewelRow, targetJewelCol); while (!PowerStarTracker.AddToHashSet(jewelToDestroy)) { targetJewelRow = Random.Range(0, 9); targetJewelCol = Random.Range(0, 9); jewelToDestroy = instantiator.GetJewelGridGameObject(targetJewelRow, targetJewelCol); targetPosition = (new Vector3(-2.45f + (targetJewelCol * .6125f), 2.591252f - (targetJewelRow * .6097268f), -90)); if (instantiatedCrosshairs != null) { Destroy(instantiatedCrosshairs); instantiatedCrosshairs = (GameObject)Instantiate(crosshairs, new Vector3(-2.45f + (targetJewelCol * .6125f), 2.591252f - (targetJewelRow * .6097268f), -79), Quaternion.identity); } } fireStar = true; timeStamp = Time.time; } } } else if (fireStar && Time.time > timeStamp + cooldown2) { if (!soundPlayed) { soundPlayed = true; soundHandler.PlayPowerShot(); } transform.Translate((targetPosition - transform.position) * Time.deltaTime * 20f, Space.World); int tempRow = 0, tempCol = 0; if ((Mathf.Abs(targetPosition.x - transform.position.x) < .2f && Mathf.Abs(targetPosition.y - transform.position.y) < .2f) || transform.position.y > 3f) { if (jewelToDestroy != null) { tempRow = jewelToDestroy.GetComponent <RockLevelJewelMovement> ().GetRow(); tempCol = jewelToDestroy.GetComponent <RockLevelJewelMovement> ().GetCol(); if (IsJewel(gameObject.tag) || IsBomb(gameObject)) { jewelMovement = jewelToDestroy.GetComponent <RockLevelJewelMovement> (); jewelMovement.StartDestroyCountdown(); } if (jewelToDestroy != null && !jewelToDestroy.GetComponent <RockLevelJewelMovement> ().GetMoving()) { deleteList.Add(jewelToDestroy); deleteJewels.DeleteAllJewelsInList(deleteList, true); } } if (instantiatedCrosshairs != null) { Destroy(instantiatedCrosshairs); } fourInARow.RemoveHomingStarFromList(gameObject); Destroy(gameObject); } } } else if (Time.time > timeStamp + cooldown1) { // if (!checkForRepeatJewel) { // while (!PowerStarTracker.AddToHashSet (jewelToDestroy)) { // targetJewelRow = Random.Range (0, 9); // targetJewelCol = Random.Range (0, 9); // jewelToDestroy = instantiator.GetJewelGridGameObject (targetJewelRow, targetJewelCol); // targetPosition = new Vector3 (-2.45f + (targetJewelCol * .6125f), 2.591252f - (targetJewelRow * .6097268f), -23); // } // checkForRepeatJewel = true; // } transform.Translate((targetPosition - transform.position) * Time.deltaTime * 7.5f, Space.World); if ((Mathf.Abs(targetPosition.x - transform.position.x) < .1f && Mathf.Abs(targetPosition.y - transform.position.y) < .1f) || transform.position.y > 3f) { Destroy(instantiatedCrosshairs); if (IsJewel(gameObject.tag) || IsBomb(gameObject)) { jewelMovement = instantiator.GetJewelGridGameObject(targetJewelRow, targetJewelCol).GetComponent <RockLevelJewelMovement> (); jewelMovement.StartDestroyCountdown(); } if (jewelToDestroy != null && !instantiator.GetJewelGridGameObject(targetJewelRow, targetJewelCol).GetComponent <RockLevelJewelMovement> ().GetMoving()) { deleteList.Add(jewelToDestroy); deleteJewels.DeleteAllJewelsInList(deleteList, true); } //Debug.Log ("Shooting Star From Second Method"); Destroy(gameObject); } } }
private void FillArrays() { RockLevelJewelMovement jewelMovement; if (horizontalPositive) { positiveHorizontalDeletes = new GameObject[9]; int count; if (!RockLevelCorners.cornerJewelAdded) { count = nextJewelToExplodeCol - 1; RockLevelCorners.cornerJewelAdded = true; } else { count = nextJewelToExplodeCol; } int index = 0; while (count < 9) { addedCornerJewel = true; if (instantiator.GetJewelGridGameObject(nextJewelToExplodeRow, count) != null) { jewelMovement = instantiator.GetJewelGridGameObject(nextJewelToExplodeRow, count).GetComponent <RockLevelJewelMovement> (); if (!jewelMovement.JewelAddedToArray() && PowerStarTracker.AddToHashSet(instantiator.GetJewelGridGameObject(nextJewelToExplodeRow, count))) { positiveHorizontalDeletes[index] = instantiator.GetJewelGridGameObject(nextJewelToExplodeRow, count); jewelMovement.SetAddedToArray(true); } } index++; count++; } } else if (horizontalNegative) { negativeHorizontalDeletes = new GameObject[9]; int count; if (!RockLevelCorners.cornerJewelAdded) { count = nextJewelToExplodeCol + 1; RockLevelCorners.cornerJewelAdded = true; } else { count = nextJewelToExplodeCol; } int index = 0; while (count >= 0) { if (instantiator.GetJewelGridGameObject(nextJewelToExplodeRow, count) != null) { jewelMovement = instantiator.GetJewelGridGameObject(nextJewelToExplodeRow, count).GetComponent <RockLevelJewelMovement> (); if (!jewelMovement.JewelAddedToArray() && PowerStarTracker.AddToHashSet(instantiator.GetJewelGridGameObject(nextJewelToExplodeRow, count))) { negativeHorizontalDeletes[index] = instantiator.GetJewelGridGameObject(nextJewelToExplodeRow, count); jewelMovement.SetAddedToArray(true); } } index++; count--; } } else if (verticalPositive) { positiveVerticalDeletes = new GameObject[9]; int count; if (!RockLevelCorners.cornerJewelAdded) { count = nextJewelToExplodeRow + 1; RockLevelCorners.cornerJewelAdded = true; } else { count = nextJewelToExplodeRow; } int index = 0; while (count >= 0) { if (instantiator.GetJewelGridGameObject(count, nextJewelToExplodeCol) != null) { jewelMovement = instantiator.GetJewelGridGameObject(count, nextJewelToExplodeCol).GetComponent <RockLevelJewelMovement> (); if (!jewelMovement.JewelAddedToArray() && PowerStarTracker.AddToHashSet(instantiator.GetJewelGridGameObject(count, nextJewelToExplodeCol))) { positiveVerticalDeletes[index] = instantiator.GetJewelGridGameObject(count, nextJewelToExplodeCol); jewelMovement.SetAddedToArray(true); } } index++; count--; } } else if (verticalNegative) { negativeVerticalDeletes = new GameObject[9]; int count; if (!RockLevelCorners.cornerJewelAdded) { count = nextJewelToExplodeRow - 1; RockLevelCorners.cornerJewelAdded = true; } else { count = nextJewelToExplodeRow; } int index = 0; while (count < 9) { if (instantiator.GetJewelGridGameObject(count, nextJewelToExplodeCol) != null) { ; } jewelMovement = instantiator.GetJewelGridGameObject(count, nextJewelToExplodeCol).GetComponent <RockLevelJewelMovement> (); if (!jewelMovement.JewelAddedToArray() && PowerStarTracker.AddToHashSet(instantiator.GetJewelGridGameObject(count, nextJewelToExplodeCol))) { negativeVerticalDeletes[index] = instantiator.GetJewelGridGameObject(count, nextJewelToExplodeCol); jewelMovement.SetAddedToArray(true); } index++; count++; } } changeJewelName = true; }
// 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 (); } } } }
// bool CheckForBouldersForBoulders (int row, int col) { // tempBoulder = instantiator.GetJewelGridGameObject (row, col); // if (tempBoulder != null && tempBoulder.name == "Rock 3 Chain(Clone)") { // PowerStarTracker.AddToHashSet (tempBoulder); // tempBoulder.name = "Rock 2 Chain(Clone)"; // tempBoulder.GetComponent<SpriteRenderer> ().sprite = boulderSprite3; // } // else if (tempBoulder != null && tempBoulder.name == "Rock 2 Chain(Clone)") { // PowerStarTracker.AddToHashSet (tempBoulder); // tempBoulder.name = "Rock 1 Chain(Clone)"; // tempBoulder.GetComponent<SpriteRenderer> ().sprite = boulderSprite2; // } // else if (tempBoulder != null && tempBoulder.name == "Slug Stage 3(Clone)") { // tempBoulder.GetComponent<SlugMovementController> ().StageThreeToStageTwo (); // return true; // } // else if (tempBoulder != null && tempBoulder.name == "Rock 1 Chain(Clone)") { // PowerStarTracker.AddToHashSet (tempBoulder); // tempBoulder.name = "Rock Blocked(Clone)"; // tempBoulder.GetComponent<SpriteRenderer> ().sprite = boulderSprite; // } // else if (tempBoulder != null && tempBoulder.name == "Slug Stage 2(Clone)") { // tempBoulder.GetComponent<SlugMovementController> ().StageTwoToStageOne (); // return true; // } // else if (tempBoulder != null && tempBoulder.name == "Rock Blocked(Clone)") { // tempBoulder.GetComponent<RockLevelJewelMovement> ().AddToRocksToBeDestroyed (tempBoulder); // boulderDeleteList.Add (tempBoulder); // } // else if (tempBoulder != null && tempBoulder.name == "Slug(Clone)") { // if (tempBoulder.transform.childCount > 1) { // Sprite tempBombSprite = null; // switch (Random.Range (0, 6)) { // case 0: tempBombSprite = blueBombSprite; tempBoulder.name = "Blue Bomb"; tempBoulder.tag = "Blue Bomb"; break; // case 1: tempBombSprite = greenBombSprite; tempBoulder.name = "Green Bomb"; tempBoulder.tag = "Green Bomb"; break; // case 2: tempBombSprite = orangeBombSprite; tempBoulder.name = "Orange Bomb"; tempBoulder.tag = "Orange Bomb"; break; // case 3: tempBombSprite = purpleBombSprite; tempBoulder.name = "Purple Bomb"; tempBoulder.tag = "Purple Bomb"; break; // case 4: tempBombSprite = redBombSprite; tempBoulder.name = "Red Bomb"; tempBoulder.tag = "Red Bomb"; break; // case 5: tempBombSprite = whiteBombSprite; tempBoulder.name = "White Bomb"; tempBoulder.tag = "White Bomb"; break; // } // if (tempBoulder.transform.GetChild (0).tag == "Slug Eyes") { // Destroy (tempBoulder.GetComponent<SlugEyeController> ()); // Destroy (tempBoulder.GetComponent<SlugMovementController> ()); // SlugListManager.RemoveFromSlugList (tempBoulder); // Instantiate (whiteExplosion, new Vector3 (tempBoulder.transform.position.x, tempBoulder.transform.position.y, tempBoulder.transform.position.z - 10), Quaternion.Euler (-90, 0, 0)); // Destroy (tempBoulder.transform.GetChild (0).gameObject); // } // // else if (tempBoulder.transform.GetChild (1).tag == "Slug Eyes") { // Destroy (tempBoulder.GetComponent<SlugEyeController> ()); // Destroy (tempBoulder.GetComponent<SlugMovementController> ()); // SlugListManager.RemoveFromSlugList (tempBoulder); // Instantiate (whiteExplosion, new Vector3 (tempBoulder.transform.position.x, tempBoulder.transform.position.y, tempBoulder.transform.position.z - 10), Quaternion.Euler (-90, 0, 0)); // Destroy (tempBoulder.transform.GetChild (1).gameObject); // } // // tempBoulder.transform.localScale = new Vector3 (.1f, .1f, 1f); // tempBoulder.GetComponent<BoxCollider2D> ().size = new Vector2 (5.47f, 6); // tempBoulder.GetComponent<SpriteRenderer> ().sprite = tempBombSprite; // GameObject instantiatedBombSpark = (GameObject) Instantiate(bombSpark, new Vector3 (tempBoulder.transform.position.x + .212f, tempBoulder.transform.position.y + .247f, tempBoulder.transform.position.z - .1f), Quaternion.identity); // instantiatedBombSpark.transform.parent = tempBoulder.transform; // int newRow = tempBoulder.GetComponent<RockLevelJewelMovement> ().GetRow (); // int newCol = tempBoulder.GetComponent<RockLevelJewelMovement> ().GetCol (); // tempBoulder.transform.position = new Vector3 (startingLeftJewelPosition + (horizontalMultiplier * newCol), 2.591258f - (.61f * newRow), (-1 * newRow) - 2); // // // if (tempBoulder.transform.GetChild (0).tag == "Bomb Number") { // tempBoulder.transform.GetChild (0).gameObject.transform.position = new Vector3 (tempBoulder.transform.position.x, tempBoulder.transform.position.y, tempBoulder.transform.position.z - .1f); // } // else if (tempBoulder.transform.GetChild (1).tag == "Bomb Number") { // tempBoulder.transform.GetChild (1).gameObject.transform.position = new Vector3 (tempBoulder.transform.position.x, tempBoulder.transform.position.y, tempBoulder.transform.position.z - .1f); // } // tempBoulder.GetComponent<Rigidbody2D> ().isKinematic = false; // return true; // } // else { // tempBoulder.GetComponent<RockLevelJewelMovement> ().AddToRocksToBeDestroyed (tempBoulder); // boulderDeleteList.Add (tempBoulder); // } // } // return false; // } // bool CheckForBouldersForBoulders (int row, int col) { // tempBoulder = instantiator.GetJewelGridGameObject (row, col); // if (tempBoulder != null && tempBoulder.name == "Rock 3 Chain(Clone)") { // PowerStarTracker.AddToHashSet (tempBoulder);new Vector3 (startingLeftJewelPosition + (horizontalMultiplier * j), Random.Range (10, 15), (-1 * i) - 2) // Vector3 boulderPosition = tempBoulder.transform.position; // int boulderLayer = tempBoulder.layer; // Destroy (tempBoulder); // instantiator.SetJewelGridGameObject (row, col, (GameObject) Instantiate (boulderChain2, boulderPosition, Quaternion.identity)); // tempBoulder = instantiator.GetJewelGridGameObject (row, col); // tempBoulder.layer = boulderLayer; // RockLevelJewelMovement boulderMovement = tempBoulder.GetComponent<RockLevelJewelMovement> (); // boulderMovement.SetBounced (true); // boulderMovement.SetRow (row); // boulderMovement.SetCol (col); // } // else if (tempBoulder != null && (tempBoulder.name == "Rock 2 Chain(Clone)" || tempBoulder.name == "Slug Stage 3(Clone)")) { // if (tempBoulder.name == "Slug Stage 3(Clone)") { // tempBoulder.GetComponent<SlugMovementController> ().StageThreeToStageTwo (); // return true; // } else { // PowerStarTracker.AddToHashSet (tempBoulder); // Vector3 boulderPosition = tempBoulder.transform.position; // int boulderLayer = tempBoulder.layer; // Destroy (tempBoulder); // instantiator.SetJewelGridGameObject (row, col, (GameObject) Instantiate (boulderChain1, boulderPosition, Quaternion.identity)); // tempBoulder = instantiator.GetJewelGridGameObject (row, col); // tempBoulder.layer = boulderLayer; // RockLevelJewelMovement boulderMovement = tempBoulder.GetComponent<RockLevelJewelMovement> (); // boulderMovement.SetBounced (true); // boulderMovement.SetRow (row); // boulderMovement.SetCol (col); // } // } // else if (tempBoulder != null && (tempBoulder.name == "Rock 1 Chain(Clone)" || tempBoulder.name == "Slug Stage 2(Clone)")) { // if (tempBoulder.name == "Slug Stage 2(Clone)") { //// SlugListManager.RemoveFromSlugList (tempBoulder); //// Destroy (tempBoulder); //// instantiator.SetJewelGridGameObject (row, col, (GameObject) Instantiate (slug, boulderPosition, Quaternion.identity)); //// SlugListManager.AddToSlugList (tempBoulder); // tempBoulder.GetComponent<SlugMovementController> ().StageTwoToStageOne (); // return true; // } else { // PowerStarTracker.AddToHashSet (tempBoulder); // Vector3 boulderPosition = tempBoulder.transform.position; // int boulderLayer = tempBoulder.layer; // bombHandler.RemoveFromBombList (tempBoulder); // Instantiate (whiteExplosion, new Vector3 (tempBoulder.transform.position.x, tempBoulder.transform.position.y, tempBoulder.transform.position.z - 10), Quaternion.Euler (-90, 0, 0)); // Destroy (tempBoulder); // instantiator.SetJewelGridGameObject (row, col, (GameObject) Instantiate (boulder, boulderPosition, Quaternion.identity)); // tempBoulder = instantiator.GetJewelGridGameObject (row, col); // tempBoulder.layer = boulderLayer; // RockLevelJewelMovement boulderMovement = tempBoulder.GetComponent<RockLevelJewelMovement> (); // boulderMovement.SetBounced (true); // boulderMovement.SetRow (row); // boulderMovement.SetCol (col); // bombHandler.AddBombToList (tempBoulder); // } // } // // else if (row >= 0 && (tempBoulder.name == "Rock Blocked(Clone)" || tempBoulder.name == "Slug(Clone)")) { // if (tempBoulder.transform.childCount > 1) { // PowerStarTracker.AddToHashSet (tempBoulder); // Vector3 boulderPosition = new Vector3 (startingLeftJewelPosition + (horizontalMultiplier * col), 2.591258f - (.61f * row), (-1 * row) - 2); //// Vector3 boulderPosition = tempBoulder.transform.position; // int boulderLayer = tempBoulder.layer; // GameObject bombNumber = null; // if (tempBoulder.transform.GetChild (0) != null && tempBoulder.transform.GetChild (0).tag == "Bomb Number") // bombNumber = tempBoulder.transform.GetChild (0).gameObject; // else if (tempBoulder.transform.GetChild (1) != null && tempBoulder.transform.GetChild (1).tag == "Bomb Number") // bombNumber = tempBoulder.transform.GetChild (1).gameObject; // bombNumber.transform.parent = null; // tempBoulder.GetComponent<SlugMovementController> ().BeingDeleted (true); // bombHandler.RemoveFromBombList (tempBoulder); // Instantiate (whiteExplosion, new Vector3 (tempBoulder.transform.position.x, tempBoulder.transform.position.y, tempBoulder.transform.position.z - 10), Quaternion.Euler (-90, 0, 0)); // Destroy (tempBoulder); // instantiator.SetJewelGridGameObject (row, col, GetRandomBomb (boulderPosition, bombNumber)); // Debug.Log ("Child 0 = " + instantiator.GetJewelGridGameObject (row, col).transform.GetChild (0) + " Child 1 = " + instantiator.GetJewelGridGameObject (row, col).transform.GetChild (1)); // tempBoulder = instantiator.GetJewelGridGameObject (row, col); // bombHandler.AddBombToList (tempBoulder); // bombNumber.transform.position = new Vector3 (tempBoulder.transform.position.x, tempBoulder.transform.position.y, tempBoulder.transform.position.z - .1f); // tempBoulder.layer = boulderLayer; // RockLevelJewelMovement boulderMovement = tempBoulder.GetComponent<RockLevelJewelMovement> (); // boulderMovement.SetBounced (true); // boulderMovement.SetRow (row); // boulderMovement.SetCol (col); // return true; // } else { // tempBoulder.GetComponent<RockLevelJewelMovement> ().AddToRocksToBeDestroyed (tempBoulder); // boulderDeleteList.Add (tempBoulder); // } // } // return false; // } bool CheckForBoulders(int row, int col) { tempBoulder = instantiator.GetJewelGridGameObject(row, col); if (tempBoulder != null && tempBoulder.name == "Rock 3 Chain(Clone)") { tempBoulder.name = "Rock 2 Chain(Clone)"; tempBoulder.GetComponent <SpriteRenderer> ().sprite = boulderSprite3; tempBoulder.GetComponent <RockLevelJewelMovement> ().SetAddedToArray(false); PowerStarTracker.RemoveFromHashSet(tempBoulder); return(true); } else if (tempBoulder != null && tempBoulder.name == "Rock 2 Chain(Clone)") { tempBoulder.name = "Rock 1 Chain(Clone)"; tempBoulder.GetComponent <SpriteRenderer> ().sprite = boulderSprite2; tempBoulder.GetComponent <RockLevelJewelMovement> ().SetAddedToArray(false); PowerStarTracker.RemoveFromHashSet(tempBoulder); Instantiate(redExplosion, new Vector3(tempBoulder.transform.position.x, tempBoulder.transform.position.y, tempBoulder.transform.position.z - 10), Quaternion.Euler(-90, 0, 0)); return(true); } else if (tempBoulder != null && tempBoulder.name == "Slug Stage 4(Clone)") { tempBoulder.GetComponent <SlugMovementController> ().StageFourToStageThree(); tempBoulder.GetComponent <RockLevelJewelMovement> ().SetAddedToArray(false); PowerStarTracker.RemoveFromHashSet(tempBoulder); return(true); } else if (tempBoulder != null && tempBoulder.name == "Slug Stage 3(Clone)") { tempBoulder.GetComponent <SlugMovementController> ().StageThreeToStageTwo(); tempBoulder.GetComponent <RockLevelJewelMovement> ().SetAddedToArray(false); PowerStarTracker.RemoveFromHashSet(tempBoulder); Instantiate(redExplosion, new Vector3(tempBoulder.transform.position.x, tempBoulder.transform.position.y, tempBoulder.transform.position.z - 10), Quaternion.Euler(-90, 0, 0)); return(true); } else if (tempBoulder != null && tempBoulder.name == "Rock 1 Chain(Clone)") { tempBoulder.name = "Rock Blocked(Clone)"; tempBoulder.GetComponent <SpriteRenderer> ().sprite = boulderSprite; tempBoulder.GetComponent <RockLevelJewelMovement> ().SetAddedToArray(false); PowerStarTracker.RemoveFromHashSet(tempBoulder); Instantiate(yellowBlockExplosion, new Vector3(tempBoulder.transform.position.x, tempBoulder.transform.position.y, tempBoulder.transform.position.z - 10), Quaternion.Euler(-90, 0, 0)); return(true); } else if (tempBoulder != null && tempBoulder.name == "Slug Stage 2(Clone)") { tempBoulder.GetComponent <SlugMovementController> ().StageTwoToStageOne(); tempBoulder.GetComponent <RockLevelJewelMovement> ().SetAddedToArray(false); PowerStarTracker.RemoveFromHashSet(tempBoulder); Instantiate(yellowBlockExplosion, new Vector3(tempBoulder.transform.position.x, tempBoulder.transform.position.y, tempBoulder.transform.position.z - 10), Quaternion.Euler(-90, 0, 0)); return(true); } else if (tempBoulder != null && tempBoulder.name == "Rock Blocked(Clone)") { if (tempBoulder.transform.childCount > 0 && bombHandler.BombListContains(tempBoulder)) { Sprite tempBombSprite = null; switch (Random.Range(0, 6)) { case 0: tempBombSprite = blueBombSprite; tempBoulder.name = "Blue Bomb"; tempBoulder.tag = "Blue Bomb"; break; case 1: tempBombSprite = greenBombSprite; tempBoulder.name = "Green Bomb"; tempBoulder.tag = "Green Bomb"; break; case 2: tempBombSprite = orangeBombSprite; tempBoulder.name = "Orange Bomb"; tempBoulder.tag = "Orange Bomb"; break; case 3: tempBombSprite = purpleBombSprite; tempBoulder.name = "Purple Bomb"; tempBoulder.tag = "Purple Bomb"; break; case 4: tempBombSprite = redBombSprite; tempBoulder.name = "Red Bomb"; tempBoulder.tag = "Red Bomb"; break; case 5: tempBombSprite = whiteBombSprite; tempBoulder.name = "White Bomb"; tempBoulder.tag = "White Bomb"; break; } for (int i = 0; i < tempBoulder.transform.childCount; i++) { if (tempBoulder.transform.GetChild(i).tag == "Slug Eyes") { Destroy(tempBoulder.GetComponent <SlugEyeController> ()); Destroy(tempBoulder.GetComponent <SlugMovementController> ()); SlugListManager.RemoveFromSlugList(tempBoulder); Instantiate(whiteExplosion, new Vector3(tempBoulder.transform.position.x, tempBoulder.transform.position.y, tempBoulder.transform.position.z - 10), Quaternion.Euler(-90, 0, 0)); Destroy(tempBoulder.transform.GetChild(i).gameObject); break; } } tempBoulder.transform.localScale = new Vector3(.1f, .1f, 1f); tempBoulder.GetComponent <BoxCollider2D> ().size = new Vector2(5.47f, 6); tempBoulder.GetComponent <SpriteRenderer> ().sprite = tempBombSprite; GameObject instantiatedBombSpark = (GameObject)Instantiate(bombSpark, new Vector3(tempBoulder.transform.position.x + .212f, tempBoulder.transform.position.y + .247f, tempBoulder.transform.position.z - .1f), Quaternion.identity); instantiatedBombSpark.transform.parent = tempBoulder.transform; int newRow = tempBoulder.GetComponent <RockLevelJewelMovement> ().GetRow(); int newCol = tempBoulder.GetComponent <RockLevelJewelMovement> ().GetCol(); tempBoulder.transform.position = new Vector3(startingLeftJewelPosition + (horizontalMultiplier * newCol), 2.591258f - (.61f * newRow), (-1 * newRow) - 2); tempBoulder.layer = row + 17; for (int i = 0; i < tempBoulder.transform.childCount; i++) { if (tempBoulder.transform.GetChild(i).tag == "Bomb Number") { tempBoulder.transform.GetChild(i).gameObject.transform.position = new Vector3(tempBoulder.transform.position.x, tempBoulder.transform.position.y, tempBoulder.transform.position.z - .1f); break; } } tempBoulder.GetComponent <Rigidbody2D> ().isKinematic = false; tempBoulder.GetComponent <RockLevelJewelMovement> ().SetAddedToArray(false); PowerStarTracker.RemoveFromHashSet(tempBoulder); tempBoulder.GetComponent <Rigidbody2D> ().AddForce(new Vector3(0, 300)); return(true); } else { tempBoulder.GetComponent <RockLevelJewelMovement> ().AddToRocksToBeDestroyed(tempBoulder); boulderDeleteList.Add(tempBoulder); return(false); } } else if (tempBoulder != null && tempBoulder.name == "Slug(Clone)") { if (tempBoulder.transform.childCount > 1 && bombHandler.BombListContains(tempBoulder)) { Sprite tempBombSprite = null; switch (Random.Range(0, 6)) { case 0: tempBombSprite = blueBombSprite; tempBoulder.name = "Blue Bomb"; tempBoulder.tag = "Blue Bomb"; break; case 1: tempBombSprite = greenBombSprite; tempBoulder.name = "Green Bomb"; tempBoulder.tag = "Green Bomb"; break; case 2: tempBombSprite = orangeBombSprite; tempBoulder.name = "Orange Bomb"; tempBoulder.tag = "Orange Bomb"; break; case 3: tempBombSprite = purpleBombSprite; tempBoulder.name = "Purple Bomb"; tempBoulder.tag = "Purple Bomb"; break; case 4: tempBombSprite = redBombSprite; tempBoulder.name = "Red Bomb"; tempBoulder.tag = "Red Bomb"; break; case 5: tempBombSprite = whiteBombSprite; tempBoulder.name = "White Bomb"; tempBoulder.tag = "White Bomb"; break; } tempBoulder.transform.localScale = new Vector3(.1f, .1f, 1f); tempBoulder.GetComponent <BoxCollider2D> ().size = new Vector2(5.47f, 6); tempBoulder.GetComponent <SpriteRenderer> ().sprite = tempBombSprite; GameObject instantiatedBombSpark = (GameObject)Instantiate(bombSpark, new Vector3(tempBoulder.transform.position.x + .212f, tempBoulder.transform.position.y + .247f, tempBoulder.transform.position.z - .1f), Quaternion.identity); instantiatedBombSpark.transform.parent = tempBoulder.transform; int newRow = tempBoulder.GetComponent <RockLevelJewelMovement> ().GetRow(); int newCol = tempBoulder.GetComponent <RockLevelJewelMovement> ().GetCol(); tempBoulder.transform.position = new Vector3(startingLeftJewelPosition + (horizontalMultiplier * newCol), 2.591258f - (.61f * newRow), (-1 * newRow) - 2); tempBoulder.layer = row + 17; for (int i = 0; i < tempBoulder.transform.childCount; i++) { if (tempBoulder.transform.GetChild(i).tag == "Slug Eyes") { Destroy(tempBoulder.GetComponent <SlugEyeController> ()); Destroy(tempBoulder.GetComponent <SlugMovementController> ()); SlugListManager.RemoveFromSlugList(tempBoulder); Instantiate(whiteExplosion, new Vector3(tempBoulder.transform.position.x, tempBoulder.transform.position.y, tempBoulder.transform.position.z - 10), Quaternion.Euler(-90, 0, 0)); DestroySlugEyes(tempBoulder); break; } } for (int i = 0; i < tempBoulder.transform.childCount; i++) { if (tempBoulder.transform.GetChild(i).tag == "Bomb Number") { tempBoulder.transform.GetChild(i).gameObject.transform.position = new Vector3(tempBoulder.transform.position.x, tempBoulder.transform.position.y, tempBoulder.transform.position.z - .1f); break; } } tempBoulder.GetComponent <Rigidbody2D> ().isKinematic = false; tempBoulder.GetComponent <RockLevelJewelMovement> ().SetAddedToArray(false); PowerStarTracker.RemoveFromHashSet(tempBoulder); tempBoulder.GetComponent <Rigidbody2D> ().AddForce(new Vector3(0, 300)); return(true); } else { tempBoulder.GetComponent <RockLevelJewelMovement> ().AddToRocksToBeDestroyed(tempBoulder); boulderDeleteList.Add(tempBoulder); return(false); } } return(false); }
void DestroySurroundingJewels() { HashSet <GameObject> deleteList = new HashSet <GameObject> (); GameObject tempJewel = null; if (PowerStarTracker.AddToHashSet(instantiator.GetJewelGridGameObject(targetRow, targetCol))) { deleteList.Add(instantiator.GetJewelGridGameObject(targetRow, targetCol)); } if (targetRow - 1 >= 0) { tempJewel = instantiator.GetJewelGridGameObject(targetRow - 1, targetCol); if (PowerStarTracker.AddToHashSet(tempJewel)) { deleteList.Add(tempJewel); } if (targetCol + 1 <= 8) { tempJewel = instantiator.GetJewelGridGameObject(targetRow - 1, targetCol + 1); if (PowerStarTracker.AddToHashSet(tempJewel)) { deleteList.Add(tempJewel); } } if (targetCol - 1 >= 0) { tempJewel = instantiator.GetJewelGridGameObject(targetRow - 1, targetCol - 1); if (PowerStarTracker.AddToHashSet(tempJewel)) { deleteList.Add(tempJewel); } } } if (targetRow + 1 <= 8) { tempJewel = instantiator.GetJewelGridGameObject(targetRow + 1, targetCol); if (PowerStarTracker.AddToHashSet(tempJewel)) { deleteList.Add(tempJewel); } if (targetCol + 1 <= 8) { tempJewel = instantiator.GetJewelGridGameObject(targetRow + 1, targetCol + 1); if (PowerStarTracker.AddToHashSet(tempJewel)) { deleteList.Add(tempJewel); } } if (targetCol - 1 >= 0) { tempJewel = instantiator.GetJewelGridGameObject(targetRow + 1, targetCol - 1); if (PowerStarTracker.AddToHashSet(tempJewel)) { deleteList.Add(tempJewel); } } } if (targetCol + 1 <= 8) { tempJewel = instantiator.GetJewelGridGameObject(targetRow, targetCol + 1); if (PowerStarTracker.AddToHashSet(tempJewel)) { deleteList.Add(tempJewel); } } if (targetCol - 1 >= 0) { tempJewel = instantiator.GetJewelGridGameObject(targetRow, targetCol - 1); if (PowerStarTracker.AddToHashSet(tempJewel)) { deleteList.Add(tempJewel); } } Instantiate(bombExplosion, transform.position, Quaternion.Euler(180, 0, 0)); deleteJewels.DeleteAllJewelsInList(deleteList, true); }
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 (); // } }