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); }
void MakeJewelsBounce() { GameObject a = instantiator.GetJewelGridGameObject(3, 3); RockLevelJewelMovement jewelMovement = a.GetComponent <RockLevelJewelMovement> (); a.GetComponent <Rigidbody2D>().AddForce(new Vector2(0, 300)); jewelMovement.SetBounceAgain(true); jewelMovement.SetBounced(false); a = instantiator.GetJewelGridGameObject(3, 5); jewelMovement = a.GetComponent <RockLevelJewelMovement> (); a.GetComponent <Rigidbody2D>().AddForce(new Vector2(0, 300)); jewelMovement.SetBounceAgain(true); jewelMovement.SetBounced(false); a = instantiator.GetJewelGridGameObject(5, 3); jewelMovement = a.GetComponent <RockLevelJewelMovement> (); a.GetComponent <Rigidbody2D>().AddForce(new Vector2(0, 300)); jewelMovement.SetBounceAgain(true); jewelMovement.SetBounced(false); a = instantiator.GetJewelGridGameObject(5, 5); jewelMovement = a.GetComponent <RockLevelJewelMovement> (); a.GetComponent <Rigidbody2D>().AddForce(new Vector2(0, 300)); jewelMovement.SetBounceAgain(true); jewelMovement.SetBounced(false); }
void FixedUpdate() { if (darkenShade) { if (oldColor.a < .67f) { spriteRenderer.color = new Color(oldColor.r, oldColor.g, oldColor.b, oldColor.a + .02f); oldColor = spriteRenderer.color; } else { MakeJewelsBounce(); timeStamp = Time.time; bounceJewels = true; touchHandler.SetGameStarted(true); matchChecker.SetGameStarted(true); darkenShade = false; } } else if (lightenShade) { if (oldColor.a > 0) { spriteRenderer.color = new Color(oldColor.r, oldColor.g, oldColor.b, oldColor.a - .02f); oldColor = spriteRenderer.color; } else { lightenShade = false; GameObject temp = instantiator.GetJewelGridGameObject(0, 3); temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y, -12); temp = instantiator.GetJewelGridGameObject(1, 3); temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y, -12); temp = instantiator.GetJewelGridGameObject(2, 2); temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y, -12); temp = instantiator.GetJewelGridGameObject(2, 3); temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y, -12); Instantiate(nextTutorialShade); Destroy(gameObject); } } if (bounceJewels && Time.time > timeStamp + cooldown) { timeStamp = Time.time; MakeJewelsBounce(); } }
// 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 (gameStarted && !timeStampReset && Time.time > timeStamp + cooldown) { bombHandler.DecreaseAllBombsInList(); bombHandler.ZeroBombsStillExist(); timeStamp = Time.time; } if (timeStampReset && Time.time > timeStamp + cooldown) { RockLevelJewelMovement jewelMovement; timeStamp = Time.time; for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { jewelMovement = instantiator.GetJewelGridGameObject(i, j).GetComponent <RockLevelJewelMovement> (); if (!jewelMovement.GetBounced()) { return; } } } timeStampReset = false; gameStarted = true; } }
// Use this for initialization void Start() { GetComponent <Rigidbody2D>().AddTorque(-540); deleteList = new HashSet <GameObject> (); deleteJewels = GameObject.Find("Level Controller").GetComponent <RockLevelDeleteJewels> (); instantiator = GameObject.Find("Level Controller").GetComponent <RockLevelInstantiator> (); fourInARow = GameObject.Find("Level Controller").GetComponent <RockLevelFourInARow> (); scoreKeeper = GameObject.Find("Level Controller").GetComponent <RockLevelScoreKeeper> (); jewelToDestroy = instantiator.GetJewelGridGameObject(targetJewelRow, targetJewelCol); controller = GameObject.Find("Level Controller").GetComponent <RockLevelController> (); audioSources = GameObject.Find("SoundHandler").GetComponents <AudioSource>(); soundHandler = GameObject.Find("Game Manager").GetComponent <SoundHandler> (); swapJewel = GameObject.Find("Level Controller").GetComponent <RockLevelSwapJewel> (); if (tag != "End Star") { instantiatedCrosshairs = (GameObject)Instantiate(crosshairs, new Vector3(-2.45f + (targetJewelCol * .6125f), 2.591252f - (targetJewelRow * .6097268f), -90), Quaternion.identity); targetPosition = instantiatedCrosshairs.transform.position; } else { targetPosition = new Vector3(-2.45f + (targetJewelCol * .6125f), 2.591252f - (targetJewelRow * .6097268f), -90); } timeStamp = Time.time; cooldown1 = .25f; cooldown2 = .15f; if (transform.position.y > -.5) { oppositeY = Random.Range(4f, 4.5f); } else { oppositeY = Random.Range(-4f, -4.65f); } oppositeX = Random.Range(-2.5f, 2.5f); }
public void ActivateCornersPowers(GameObject jewel) { deleteJewels.StampTimeCard(); ResetIntsAndBools(); switch (jewel.tag) { case "Green Bomb": case "Green Block": starToInstantiate = greenCornerStar; break; case "Red Bomb": case "Red Block": starToInstantiate = redCornerStar; break; case "Blue Bomb": case "Blue Block": starToInstantiate = blueCornerStar; break; case "White Bomb": case "White Block": starToInstantiate = whiteCornerStar; break; case "Orange Bomb": case "Yellow Block": starToInstantiate = orangeCornerStar; break; case "Purple Bomb": case "Purple Block": starToInstantiate = purpleCornerStar; break; } jewelMovement = jewel.GetComponent <RockLevelJewelMovement> (); if (jewelMovement.GetRow() + 1 < 9 && JewelsAreTheSame(instantiator.GetJewelGridGameObject(jewelMovement.GetRow() + 1, jewelMovement.GetCol()).tag, jewel.tag)) { starNumber++; negativeVerticalStar = true; } if (jewelMovement.GetRow() - 1 >= 0 && JewelsAreTheSame(instantiator.GetJewelGridGameObject(jewelMovement.GetRow() - 1, jewelMovement.GetCol()).tag, jewel.tag)) { starNumber++; positiveVerticalStar = true; } if (jewelMovement.GetCol() + 1 < 9 && JewelsAreTheSame(instantiator.GetJewelGridGameObject(jewelMovement.GetRow(), jewelMovement.GetCol() + 1).tag, jewel.tag)) { starNumber++; positiveHorizontalStar = true; } if (jewelMovement.GetCol() - 1 >= 0 && JewelsAreTheSame(instantiator.GetJewelGridGameObject(jewelMovement.GetRow(), jewelMovement.GetCol() - 1).tag, jewel.tag)) { starNumber++; negativeHorizontalStar = true; } InstantiateCornerStars(jewel); }
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(); }
void GetInitialPosition() { switch (directionInt) { case 0: initialY = 3.45f; initialX = instantiator.GetJewelGridGameObject(targetJewelRow, targetJewelCol).transform.position.x; finalPositionVector = new Vector3(initialX, -100f, transform.position.z); break; case 1: initialY = -3.2f; initialX = instantiator.GetJewelGridGameObject(targetJewelRow, targetJewelCol).transform.position.x; finalPositionVector = new Vector3(initialX, 100f, transform.position.z); break; case 2: initialY = instantiator.GetJewelGridGameObject(targetJewelRow, targetJewelCol).transform.position.y; initialX = 3.2f; finalPositionVector = new Vector3(-100, initialY, transform.position.z); break; case 3: initialY = instantiator.GetJewelGridGameObject(targetJewelRow, targetJewelCol).transform.position.y; initialX = -3.2f; finalPositionVector = new Vector3(100, initialY, transform.position.z); break; } initialPositionVector = new Vector3(initialX, initialY, transform.position.z); }
// 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 DarkenShade() { GameObject tempJewel = instantiator.GetJewelGridGameObject(2, 1); tempJewel.transform.position = (new Vector3(tempJewel.transform.position.x, tempJewel.transform.position.y, -12)); tempJewel = instantiator.GetJewelGridGameObject(2, 2); tempJewel.transform.position = (new Vector3(tempJewel.transform.position.x, tempJewel.transform.position.y, -12)); tempJewel = instantiator.GetJewelGridGameObject(2, 3); tempJewel.transform.position = (new Vector3(tempJewel.transform.position.x, tempJewel.transform.position.y, -12)); tempJewel = instantiator.GetJewelGridGameObject(2, 4); tempJewel.transform.position = (new Vector3(tempJewel.transform.position.x, tempJewel.transform.position.y, -12)); tempJewel = instantiator.GetJewelGridGameObject(1, 2); tempJewel.transform.position = (new Vector3(tempJewel.transform.position.x, tempJewel.transform.position.y, -12)); darkenShade = true; }
// Use this for initialization void Start() { instantiator = GameObject.Find("Level Controller").GetComponent <RockLevelInstantiator> (); deleteJewels = GameObject.Find("Level Controller").GetComponent <RockLevelDeleteJewels> (); row = Random.Range(1, 8); col = Random.Range(1, 8); targetJewel = instantiator.GetJewelGridGameObject(row, col); targetPositon = new Vector3(startingLeftJewelPosition + (horizontalMultiplier * col), 2.591258f - (.61f * row), (-1 * row) - 2); targetXPosition = targetPositon.x; targetYPosition = targetPositon.y; rigidBody = GetComponent <Rigidbody2D> (); rigidBody.AddForce(new Vector2(0, 1000)); rigidBody.AddTorque(Random.Range(-10000, 10000)); }
void MakeJewelsBounce() { RockLevelInstantiator instantiator = GameObject.Find("Level Controller").GetComponent <RockLevelInstantiator> (); GameObject a = instantiator.GetJewelGridGameObject(4, 2); RockLevelJewelMovement jewelMovement = a.GetComponent <RockLevelJewelMovement> (); a.GetComponent <Rigidbody2D>().AddForce(new Vector2(0, 300)); jewelMovement.SetBounceAgain(true); jewelMovement.SetBounced(false); a = instantiator.GetJewelGridGameObject(3, 3); jewelMovement = a.GetComponent <RockLevelJewelMovement> (); a.GetComponent <Rigidbody2D>().AddForce(new Vector2(0, 300)); jewelMovement.SetBounceAgain(true); jewelMovement.SetBounced(false); a = instantiator.GetJewelGridGameObject(4, 4); jewelMovement = a.GetComponent <RockLevelJewelMovement> (); a.GetComponent <Rigidbody2D>().AddForce(new Vector2(0, 300)); jewelMovement.SetBounceAgain(true); jewelMovement.SetBounced(false); }
// Update is called once per frame void Update() { if (Time.time > floatingJewelCooldown + floatingJewelTimestamp) { floatingJewelTimestamp = Time.time; if (instantiator.GetJewelGridGameObject(row, col) != gameObject && !swapJewel.IsASwapJewel(gameObject) && shuffleGameboard.GetShuffleFinished() && tag != "Slug Meal" && !jewelFalling) { Debug.Log("Destroying Floating Jewel"); Destroy(gameObject); } } if (shuffleJewel) { if (transform.position.y < -10) { Destroy(gameObject); } // if (!shufflePositionSet) { // firstTargetPosition = new Vector3 ((-2.45f + (.6125f * col)), Random.Range (3.5f, 4.5f), 0); // shufflePositionSet = true; // } // transform.Translate (new Vector3 (firstTargetPosition.x - transform.position.x, firstTargetPosition.y - transform.position.y, 0) * Time.deltaTime * 6f); // if (Mathf.Abs (firstTargetPosition.x - transform.position.x) < .005f && Mathf.Abs (firstTargetPosition.y - transform.position.y) < .005f) { // transform.position = (new Vector3 (firstTargetPosition.x, firstTargetPosition.y, ((-1 * row) - 2))); // rigidbody2D.isKinematic = false; // shuffleJewel = false; // shufflePositionSet = false; // } } // if (destroyJewelCountdown && Time.time >= timeStamp + cooldown) { // //Debug.Log ("DESTROYING FLOATING JEWEL"); // Destroy (gameObject); // } }
// Use this for initialization void Start() { deleteList = new HashSet <GameObject> (); deleteRowArray = new GameObject[9]; //Debug.Log ("deleteRowArray.Length = " + deleteRowArray.Length); GetComponent <Rigidbody2D>().AddTorque(-540); instantiator = GameObject.Find("Level Controller").GetComponent <RockLevelInstantiator> (); deleteJewels = GameObject.Find("Level Controller").GetComponent <RockLevelDeleteJewels> (); soundHandler = GameObject.Find("Game Manager").GetComponent <SoundHandler> (); directionInt = Random.Range(0, 4); targetJewelRow = Random.Range(0, 9); targetJewelCol = Random.Range(0, 9); while (instantiator.GetJewelGridGameObject(targetJewelRow, targetJewelCol).GetComponent <RockLevelJewelMovement> ().GetMoving()) { targetJewelRow = Random.Range(0, 9); targetJewelCol = Random.Range(0, 9); } GetInitialPosition(); moveToInitialPosition = true; }
void InstantiateBombSeekingChildStars() { GameObject randomBomb = bombHandler.GetRandomBomb(); if (randomBomb == null) { InstantiateChildStars(); return; } instantiatedStar = (GameObject)Instantiate(childStar, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, -15), Quaternion.identity); childStarMovement = instantiatedStar.GetComponent <RockLevelChildStarMovement> (); row = randomBomb.GetComponent <RockLevelJewelMovement> ().GetRow(); col = randomBomb.GetComponent <RockLevelJewelMovement> ().GetCol(); while (instantiator.GetJewelGridGameObject(row, col) == null) { row = Random.Range(0, 9); col = Random.Range(0, 9); } jewelMovement = instantiator.GetJewelGridGameObject(row, col).GetComponent <RockLevelJewelMovement> (); while (jewelMovement.GetMoving() || jewelList.Contains(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> (); } childStarMovement = instantiatedStar.GetComponent <RockLevelChildStarMovement> (); childStarArray.Add(instantiatedStar); fiveInARow.GetChildStarList().Add(instantiatedStar); jewelList.Add(instantiator.GetJewelGridGameObject(row, col)); instantiatedTarget = (GameObject)Instantiate(target, new Vector3(-2.45f + (col * .6125f), 2.591252f - (row * .6097268f), -23), Quaternion.identity); childStarMovement.SetTargetPosition(instantiator.GetJewelGridGameObject(row, col).transform.position, row, col, instantiatedTarget); }
void FixedUpdate() { if (darkenShade) { if (instantiateOwlie) { instantiateOwlie = false; instantiatedOwlieSwapper = (GameObject)Instantiate(owlieSwapper); instantiatedSpeechBubble = (GameObject)Instantiate(speechBubble, new Vector3(-10, 3.59f, -11.9f), Quaternion.identity); instantiatedSpeechBubble.GetComponent <LevelFailedScreenSlider> ().SetTargetX(-.94f); currentOwlie = (GameObject)Instantiate(owlie, new Vector3(-10, 1.8f, -50), Quaternion.identity); currentOwlie.GetComponent <LevelFailedScreenSlider> ().SetTargetX(1.75f); instantiatedOwlieSwapper.GetComponent <OwlieSwapper> ().SetCurrentOwlie(currentOwlie); } if (oldColor.a < .67f) { spriteRenderer.color = new Color(oldColor.r, oldColor.g, oldColor.b, oldColor.a + .02f); oldColor = spriteRenderer.color; } else { MakeJewelsBounce(); timeStamp = Time.time; bounceJewels = true; touchHandler.SetGameStarted(true); matchChecker.SetGameStarted(true); darkenShade = false; } } else if (lightenShade) { if (oldColor.a > 0) { spriteRenderer.color = new Color(oldColor.r, oldColor.g, oldColor.b, oldColor.a - .02f); oldColor = spriteRenderer.color; } else { GameObject temp = instantiator.GetJewelGridGameObject(4, 4); temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y, -51); temp = instantiator.GetJewelGridGameObject(5, 4); temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y, -50.99f); temp = instantiator.GetJewelGridGameObject(6, 4); temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y, -51); temp = instantiator.GetJewelGridGameObject(7, 4); temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y, -51); temp = instantiator.GetJewelGridGameObject(5, 5); temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y, -51); temp = instantiator.GetJewelGridGameObject(5, 6); temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y, -51); lightenShade = false; Instantiate(nextTutorialShade); Destroy(gameObject); } } if (bounceJewels && Time.time > timeStamp + cooldown) { timeStamp = Time.time; MakeJewelsBounce(); } }
void FixedUpdate() { if (darkenShade) { if (instantiateOwlie) { instantiateOwlie = false; instantiatedOwlieSwapper = (GameObject)Instantiate(owlieSwapper); instantiatedSpeechBubble = (GameObject)Instantiate(speechBubble, new Vector3(-10, 3.74f, -11.9f), Quaternion.identity); instantiatedSpeechBubble.GetComponent <LevelFailedScreenSlider> ().SetTargetX(-.94f); currentOwlie = (GameObject)Instantiate(owlie, new Vector3(-10, 2.28f, -11.9f), Quaternion.identity); currentOwlie.GetComponent <LevelFailedScreenSlider> ().SetTargetX(1.75f); instantiatedOwlieSwapper.GetComponent <OwlieSwapper> ().SetCurrentOwlie(currentOwlie); } if (oldColor.a < .67f) { spriteRenderer.color = new Color(oldColor.r, oldColor.g, oldColor.b, oldColor.a + .02f); oldColor = spriteRenderer.color; } else { MakeJewelsBounce(); timeStamp = Time.time; bounceJewels = true; touchHandler.SetGameStarted(true); matchChecker.SetGameStarted(true); darkenShade = false; darkened = true; } } else if (lightenShade) { if (oldColor.a > 0) { spriteRenderer.color = new Color(oldColor.r, oldColor.g, oldColor.b, oldColor.a - .02f); oldColor = spriteRenderer.color; } else { GameObject temp = instantiator.GetJewelGridGameObject(3, 3); temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y, -2); temp = instantiator.GetJewelGridGameObject(3, 5); temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y, -2f); temp = instantiator.GetJewelGridGameObject(5, 3); temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y, -2); temp = instantiator.GetJewelGridGameObject(5, 5); temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y, -2); lightenShade = false; PlayerPrefs.SetInt("Level Four Tutorial Played", 1); GameObject.Find("Level Controller").GetComponent <RockLevelMatchAssistant> ().SetTutorialLevel(false); // Instantiate (nextTutorialShade); Destroy(gameObject); } } if (bounceJewels && Time.time > timeStamp + cooldown) { timeStamp = Time.time; MakeJewelsBounce(); } }
private void InstantiateHomingStar(GameObject star, GameObject jewel) { if (tutorialLevel2) { InstantiateTutorialTwoHomingStar(star, jewel); return; } GameObject instantiatedStar = (GameObject)Instantiate(star, new Vector3(jewel.transform.position.x, jewel.transform.position.y, -49), Quaternion.identity); homingStarMovement = instantiatedStar.GetComponent <RockLevelHomingStarMovement> (); jewelMovement = jewel.GetComponent <RockLevelJewelMovement> (); random1 = Random.Range(0, 9); random2 = Random.Range(0, 9); if (instantiator.GetJewelGridGameObject(random1, random2) != null) { jewelMovement2 = instantiator.GetJewelGridGameObject(random1, random2).GetComponent <RockLevelJewelMovement> (); } while (IsBomb(instantiator.GetJewelGridGameObject(random1, random2).tag) || instantiator.GetJewelGridGameObject(random1, random2) == null || (random1 == jewelMovement.GetRow() && random2 == jewelMovement.GetCol()) || checkForMatches.deleteList.Contains(instantiator.GetJewelGridGameObject(random1, random2)) || jewelMovement2.GetMoving() || !targetJewels.Add(instantiator.GetJewelGridGameObject(random1, random2))) { random1 = Random.Range(0, 9); random2 = Random.Range(0, 9); if (instantiator.GetJewelGridGameObject(random1, random2) != null) { jewelMovement2 = instantiator.GetJewelGridGameObject(random1, random2).GetComponent <RockLevelJewelMovement> (); } } homingStarMovement.SetRow(random1); homingStarMovement.SetCol(random2); homingStarMovement.SetFourInARowStar(); homingStarList.Add(instantiatedStar); }
public void DarkenShade() { if (PlayerPrefs.HasKey("Level Four Tutorial Played")) { touchHandler.SetGameStarted(true); matchChecker.SetGameStarted(true); Destroy(gameObject); } darkenShade = true; GameObject temp = instantiator.GetJewelGridGameObject(2, 4); temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y, -12); temp = instantiator.GetJewelGridGameObject(3, 4); temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y, -12f); temp = instantiator.GetJewelGridGameObject(5, 4); temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y, -12); temp = instantiator.GetJewelGridGameObject(6, 4); temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y, -12); temp = instantiator.GetJewelGridGameObject(4, 2); temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y, -12); temp = instantiator.GetJewelGridGameObject(4, 3); temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y, -12); temp = instantiator.GetJewelGridGameObject(4, 5); temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y, -12); temp = instantiator.GetJewelGridGameObject(4, 6); temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y, -12); }
// 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); }
public void MoveSlug() { if (move || beingDeleted) { return; } directionCount = 0; movementDirection = GetRandomSlugDirection(); if (jewelMovement == null) { jewelMovement = GetComponent <RockLevelJewelMovement> (); } row = jewelMovement.GetRow(); col = jewelMovement.GetCol(); oldRow = row; oldCol = col; directionCount = 0; do { if (movementDirection == slugDirection.up) { if (row - 1 >= 0 && instantiator.GetJewelGridGameObject(row - 1, col) != null && IsJewel(instantiator.GetJewelGridGameObject(row - 1, col)) && instantiator.GetJewelGridGameObject(row - 1, col).name != "Slug Meal" && !swapJewel.IsASwapJewel(instantiator.GetJewelGridGameObject(row - 1, col))) { instantiator.GetJewelGridGameObject(row - 1, col).tag = "Slug Meal"; tempBoulder = (GameObject)Instantiate(currentBoulder, new Vector3(transform.position.x, transform.position.y, -.5f), Quaternion.identity); tempBoulder.GetComponent <RockLevelJewelMovement> ().SetBounced(true); tempBoulder.layer = gameObject.layer; tempBoulder.GetComponent <RockLevelJewelMovement> ().SetRow(row); tempBoulder.GetComponent <RockLevelJewelMovement> ().SetCol(col); instantiator.AddToJewelGrid(tempBoulder, row, col); targetX = transform.position.x; targetY = transform.position.y + .61f; jewelMovement.SetRow(row - 1); row--; destructionJewel = instantiator.GetJewelGridGameObject(row, col); instantiator.AddToJewelGrid(gameObject, row, col); gameObject.GetComponent <Rigidbody2D> ().isKinematic = true; transform.position = (new Vector3(transform.position.x, transform.position.y, -20)); move = true; return; } movementDirection = slugDirection.right; } else if (movementDirection == slugDirection.right) { if (col + 1 < 9 && instantiator.GetJewelGridGameObject(row, col + 1) != null && IsJewel(instantiator.GetJewelGridGameObject(row, col + 1)) && instantiator.GetJewelGridGameObject(row, col + 1).name != "Slug Meal" && !swapJewel.IsASwapJewel(instantiator.GetJewelGridGameObject(row, col + 1))) { instantiator.GetJewelGridGameObject(row, col + 1).tag = "Slug Meal"; tempBoulder = (GameObject)Instantiate(currentBoulder, new Vector3(transform.position.x, transform.position.y, -.5f), Quaternion.identity); tempBoulder.GetComponent <RockLevelJewelMovement> ().SetBounced(true); tempBoulder.layer = gameObject.layer; tempBoulder.GetComponent <RockLevelJewelMovement> ().SetRow(row); tempBoulder.GetComponent <RockLevelJewelMovement> ().SetCol(col); instantiator.AddToJewelGrid(tempBoulder, row, col); targetX = transform.position.x + .6125f; targetY = transform.position.y; jewelMovement.SetCol(col + 1); col++; destructionJewel = instantiator.GetJewelGridGameObject(row, col); instantiator.AddToJewelGrid(gameObject, row, col); gameObject.GetComponent <Rigidbody2D> ().isKinematic = true; transform.position = (new Vector3(transform.position.x, transform.position.y, -20)); move = true; return; } movementDirection = slugDirection.down; } else if (movementDirection == slugDirection.down) { if (row + 1 < 9 && instantiator.GetJewelGridGameObject(row + 1, col) != null && IsJewel(instantiator.GetJewelGridGameObject(row + 1, col)) && instantiator.GetJewelGridGameObject(row + 1, col).name != "Slug Meal" && !swapJewel.IsASwapJewel(instantiator.GetJewelGridGameObject(row + 1, col))) { instantiator.GetJewelGridGameObject(row + 1, col).tag = "Slug Meal"; tempBoulder = (GameObject)Instantiate(currentBoulder, new Vector3(transform.position.x, transform.position.y, -.5f), Quaternion.identity); tempBoulder.GetComponent <RockLevelJewelMovement> ().SetBounced(true); tempBoulder.layer = gameObject.layer; tempBoulder.GetComponent <RockLevelJewelMovement> ().SetRow(row); tempBoulder.GetComponent <RockLevelJewelMovement> ().SetCol(col); instantiator.AddToJewelGrid(tempBoulder, row, col); targetX = transform.position.x; targetY = transform.position.y - .61f; jewelMovement.SetRow(row + 1); row++; destructionJewel = instantiator.GetJewelGridGameObject(row, col); instantiator.AddToJewelGrid(gameObject, row, col); gameObject.GetComponent <Rigidbody2D> ().isKinematic = true; transform.position = (new Vector3(transform.position.x, transform.position.y, -20)); move = true; return; } movementDirection = slugDirection.left; } else if (movementDirection == slugDirection.left) { if (col - 1 >= 0 && instantiator.GetJewelGridGameObject(row, col - 1) != null && IsJewel(instantiator.GetJewelGridGameObject(row, col - 1)) && instantiator.GetJewelGridGameObject(row, col - 1).name != "Slug Meal" && !swapJewel.IsASwapJewel(instantiator.GetJewelGridGameObject(row, col - 1))) { instantiator.GetJewelGridGameObject(row, col - 1).tag = "Slug Meal"; tempBoulder = (GameObject)Instantiate(currentBoulder, new Vector3(transform.position.x, transform.position.y, -.5f), Quaternion.identity); tempBoulder.GetComponent <RockLevelJewelMovement> ().SetBounced(true); tempBoulder.layer = gameObject.layer; tempBoulder.GetComponent <RockLevelJewelMovement> ().SetRow(row); tempBoulder.GetComponent <RockLevelJewelMovement> ().SetCol(col); instantiator.AddToJewelGrid(tempBoulder, row, col); targetX = transform.position.x - .6125f; targetY = transform.position.y; jewelMovement.SetCol(col - 1); col--; destructionJewel = instantiator.GetJewelGridGameObject(row, col); instantiator.AddToJewelGrid(gameObject, row, col); gameObject.GetComponent <Rigidbody2D> ().isKinematic = true; transform.position = (new Vector3(transform.position.x, transform.position.y, -20)); move = true; return; } movementDirection = slugDirection.up; } directionCount++; } while (directionCount < 4); MoveNonJewelDirection(); }
private void KeepBombsAndRocksTheSame() { for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { if (IsBomb(instantiator.GetJewelGridGameObject(i, j)) || instantiator.GetJewelGridGameObject(i, j).tag == "Boulder" || instantiator.GetJewelGridGameObject(i, j).tag == "Steel Block") { tempJewelGrid[i, j] = instantiator.GetJewelGridGameObject(i, j); } } } }
public void SetTargetRowAndCol(int row, int col) { this.targetRow = row; this.targetCol = col; targetPosition = new Vector3(startingLeftJewelPosition + (horizontalMultiplier * col), 2.591258f - (.61f * row), (-1 * row) - 2); targetJewel = instantiator.GetJewelGridGameObject(row, col); }
// 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 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); } } } }
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 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); } }
public void FindMatchForPlayer() { if (!gameStarted || tutorialLevel) { return; } if (resetRandoms) { randomRow = Random.Range(0, 9); randomCol = Random.Range(0, 9); resetRandoms = false; } originalRow = randomRow; originalCol = randomCol; for (int j = randomCol; j < 9; j++) { if (CheckForSwipeUpHorizontalMatch(randomRow, j, instantiator.GetJewelGridGameObject(randomRow, j))) { return; } if (CheckForSwipeDownHorizontalMatch(randomRow, j, instantiator.GetJewelGridGameObject(randomRow, j))) { return; } if (CheckForSwipeUpVerticalMatch(randomRow, j, instantiator.GetJewelGridGameObject(randomRow, j))) { return; } if (CheckForSwipeDownVerticalMatch(randomRow, j, instantiator.GetJewelGridGameObject(randomRow, j))) { return; } if (CheckForSwipeLeftVerticalMatch(randomRow, j, instantiator.GetJewelGridGameObject(randomRow, j))) { return; } if (CheckForSwipeRightVerticalMatch(randomRow, j, instantiator.GetJewelGridGameObject(randomRow, j))) { return; } if (CheckForSwipeLeftHorizontalMatch(randomRow, j, instantiator.GetJewelGridGameObject(randomRow, j))) { return; } if (CheckForSwipeRightHorizontalMatch(randomRow, j, instantiator.GetJewelGridGameObject(randomRow, j))) { return; } } for (int i = randomRow + 1; i < 9; i++) { for (int j = 0; j < 9; j++) { if (CheckForSwipeUpHorizontalMatch(i, j, instantiator.GetJewelGridGameObject(i, j))) { return; } if (CheckForSwipeDownHorizontalMatch(i, j, instantiator.GetJewelGridGameObject(i, j))) { return; } if (CheckForSwipeUpVerticalMatch(i, j, instantiator.GetJewelGridGameObject(i, j))) { return; } if (CheckForSwipeDownVerticalMatch(i, j, instantiator.GetJewelGridGameObject(i, j))) { return; } if (CheckForSwipeLeftVerticalMatch(i, j, instantiator.GetJewelGridGameObject(i, j))) { return; } if (CheckForSwipeRightVerticalMatch(i, j, instantiator.GetJewelGridGameObject(i, j))) { return; } if (CheckForSwipeLeftHorizontalMatch(i, j, instantiator.GetJewelGridGameObject(i, j))) { return; } if (CheckForSwipeRightHorizontalMatch(i, j, instantiator.GetJewelGridGameObject(i, j))) { return; } } } for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { if (CheckForSwipeUpHorizontalMatch(i, j, instantiator.GetJewelGridGameObject(i, j))) { return; } if (CheckForSwipeDownHorizontalMatch(i, j, instantiator.GetJewelGridGameObject(i, j))) { return; } if (CheckForSwipeUpVerticalMatch(i, j, instantiator.GetJewelGridGameObject(i, j))) { return; } if (CheckForSwipeDownVerticalMatch(i, j, instantiator.GetJewelGridGameObject(i, j))) { return; } if (CheckForSwipeLeftVerticalMatch(i, j, instantiator.GetJewelGridGameObject(i, j))) { return; } if (CheckForSwipeRightVerticalMatch(i, j, instantiator.GetJewelGridGameObject(i, j))) { return; } if (CheckForSwipeLeftHorizontalMatch(i, j, instantiator.GetJewelGridGameObject(i, j))) { return; } if (CheckForSwipeRightHorizontalMatch(i, j, instantiator.GetJewelGridGameObject(i, j))) { return; } if (i == originalRow && j == originalCol) { //Debug.Log ("NO POSSIBLE MOVES SON!!!"); return; } } } }