Beispiel #1
0
    public List <ActionData> MakeFightActionDataList(Divine.BattleActionData action)
    {
        var result = new List <ActionData>();

        foreach (var spell in action.Spell)
        {
            var effectsInfo = new List <SpellEffectInfo>();
            var isCritical  = spell.Effect.Count > 0 && spell.Effect[0].Type == Divine.SpellEffectType.Critical;

            foreach (var effect in spell.Effect)
            {
                var statChanges = new List <SpellSingleStatChangeInfo>();
                var stat        = _curStats[effect.Target];

                int hpChange     = 0;
                int shieldChange = 0;

                foreach (var change in effect.Change)
                {
                    switch (change.Type)
                    {
                    case Divine.StatType.Health:
                        hpChange += change.Value;
                        stat.SetHP(stat.hp + change.Value);
                        break;

                    case Divine.StatType.Shield:
                        shieldChange += change.Value;
                        stat.SetShield(stat.shield + change.Value);
                        break;

                    case Divine.StatType.Attack:
                        statChanges.Add(new SpellSingleStatChangeInfo(
                                            SpellSingleStatChangeType.curDamageValChange,
                                            change.Value));
                        stat.damage += change.Value;
                        break;

                    case Divine.StatType.Flag:
                        statChanges.Add(new SpellSingleStatChangeInfo(
                                            SpellSingleStatChangeType.curFlagValChange,
                                            change.Value));
                        stat.flags = (BattleFlags)change.Value;
                        break;
                    }
                }

                if (hpChange != 0)
                {
                    statChanges.Add(new SpellSingleStatChangeInfo(
                                        SpellSingleStatChangeType.curHPValChange,
                                        hpChange));

                    if (effect.Target > 0 && _curStats.ContainsKey(-effect.Target))
                    {
                        _curStats[-effect.Target].SetHP(_curStats[-effect.Target].hp + hpChange);
                    }
                }

                if (shieldChange != 0)
                {
                    statChanges.Add(new SpellSingleStatChangeInfo(
                                        SpellSingleStatChangeType.curShieldValChange,
                                        shieldChange));
                }

                effectsInfo.Add(new SpellEffectInfo(statChanges, effect.Target, translate(effect.Type), (BattleObjStats)stat.Clone()));
            }

            AppearanceConfigData.MagicAppearanceData appearance;
            int spellIndex;
            if (spell.Spell < 100)
            {
                spellIndex = spell.Spell;
                appearance = AppearanceConfigData.instance.GetMagicWithIndex(_monikers[spell.Attacker], spellIndex);

                if (appearance._multiplePartDamage != null && appearance._multiplePartDamage.Count > 0)
                {
                    effectsInfo = multipart(appearance._multiplePartDamage, effectsInfo);
                }

                var fightAction = new FightActionData();
                fightAction.consumedActionPoint            = spell.ConsumedActionPoint;
                fightAction.ownerID                        = spell.Attacker;
                fightAction.spellInfo.generatedActionPoint = spell.GeneratedActionPoint;

                result.Add(fightAction);
            }
            else if (spell.Spell < 1000)
            {
                spellIndex = spell.Spell - 100;
                var secret = getSide(spell.Attacker).partyInfo.availableSecrets[spellIndex];
                appearance = AppearanceConfigData.instance.GetSecretWithIndex(secret);

                var fightAction = new SecretActionData();
                fightAction.ownerID    = spell.Attacker;
                fightAction._spellInfo = new SpellInfo(
                    spellIndex,
                    true, appearance._dontShowToUser, appearance._needTargetToComeNear,
                    appearance._spellName, appearance._cost, appearance._prefabName,
                    appearance._spellType, appearance._damageType, appearance._spellImpact, effectsInfo);
                fightAction._spellInfo.generatedActionPoint = spell.GeneratedActionPoint;

                result.Add(fightAction);
            }
            else
            {
                var fightAction = new FightActionData();
                fightAction.ownerID   = spell.Attacker;
                fightAction.spellInfo = new SpellInfo(
                    0, false, false, false,
                    PREFAB_DAMAGERETURN, 0, PREFAB_DAMAGERETURN,
                    SpellType.DamageReturn, DamageType.Low, SpellImpactType.None, effectsInfo);

                result.Add(fightAction);
            }
        }

        return(result);
    }
 private void OnBattleActionReceived(Divine.BattleActionData action)
 {
     SpellInfoReceived(analyzer_.MakeFightActionDataList(action));
 }