// 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); } } } }
// Update is called once per frame void Update() { if (moveToInitialPosition) { transform.Translate((initialPositionVector - transform.position) * Time.deltaTime * 5, Space.World); if (Mathf.Abs(initialPositionVector.x - transform.position.x) < .01f || Mathf.Abs(initialPositionVector.y - transform.position.y) < .01f) { FillDeleteRowArray(); moveToInitialPosition = false; moveToFinalPosition = true; } } else if (moveToFinalPosition) { if (!soundPlayed) { soundPlayed = true; soundHandler.PlayPowerShot(); } transform.Translate((finalPositionVector - transform.position) * Time.deltaTime / 2, Space.World); for (int i = 0; i < deleteRowArray.Length; i++) { if (directionInt == 0 && deleteRowArray[i] != null && deleteRowArray[i].transform.position.y > transform.position.y) { deleteList.Add(deleteRowArray[i]); deleteRowArray[i] = null; deleteJewels.DeleteAllJewelsInList(deleteList, true); deleteList.Clear(); } else if (directionInt == 1 && deleteRowArray[i] != null && deleteRowArray[i].transform.position.y < transform.position.y) { deleteList.Add(deleteRowArray[i]); deleteRowArray[i] = null; deleteJewels.DeleteAllJewelsInList(deleteList, true); deleteList.Clear(); } else if (directionInt == 2 && deleteRowArray[i] != null && deleteRowArray[i].transform.position.x > transform.position.x) { deleteList.Add(deleteRowArray[i]); deleteRowArray[i] = null; deleteJewels.DeleteAllJewelsInList(deleteList, true); deleteList.Clear(); } else if (directionInt == 3 && deleteRowArray[i] != null && deleteRowArray[i].transform.position.x < transform.position.x) { deleteList.Add(deleteRowArray[i]); deleteRowArray[i] = null; deleteJewels.DeleteAllJewelsInList(deleteList, true); deleteList.Clear(); } } if ((Mathf.Abs(transform.position.x) > 50 || Mathf.Abs(transform.position.y) > 50)) { PaidPowerTracker.RemovePowerFromList(gameObject); Destroy(gameObject); } } }
// Update is called once per frame void Update() { if (move) { transform.Translate(new Vector3(targetPosition.x - transform.position.x, 0, 0) * Time.deltaTime * speed); if (transform.position.y < yMin) { if (instantiator.GetJewelGridGameObject(row, col) != null) { deleteList.Add(instantiator.GetJewelGridGameObject(row, col)); deleteJewels.DeleteAllJewelsInList(deleteList, false); } Destroy(gameObject); } } }
// 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 bool CheckForSwapBack(GameObject jewel, int i, int j) { if (!gameStarted) { return(false); } //Debug.Log ("Checking For SwapBack"); horizontalMatchCheckCount = 0; verticalMatchCheckCount = 0; horizontalMatch = false; verticalMatch = false; exitMatchCheck = false; dontDelete = false; ClearLists(); int verticalJewelOffset = 1; int verticalJewelCount = 1; verticalDeleteList.Add(jewel); while (i - verticalJewelOffset >= 0 && instantiator.GetJewelGridGameObject(i - verticalJewelOffset, j) != null && JewelsAreTheSame(instantiator.GetJewelGridGameObject(i - verticalJewelOffset, j).tag, jewel.tag)) { verticalDeleteList.Add(instantiator.GetJewelGridGameObject(i - verticalJewelOffset, j)); verticalJewelCount++; verticalJewelOffset++; } verticalJewelOffset = 1; while (i + verticalJewelOffset < 9 && instantiator.GetJewelGridGameObject(i + verticalJewelOffset, j) != null && JewelsAreTheSame(instantiator.GetJewelGridGameObject(i + verticalJewelOffset, j).tag, jewel.tag)) { verticalDeleteList.Add(instantiator.GetJewelGridGameObject(i + verticalJewelOffset, j)); verticalJewelCount++; verticalJewelOffset++; } if (verticalJewelCount >= 3) { foreach (GameObject a in verticalDeleteList) { bool added = deleteList.Add(a); if (added && a != null) { jewelMovement = a.GetComponent <RockLevelJewelMovement> (); jewelMovement.SetToBeDestroyed(); if (jewelMovement.GetMoving()) { ClearLists(); return(true); } CheckForHorizontalMatches(a, jewelMovement.GetRow(), jewelMovement.GetCol()); if (exitMatchCheck) { ClearLists(); return(true); } } } verticalMatch = true; } else { verticalDeleteList.Remove(jewel); } int horizontalJewelOffset = 1; int horizontalJewelCount = 1; horizontalDeleteList.Add(jewel); while (j - horizontalJewelOffset >= 0 && instantiator.GetJewelGridGameObject(i, j - horizontalJewelOffset) != null && JewelsAreTheSame(instantiator.GetJewelGridGameObject(i, j - horizontalJewelOffset).tag, jewel.tag)) { horizontalDeleteList.Add(instantiator.GetJewelGridGameObject(i, j - horizontalJewelOffset)); horizontalJewelCount++; horizontalJewelOffset++; } horizontalJewelOffset = 1; while (j + horizontalJewelOffset < 9 && instantiator.GetJewelGridGameObject(i, j + horizontalJewelOffset) != null && JewelsAreTheSame(instantiator.GetJewelGridGameObject(i, j + horizontalJewelOffset).tag, jewel.tag)) { horizontalDeleteList.Add(instantiator.GetJewelGridGameObject(i, j + horizontalJewelOffset)); horizontalJewelCount++; horizontalJewelOffset++; } if (horizontalJewelCount >= 3) { foreach (GameObject a in horizontalDeleteList) { bool added = deleteList.Add(a); if (added && a != null) { jewelMovement = a.GetComponent <RockLevelJewelMovement> (); jewelMovement.SetToBeDestroyed(); if (jewelMovement.GetMoving()) { ClearLists(); return(true); } CheckForVerticalMatches(a, jewelMovement.GetRow(), jewelMovement.GetCol()); if (exitMatchCheck) { ClearLists(); return(true); } } } horizontalMatch = true; } else { horizontalDeleteList.Remove(jewel); } if (exitMatchCheck) { ClearLists(); return(true); } if (deleteList.Count > 2) { if (deleteList.Count >= 5 && verticalMatch && horizontalMatch) { foreach (GameObject a in horizontalDeleteList) { if (verticalDeleteList.Contains(a)) { int count = 1; if (!jewelsThatActivatedCorners.Contains(a)) { jewelsThatActivatedCorners.Add(a); soundHandler.PlayPowerUpSound(); corners.ActivateCornersPowers(a); } } } // scoreKeeper.IncreaseScoreByCornerJewelBonus (); // deleteList.Clear (); } else if (deleteList.Count >= 5 && !(verticalMatch && horizontalMatch)) { // //Debug.Log ("5 in a row"); fiveInARow.InstantiateMotherStar(jewel); // scoreKeeper.IncreaseScoreByFiveInLineBonus (); } if (deleteList.Count >= 7 && verticalMatch && horizontalMatch) { fiveInARow.InstantiateMotherStar(jewel); } // if (deleteList.Count > 5 && verticalMatch && horizontalMatch) { // fiveInARow.InstantiateMotherStar (jewel); // } foreach (GameObject a in deleteList) { swapJewel.IfJewelSetToNull(a); } deleteJewels.DeleteAllJewelsInList(deleteList, false); //Debug.Log ("deleteList.Count = " + deleteList.Count); } else { dontDelete = false; } if (verticalMatch || horizontalMatch) { ClearLists(); return(true); } else { ClearLists(); return(false); } }
// 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); } } }
// Update is called once per frame void Update() { // if (Mathf.Abs (transform.position.x) > 10 || Mathf.Abs (transform.position.y) > 10) { // corners.GetCornerStarList ().Remove (gameObject); // } if (movementStart && !fireStar) { transform.Translate(new Vector3((oppositeX - transform.position.x) * Time.deltaTime * 5f, (oppositeY - transform.position.y) * Time.deltaTime * 5f), Space.World); if (Mathf.Abs(transform.position.x - oppositeX) < .05f && Mathf.Abs(transform.position.y - oppositeY) < .05f) { fireStar = true; } } if (movementStart && fireStar) { if (!soundPlayed) { soundHandler.PlayPowerShot(); soundPlayed = true; } transform.Translate(new Vector3((targetX - transform.position.x) * Time.deltaTime * .25f, (targetY - transform.position.y) * Time.deltaTime * .25f, 0), Space.World); } // if (Mathf.Abs (transform.position.x) > 99) { // Destroy (gameObject); // } // if (Mathf.Abs (transform.position.y) > 99) { // Destroy (gameObject); // } if (arraysFilled && (Mathf.Abs(transform.position.x) > 10) && (horizontalPositive || horizontalNegative)) { if (positiveHorizontalDeletes != null && positiveHorizontalDeletes.Length >= arrayCount) { corners.GetCornerStarList().Remove(gameObject); Destroy(gameObject); } else if (negativeHorizontalDeletes != null && negativeHorizontalDeletes.Length >= arrayCount) { corners.GetCornerStarList().Remove(gameObject); Destroy(gameObject); } } else if (arraysFilled && (Mathf.Abs(transform.position.y) > 10) && (verticalPositive || verticalNegative)) { if (positiveVerticalDeletes != null && positiveVerticalDeletes.Length >= arrayCount) { corners.GetCornerStarList().Remove(gameObject); Destroy(gameObject); } else if (negativeVerticalDeletes != null && negativeVerticalDeletes.Length >= arrayCount) { corners.GetCornerStarList().Remove(gameObject); Destroy(gameObject); } } if (movementStart && fireStar) { if (!arraysFilled) { FillArrays(); arraysFilled = true; } if (timeForDelete && horizontalPositive && arrayCount < 9 && positiveHorizontalDeletes[arrayCount] != null && transform.position.x > positiveHorizontalDeletes[arrayCount].transform.position.x) { timeForDelete = false; if (IsJewel(gameObject.tag) || IsBomb(gameObject)) { jewelMovement = positiveHorizontalDeletes[arrayCount].GetComponent <RockLevelJewelMovement> (); jewelMovement.StartDestroyCountdown(); } if (positiveHorizontalDeletes[arrayCount] != null) { deleteList.Add(positiveHorizontalDeletes[arrayCount]); deleteJewels.DeleteAllJewelsInList(deleteList, true); } deleteList.Clear(); arrayCount++; } else if (horizontalPositive && arrayCount < 9 && positiveHorizontalDeletes[arrayCount] == null) { arrayCount++; } else { timeForDelete = true; } if (horizontalNegative && arrayCount < 9 && negativeHorizontalDeletes[arrayCount] != null && transform.position.x < negativeHorizontalDeletes[arrayCount].transform.position.x) { if (IsJewel(gameObject.tag) || IsBomb(gameObject)) { jewelMovement = negativeHorizontalDeletes[arrayCount].GetComponent <RockLevelJewelMovement> (); jewelMovement.StartDestroyCountdown(); } if (negativeHorizontalDeletes[arrayCount] != null) { deleteList.Add(negativeHorizontalDeletes[arrayCount]); deleteJewels.DeleteAllJewelsInList(deleteList, true); } deleteList.Clear(); arrayCount++; } else if (horizontalNegative && arrayCount < 9 && negativeHorizontalDeletes[arrayCount] == null) { arrayCount++; } if (timeForDelete && verticalNegative && arrayCount < 9 && negativeVerticalDeletes[arrayCount] != null && transform.position.y < negativeVerticalDeletes[arrayCount].transform.position.y) { timeForDelete = false; if (IsJewel(gameObject.tag) || IsBomb(gameObject)) { jewelMovement = positiveVerticalDeletes[arrayCount].GetComponent <RockLevelJewelMovement> (); jewelMovement.StartDestroyCountdown(); } if (negativeVerticalDeletes != null) { deleteList.Add(negativeVerticalDeletes[arrayCount]); deleteJewels.DeleteAllJewelsInList(deleteList, true); } deleteList.Clear(); arrayCount++; } else if (verticalNegative && arrayCount < 9 && negativeVerticalDeletes[arrayCount] == null) { arrayCount++; } else { timeForDelete = true; } if (verticalPositive && arrayCount < 9 && positiveVerticalDeletes[arrayCount] != null && transform.position.y > positiveVerticalDeletes[arrayCount].transform.position.y) { if (IsJewel(gameObject.tag) || IsBomb(gameObject)) { jewelMovement = negativeVerticalDeletes[arrayCount].GetComponent <RockLevelJewelMovement> (); jewelMovement.StartDestroyCountdown(); } if (positiveVerticalDeletes[arrayCount] != null) { deleteList.Add(positiveVerticalDeletes[arrayCount]); deleteJewels.DeleteAllJewelsInList(deleteList, true); } deleteList.Clear(); arrayCount++; } else if (verticalPositive && arrayCount < 9 && positiveVerticalDeletes[arrayCount] == null) { arrayCount++; } } }
void ExplodeBomb() { 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); }