/// <summary> /// Starts the transition to a new enemy /// </summary> /// <param name="currentEnemy"> The script of the enemy who was just defeated </param> /// <param name="nextEnemy"> The name of the next enemy's prefab </param> public void StartTransition(BadThing currentEnemy, string nextEnemy) { Physics2D.IgnoreLayerCollision(10, 8, true); transition.SetActive(true); transition.transform.GetChild(0).gameObject.SetActive(false); this.currentEnemy = currentEnemy; this.nextEnemy = nextEnemy; StartCoroutine("WaitToContinue"); }
/// <summary> /// This method spawns funny dog. /// </summary> public void SpawnRecoveryEnemy() { bool transitionActive = FindObjectOfType <EnemyTransitionControl>().transition.activeSelf; bool dennisDie = false; if (FindObjectOfType <CrazyDennis>()) { dennisDie = FindObjectOfType <CrazyDennis>().anim.GetBool("Dead"); } if (!transitionActive && !dennisDie) { //TODO: make this be a lookup table for when we have different recovery enemies and not just Dog BadThing enemy = SpawnNextEnemy("dogy"); if (enemy is Dog dog) //that a funny line { dog.nextEnemy = this.PrefabString(); } } }
/// <summary> /// Gamers don't die, they- /// </summary> /// <returns>All the time you could've spent playing the game if you didn't get hit</returns> private IEnumerator WaitAndRespawn() { if (lives == 1) { FindObjectOfType <MusicManager>().Stop(); } // Activate respawn invincibility (we do this before respawning because // dying again during the death animation would be, like, the worst) Physics2D.IgnoreLayerCollision(10, 8, true); // Restrict movement until the death animation ends GetComponent <Move2D>().enabled = false; rb.velocity = Vector2.zero; // Let the death animation loop for a while yield return(new WaitForSeconds(HURT_TIME)); // The "respawn" part of "wait and respawn" anim.SetBool("Dead x_x", false); GetComponent <Move2D>().enabled = true; StartCoroutine("RespawnInvincibility"); // Stuff that was originally in the Die method lives--; BadThing.DestroyAllBalls(); if (PlayerHurt != null) { PlayerHurt(); } if (lives > 0) { bombs = defaultBombs; GetComponent <Rigidbody2D>().position = defaultPosition; } else { bool transitionActive = FindObjectOfType <EnemyTransitionControl>().transition.activeSelf; bool dennisDie = false; if (FindObjectOfType <CrazyDennis>()) { dennisDie = FindObjectOfType <CrazyDennis>().anim.GetBool("Dead"); } if (!transitionActive && !dennisDie) { bombs = defaultBombs; GetComponent <Rigidbody2D>().position = defaultPosition; if (!inRecovery) { inRecovery = true; lives = 5; } else { // TODO: Actual game over screen thabk } if (PlayerGameOver != null) { PlayerGameOver(); } } else { lives = 1; } } }