void createFormation() { // if there is no formation and the timer is greater than or equal to 0.5 if (formation == null && formation2 == null && formation3 == null && timer >= 0.1 && !lifeCount.PCisDestroyed) { //destroy all bullets bulletManager.destroyAllEnemyBullets(); //add one to the formation number if (formationNumber < 13) { formationNumber += 1; } //if the formation number limit is exceeded, reset formation number if (formationNumber >= 13) { formationNumber = 0; formationNumber2 = 0; formationNumber3 = 0; } //create a new formation list Instantiate(formationList[formationNumber], new Vector3(7.6f, 6.5f, 0f), Quaternion.identity); //reset timer timer = 0; #region instantiate formation 2 // if there is no formation and the timer is greater than or equal to 0.5 and the first formation number has gone past 5 if (formationNumber >= 6 && formationNumber < 12) { //create a new formation list Instantiate(formationList2[formationNumber2], new Vector3(7f, 6.5f, 0f), Quaternion.identity); //add one to the formation number if (formationNumber < 12) { formationNumber2 += 1; } } #endregion instantiate formation 2 #region instantiate formation 3 // if there is no formation and the timer is greater than or equal to 0.5 and the first formation number has gone past 5 if (formationNumber >= 3 && formationNumber < 12) { //create a new formation list Instantiate(formationList3[formationNumber3], new Vector3(7.3f, 6.5f, 0f), Quaternion.identity); //add one to the formation number if (formationNumber < 12) { formationNumber3 += 1; } } #endregion instantiate formation 3 } }
void createAnotherButterfly() { #region start the countdown until the PC is respawned //start countdown until a new PCButterfly is made set health to 1000 if (timeTilRespawnActive) { //set the new butterflies health to 1000 scoreHealthLivesCounter.alterHealth(1000); //countdown timeTilRespawn = (timeTilRespawn - (1 * Time.deltaTime)); #region when timer runs out, recreate a PC //when timer runs out, create a new PC and create a new text if (timeTilRespawn <= 0) { //remove all bullets bulletManager.destroyAllEnemyBullets(); //timer set back to one timeTilRespawn = 1; //timer is no longer counting down timeTilRespawnActive = false; //lower life count in this script lives = lives - 1; //instantiate a new gameObejct prefab GameObject PC; PC = Instantiate(newButterfly, startPoint, Quaternion.identity) as GameObject; //now that the butterflyPC has come back, it's time to re-initialize it butterflyPC = GameObject.FindWithTag("Player"); #region set PCisDestroyed back to false if there is a butterflyPC //if there is a butterflyPC if (butterflyPC) { //set PCisDestroyed back to false so that reduceLife can be called the next time the PC disappears PCisDestroyed = false; } #endregion } #endregion } #endregion }
// Update is called once per frame void Update() { entrance(); //when Atlas is out of health if (enemyHeatlh.health <= 0) { //clear bullets bulletManager.destroyAllEnemyBullets(); //disable movement and death enemyHeatlh.enabled = false; spawnEnemy.enabled = false; atlasBullets.enabled = false; //disable soundtrack musicPlayer.audioSource.mute = true; //increase timeBetweenBurst value timeBetweenBurst += 1 * Time.deltaTime; //reduce timeUntilBustsStop timeUntilBurstsStop -= 1 * Time.deltaTime; if (timeUntilBurstsStop <= 3f) { timeToBurst = 0.125f; } if (timeUntilBurstsStop <= 1.5f) { timeToBurst = 0.0625f; } //if the time between bursts has reached half a second if (timeBetweenBurst >= timeToBurst && timeUntilBurstsStop > 0) { //create particles Instantiate(particles, transform.position + new Vector3(Random.Range(-2, 2), Random.Range(-2, 2), 0), Quaternion.identity); //play sound AudioSource.PlayClipAtPoint(poof, transform.position); timeBetweenBurst = 0; } //if its time for the bursts to stop if (timeUntilBurstsStop <= 0) { //enable the disabled scripts spawnEnemy.enabled = true; //play sound AudioSource.PlayClipAtPoint(finalPoof, transform.position); //music player is enabled musicPlayer.audioSource.mute = false; //send points to scoreCounter myScoreCounter.increaseScore(scoreValue); if (spawnEnemy.enabled && !musicPlayer.audioSource.mute) { //destroy Destroy(transform.gameObject); } print("spawn enemy is " + spawnEnemy.enabled); } } }