Beispiel #1
0
    private CharInfo MakeCharatcerInfo(WBattleUnitData unit, bool isHero)
    {
        BattleObjStats stats = new BattleObjStats(unit.health,
                                                  unit.maxHealth,
                                                  unit.attack,
                                                  unit.shield, unit.maxShield);

        var spellInfoList = new List <SpellInfo>();

        for (int i = 0; i < unit.spell.Length; i++)
        {
            var appearance = AppearanceConfigData.instance.GetMagicWithIndex(unit.moniker, unit.spell[i].index);

            spellInfoList.Add(new SpellInfo(
                                  i,
                                  appearance._isInstant, appearance._dontShowToUser, appearance._needTargetToComeNear,
                                  appearance._spellName, unit.spell[i].need_ap, appearance._prefabName,
                                  appearance._spellType, appearance._damageType, appearance._spellImpact, null));

            string spellParams = unit.spell[i].spell_params == null ? "" : unit.spell[i].spell_params.ToString();
            spellInfoList[i].SetSpellParams(spellParams);
        }

        if (isHero)
        {
            HeroInfo heroInf = new HeroInfo(
                unit.moniker,
                stats,
                spellInfoList,
                unit.dexterity,
                0, unit.level, unit.id, 0, 0, new NextUpgradeStats(), unit.is_active);

            heroInf.SetHeroItemsForBattle(unit.items);

            return(heroInf);
        }
        else
        {
            var troop = new CharInfo(
                unit.moniker,
                stats,
                spellInfoList,
                unit.dexterity,
                0, unit.level, unit.id, 0, 0, new NextUpgradeStats(), Divine.Moniker.Unknown, unit.is_active);

            return(troop);
        }
    }