Пример #1
0
    public void SpawnEncounter(BattleEncounter encounter, bool campfireSurprise)
    {
        MonsterFormation.LoadParty(encounter);
        for (int i = 0; i < MonsterParty.Units.Count; i++)
        {
            var monster = MonsterParty.Units[i].Character as Monster;
            MonsterParty.Units[i].CombatInfo.PrepareForBattle(PickId(), monster, true);
            if (monster.TorchlightModifier != null)
            {
                RaidSceneManager.TorchMeter.Modify(monster.TorchlightModifier);
            }
            RaidSceneManager.TorchMeter.ApplyBuffsForUnit(MonsterParty.Units[i]);
            if (monster.Data.BattleBackdrop != null)
            {
                backdrop.Activate(monster.Data.BattleBackdrop);
            }
            #region Spawn Check
            if (monster.Data.Spawn != null)
            {
                for (int k = 0; k < monster.Data.Spawn.Effects.Count; k++)
                {
                    for (int j = 0; j < monster.Data.Spawn.Effects[k].SubEffects.Count; j++)
                    {
                        monster.Data.Spawn.Effects[k].SubEffects[j].ApplyInstant(MonsterParty.Units[i],
                                                                                 MonsterParty.Units[i], monster.Data.Spawn.Effects[k]);
                    }
                }
                MonsterParty.Units[i].OverlaySlot.UpdateOverlay();
            }
            #endregion
        }
        var shared = MonsterParty.Units.Find(unit => unit.Character.SharedHealth != null);
        if (shared != null)
        {
            SharedHealth.Initialize(MonsterParty.Units, shared.Character.SharedHealth);
        }
        MonsterFormation.overlay.UpdateOverlay();

        SurpriseStatus = SurpriseStatus.Nothing;

        if (MonsterFormation.AlwaysSurprises() || campfireSurprise)
        {
            SurpriseStatus = SurpriseStatus.HeroesSurprised;
        }
        else if (MonsterFormation.AlwaysBeSurprised())
        {
            SurpriseStatus = SurpriseStatus.MonstersSurprised;
        }
        else
        {
            if (MonsterFormation.CanBeSurprised())
            {
                float monstersSurprised = 0.1f + RaidSceneManager.TorchMeter.CurrentRange.MonstersSurprised;
                for (int i = 0; i < HeroParty.Units.Count; i++)
                {
                    monstersSurprised += HeroParty.Units[i].Character[AttributeType.MonsterSurpirseChance].ModifiedValue;
                }
                monstersSurprised = Mathf.Clamp(monstersSurprised, 0, 0.65f);
                if (RandomSolver.CheckSuccess(monstersSurprised))
                {
                    SurpriseStatus = SurpriseStatus.MonstersSurprised;
                }
            }

            if (MonsterFormation.CanSurprise() && SurpriseStatus == SurpriseStatus.Nothing)
            {
                float heroesSurprised = 0.1f + RaidSceneManager.TorchMeter.CurrentRange.HeroesSurprised;
                for (int i = 0; i < HeroParty.Units.Count; i++)
                {
                    heroesSurprised += HeroParty.Units[i].Character[AttributeType.PartySurpriseChance].ModifiedValue;
                }
                heroesSurprised = Mathf.Clamp(heroesSurprised, 0, 0.65f);
                if (RandomSolver.CheckSuccess(heroesSurprised))
                {
                    SurpriseStatus = SurpriseStatus.HeroesSurprised;
                }
            }
        }
        Round.StartBattle(this);
    }