private IEnumerator triggerOnDrawnEffectsCoroutine() { //wait for cards to be done moving around yield return(EnemyHandScript.instance.waitForReady()); yield return(PlayerHandScript.instance.waitForReady()); if (wave.isSurvivorWave == false) { //effects if (wave.enemyData.effectData != null) { foreach (IEffect ie in wave.enemyData.effectData.effects) { if (ie.triggersAs(EffectType.cardDrawn)) { ((IEffectInstant)ie).trigger(); } } } //wave messages if (wave.message != null && wave.message != "") { MessageHandlerScript.ShowNoYield(wave.message); } } }
[Show] private IEnumerator saveDecks() { yield return(DeckManagerScript.instance.StartCoroutine(MessageHandlerScript.PromptYesNo("Are you sure you want to save these decks?"))); if (MessageHandlerScript.responseToLastPrompt == "Yes") { Save(curPath); Debug.Log("Decks Saved."); } }
//Dev: shows a button in the inspector to save the card types, provided there are some loaded [Show][VisibleWhen("areTypesLoaded")] private System.Collections.IEnumerator saveCardChanges() { yield return(StartCoroutine(MessageHandlerScript.PromptYesNo("Are you sure you want to overwrite the card definitions?"))); if (MessageHandlerScript.responseToLastPrompt == "Yes") { types.Save(Path.Combine(Application.streamingAssetsPath, path)); Debug.Log("Card changes saved. <UNMODDED CARDS ONLY!>"); } }
private IEnumerator saveScores() { yield return(ScoreManagerScript.instance.StartCoroutine(MessageHandlerScript.PromptYesNo("Are you sure you want to save these scores?"))); if (MessageHandlerScript.responseToLastPrompt == "Yes") { Save(Path.Combine(Application.persistentDataPath, "playerScores.xml")); Debug.Log("Scores Saved."); } }
/// <summary> /// [COROUTINE] handles player death /// </summary> public IEnumerator playerDead() { //stop music LevelManagerScript.instance.musicSource.Stop(); //score report yield return(MessageHandlerScript.ShowAndYield("GAME OVER!\n" + ScoreManagerScript.instance.report(false, LevelManagerScript.instance.endurance))); //reload UnityEngine.SceneManagement.SceneManager.LoadScene("Game"); yield break; }
/// <summary> /// if a level is loaded, asks the player if they want to quit it /// </summary> /// <returns></returns> private IEnumerator quitPromptCoroutine() { if (LevelManagerScript.instance.levelLoaded) { yield return(StartCoroutine(MessageHandlerScript.ShowPauseMenu())); if (MessageHandlerScript.responseToLastPrompt == "Quit Level") { SceneManager.LoadScene("Game"); } else if (MessageHandlerScript.responseToLastPrompt == "Quit Game") { Application.Quit(); } } }
//init private void Start() { messageBox.SetActive(false); messageText.text = "No Message."; buttonA.SetActive(false); buttonB.SetActive(false); buttonC.SetActive(false); buttonD.SetActive(false); //load volume settings, if present, or use defaults if not SFXSliderComponent.value = PlayerPrefs.GetFloat("SFX Volume", 0.75f); MusicSliderComponent.value = PlayerPrefs.GetFloat("Music Volume", 0.75f); SFXMuteToggleComponent.isOn = (PlayerPrefs.GetInt("SFX Mute", 0) == 1); MusicMuteToggleComponent.isOn = (PlayerPrefs.GetInt("Music Mute", 0) == 1); instance = this; }
//handles all buttons in the editor that only have text attached. public void TextButtonSelected(string text) { //Debug.Log("TextButtonSelected"); //DEBUG ONLY //text contains the text of the button that was clicked, so we use a case statement to differentiate between buttons switch (text) { case "-": //this is a stray message actually intended for DeckEditorCurrentDeckScript, so we can ignore it break; case "+": //this is a stray message actually intended for DeckEditorCurrentDeckScript, so we can ignore it break; case "New Deck": //user wants to make a new deck saveChanges(); //save any unsaved changes openDeck = new XMLDeck(); //make a new deck newDeck = true; //flag this deck as new so that any changes to it get saved as a new deck BroadcastMessage("refresh", openDeck); //inform the lists break; case "Save and return to menu": //user wants to close the editor saveChanges(); //save any unsaved changes SceneManager.LoadScene("Game"); //go back to the game scene break; case "Generate Random Deck": //user wants to get a randomly created deck unsavedChanges = true; //there are no unsaved changes openDeck = DeckManagerScript.instance.generateRandomDeck(); //make a new deck newDeck = true; //flag it as new so that any changes to it get saved as a new deck BroadcastMessage("refresh", openDeck); //show the new deck break; case "Settings": //player wants to see the settings menu StartCoroutine(MessageHandlerScript.ShowSettingsMenu()); break; default: //button has not been implemented. Print warning. Debug.LogError("DeckEditorMainScript doesn't know how to respond to this button"); break; } }
/// <summary> /// [COROUTINE] spawns all of the incoming waves /// </summary> private IEnumerator spawnWaves() { //start the waves foreach (WaveData d in EnemyHandScript.instance.IncomingWaves) { StartCoroutine(spawnWave(d)); yield return(new WaitForSeconds(0.1f)); } //wait for them to finish while (wavesSpawning > 0) { yield return(null); } //wait for all monsters to be dead while (true) { yield return(new WaitForSeconds(1.0f)); if (wavesSpawning <= 0) { if (GameObject.FindGameObjectsWithTag("Enemy").Length == 0) { break; } } } PlayerHandScript.instance.SendMessage("Show"); //show the hand //find all towers in the level and tell them a wave ended GameObject[] towers = GameObject.FindGameObjectsWithTag("Tower"); foreach (GameObject t in towers) { t.SendMessage("WaveOver"); } //draw yield return(new WaitForSeconds(1.0f)); PlayerHandScript.instance.drawCard(); //cull null entries from the survivor list to avoid a very rare bug where enemies die after leaving the map if (EnemyManagerScript.instance.survivors != null) { EnemyManagerScript.instance.survivors.RemoveAll(es => es == null); } //if there are any survivors, draw a new survivor card to represent them if ((EnemyManagerScript.instance.survivors != null) && (EnemyManagerScript.instance.survivors.Count > 0)) { EnemyHandScript.instance.drawCard(true, true, true, true); } else if ( //if there were no survivors... (wavesInDeck == 0) && //and there are no more enemies in the deck... (EnemyHandScript.instance.currentHandSize == 0) && //and the enemy hand is empty... (LevelManagerScript.instance.endurance == false)) //and we are not in endurance... { //then the player wins! //tell user they won and wait for them to answer yield return(StartCoroutine(MessageHandlerScript.ShowAndYield("Level Complete!\n" + ScoreManagerScript.instance.report(true, false)))); //prompt user to continue in endurance yield return(StartCoroutine(MessageHandlerScript.PromptYesNo("Continue in endurance?"))); if (MessageHandlerScript.responseToLastPrompt == "Yes") { LevelManagerScript.instance.endurance = true; //if player wants to, then set it to endurance and keep going } else { UnityEngine.SceneManagement.SceneManager.LoadScene("Game"); //if not, then restart the scene yield break; } } //draw a new enemy card EnemyHandScript.instance.drawCard(); //fire event RoundOverEvent(); //update stats for the next wave UpdateWaveStats(); }