public void SwapIfInChildStarList(GameObject oldBomb, GameObject newBomb) { foreach (GameObject a in childStarList) { RockLevelChildStarMovement childStarMovement = a.GetComponent <RockLevelChildStarMovement> (); if (childStarMovement.GetJewelToDestroy() == oldBomb) { childStarMovement.SetJewelToDestroy(newBomb); return; } } }
// Update is called once per frame void Update() { if (!instantiateChildStars) { transform.Translate((targetX - transform.position.x) * .1f, (targetY - transform.position.y) * .1f, 0, Space.World); } if (!instantiateChildStars && Mathf.Abs(targetX - transform.position.x) < .05f && Mathf.Abs(targetY - transform.position.y) < .05f) { instantiateChildStars = true; timeStamp = Time.time; moveRight = true; } if (instantiateChildStars && childStarCount < 12) { childStarCount++; if (!tutorialLevel && powerPercentageController.IsWithinPercentage() && !bombInstantiated) { bombInstantiated = true; InstantiateBombSeekingChildStars(); } else { InstantiateChildStars(); } timeStamp = Time.time; if (childStarCount == 12) { cooldown = .4f; timeStamp = Time.time; startDecent = true; } } if (startDecent && Time.time > timeStamp + cooldown) { foreach (GameObject a in childStarArray) { childStarMovement = a.GetComponent <RockLevelChildStarMovement> (); childStarMovement.StartDecent(); } soundHandler.PlayPowerShot(); fiveInARow.GetMotherStarList().Remove(gameObject); Destroy(gameObject); } }
void InstantiateChildStars() { instantiatedStar = (GameObject)Instantiate(childStar, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, -15), Quaternion.identity); childStarMovement = instantiatedStar.GetComponent <RockLevelChildStarMovement> (); if (!tutorialLevel) { row = Random.Range(0, 9); col = Random.Range(0, 9); while (IsBomb(instantiator.GetJewelGridGameObject(row, col).tag) || instantiator.GetJewelGridGameObject(row, col) == null) { row = Random.Range(0, 9); col = Random.Range(0, 9); } jewelMovement = instantiator.GetJewelGridGameObject(row, col).GetComponent <RockLevelJewelMovement> (); while (IsBomb(instantiator.GetJewelGridGameObject(row, col).tag) || 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> (); } } else { InstantiateTutorailChildStars(); jewelMovement = instantiator.GetJewelGridGameObject(row, col).GetComponent <RockLevelJewelMovement> (); } childStarMovement = instantiatedStar.GetComponent <RockLevelChildStarMovement> (); // childStarMovement.StartDecent (); // jewelMovement.targetForExplosion (); 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 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); }