Exemplo n.º 1
0
    [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.");
        }
    }
Exemplo n.º 2
0
    //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!>");
        }
    }
Exemplo n.º 3
0
    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.");
        }
    }
Exemplo n.º 4
0
    /// <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();
    }