Exemplo n.º 1
0
    public IEnumerator InitializeCombat(Fighter[] teamA, Fighter[] teamB, List <GlobalBuffs.GlobalHotDot> globalHotDots, Climate climate)
    {
        StopAllCoroutines();

        this.teamA = RelicManager.instance.CombatStart(teamA);

        this.teamB     = teamB;
        ended          = false;
        currentFighter = null;
        this.climate   = climate;

        if (climate != null)
        {
            climate.Setup();
        }

        //combatUI.InitializeCombat(teamA, teamB);
        combat3Dcontroller.Setup(this.teamA, teamB);
        combat3DUI.InitializeUI(this.teamA, teamB);

        foreach (Fighter f in GetAllFighters())
        {
            f.OnDeath.AddListener(CheckDeath);
        }

        if (ExperienceManager.instance != null)
        {
            ExperienceManager.instance.CalculatePotentialExperience(this);
        }

        StoreAllFightersInSpeedList();
        SortSpeedList();
        CombatSpeedElementManager.instance.SetupPanel(speedList);


        // ------- Events ------ //
        EventManager.CombatEvent eventParam = new EventManager.CombatEvent();
        EventManager.TriggerEvent(EventManager.combatEvents.combatStart, eventParam);

        // --------------------- //

        foreach (GlobalBuffs.GlobalHotDot globalHotDot in globalHotDots)
        {
            if (globalHotDot.combatsLeft > 0)
            {
                if (globalHotDot.affectsAllies)
                {
                    for (int i = 0; i < this.teamA.Length; i++)
                    {
                        var hotdot = new HotDot.HotDotInstance(globalHotDot.hotdot, globalHotDot.hotdot.hotdotID + this.teamA[i].fighterName, null);
                        yield return(StartCoroutine(this.teamA[i].GetDotManager().AddNewHotDot(hotdot)));
                    }
                }
                if (globalHotDot.affectsEnemies)
                {
                    for (int i = 0; i < teamB.Length; i++)
                    {
                        var hotdot = new HotDot.HotDotInstance(globalHotDot.hotdot, globalHotDot.hotdot.hotdotID + teamB[i].fighterName, null);
                        yield return(StartCoroutine(teamB[i].GetDotManager().AddNewHotDot(hotdot)));
                    }
                }
            }
        }

        if (RelicManager.instance != null)
        {
            RelicManager.instance.InitializeAll();
        }

        StartCoroutine(NextTurn());
    }