Esempio n. 1
0
    void TryTransitionToFightPhase()
    {
        if (boardController.gameStatus != GameStatus.Fight && boardController.gameStatus != GameStatus.ReportDefeat && boardController.gameStatus == GameStatus.Shopping && playerController.currentlyDeployedUnits > 0) // check if we are ready to proceed to combat
        {
            boardController.ChangeGameStatus(GameStatus.Wait);                                                                                                                                                           // smooth wait transition
            npcController.allyListBackup = new List <NPC>();
            boardController.SpawnEnemyUnitsRound_Balanced();                                                                                                                                                             // spawn balanced enemies

            if (playerController.newPlayer && boardController.currentGameRound == 1)
            {
                if (currentLanguage == Language.English)
                {
                    dialogueTriggerSystem.tutorialDialogue2_English.TriggerDialogue();
                }
                else if (currentLanguage == Language.Spanish)
                {
                    dialogueTriggerSystem.tutorialDialogue2_Spanish.TriggerDialogue();
                }
            }
            else if (playerController.newPlayer && boardController.currentGameRound == 3)
            {
                if (currentLanguage == Language.English)
                {
                    dialogueTriggerSystem.tutorialDialogue3_English.TriggerDialogue();
                }
                else if (currentLanguage == Language.Spanish)
                {
                    dialogueTriggerSystem.tutorialDialogue3_Spanish.TriggerDialogue();
                }
            }
            else if (boardController.currentGameRound == 6)
            {
                if (currentLanguage == Language.English)
                {
                    dialogueTriggerSystem.bossDialogue1_English.TriggerDialogue();
                }
                else if (currentLanguage == Language.Spanish)
                {
                    dialogueTriggerSystem.bossDialogue1_Spanish.TriggerDialogue();
                }
            }
            else if (boardController.currentGameRound == 12)
            {
                if (currentLanguage == Language.English)
                {
                    dialogueTriggerSystem.bossDialogue2_English.TriggerDialogue();
                }
                else if (currentLanguage == Language.Spanish)
                {
                    dialogueTriggerSystem.bossDialogue2_Spanish.TriggerDialogue();
                }
            }
            else if (boardController.currentGameRound == 20)
            {
                if (currentLanguage == Language.English)
                {
                    dialogueTriggerSystem.bossDialogue3_English.TriggerDialogue();
                }
                else if (currentLanguage == Language.Spanish)
                {
                    dialogueTriggerSystem.bossDialogue3_Spanish.TriggerDialogue();
                }
            }

            if (UnityEngine.Random.Range(0, 7) == 1)
            {
                boardController.rainSystem.SetActive(!boardController.rainSystem.activeSelf);
                if (boardController.rainSystem.activeSelf)
                {
                    boardController.ambienceSound.PlayRainLoop();
                }
                else
                {
                    boardController.ambienceSound.StopPlaying();
                }
            }

            for (int i = npcController.deployedAllyList.Count - 1; i >= 0; i--) // copy the human player unit deployment so we can restore it after combat
            {
                if (npcController.deployedAllyList[i] != null)
                {
                    npcController.deployedAllyList[i].enabled = false;
                    GameObject obj = Instantiate(npcController.deployedAllyList[i].transform.parent.gameObject); // make a copy of our units and store them out of sight so we can restore them after combat
                    npcController.allyListBackup.Add(obj.GetComponentInChildren <NPC>());
                    obj.transform.position = Vector3.up * 1000;
                    obj.name = npcController.deployedAllyList[i].transform.parent.gameObject.name;
                    npcController.deployedAllyList[i].enabled = true;

                    if (UnityEngine.Random.Range(0, 2) == 0 && npcController.deployedAllyList[i].battleCry_SoundClip != null)
                    {
                        npcController.deployedAllyList[i].npcAudioSource.PlayOneShot(npcController.deployedAllyList[i].battleCry_SoundClip);
                    }
                }
            }

            foreach (NPC npc in npcController.deployedAllyList)
            {
                sessionLogger.IncrementTribesDeployedToFightCounters(npc);
            }
            foreach (GameObject lootDrop in boardController.DroppedItemList)
            {
                GameObject.Destroy(lootDrop);
            }

            sessionLogger.unitsDeployedToFight += npcController.deployedAllyList.Count;
            combatTimerPanel.gameObject.SetActive(true); // toggle the combat timer panel

            hudCanvasAudioSource.PlayOneShot(fightStartAudioClip);

            StartCoroutine(SmoothRoundFightPhaseTransition()); // finally we can transition to combat phase.
        }
        else
        {
            hudCanvasAudioSource.PlayOneShot(genericButtonFailureAudioClip);
        }
    }