Пример #1
0
        public void Load(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            var             file = new ContentFile();
            List <IPackage> packages;

            try
            {
                file     = (ContentFile)_contentManager.GetContentFileFromJson("Stats", name);
                packages = new List <IPackage>(_contentManager.GetAllLoadedPackages());
            }
            catch (ContentNotFoundException exception)
            {
                _logger.Warn(exception.Message);
                return;
            }

            BaseHp                       = file.GetFloat("Data", "BaseHP", BaseHp);
            BaseMp                       = file.GetFloat("Data", "BaseMP", BaseMp);
            BaseDamage                   = file.GetFloat("Data", "BaseDamage", BaseDamage);
            AttackRange                  = file.GetFloat("Data", "AttackRange", AttackRange);
            MoveSpeed                    = file.GetInt("Data", "MoveSpeed", MoveSpeed);
            Armor                        = file.GetFloat("Data", "Armor", Armor);
            SpellBlock                   = file.GetFloat("Data", "SpellBlock", SpellBlock);
            BaseStaticHpRegen            = file.GetFloat("Data", "BaseStaticHPRegen", BaseStaticHpRegen);
            BaseStaticMpRegen            = file.GetFloat("Data", "BaseStaticMPRegen", BaseStaticMpRegen);
            AttackDelayOffsetPercent     = file.GetFloat("Data", "AttackDelayOffsetPercent", AttackDelayOffsetPercent);
            AttackDelayCastOffsetPercent = file.GetFloat("Data", "AttackDelayCastOffsetPercent", AttackDelayCastOffsetPercent);
            HpPerLevel                   = file.GetFloat("Data", "HPPerLevel", HpPerLevel);
            MpPerLevel                   = file.GetFloat("Data", "MPPerLevel", MpPerLevel);
            DamagePerLevel               = file.GetFloat("Data", "DamagePerLevel", DamagePerLevel);
            ArmorPerLevel                = file.GetFloat("Data", "ArmorPerLevel", ArmorPerLevel);
            SpellBlockPerLevel           = file.GetFloat("Data", "SpellBlockPerLevel", SpellBlockPerLevel);
            HpRegenPerLevel              = file.GetFloat("Data", "HPRegenPerLevel", HpRegenPerLevel);
            MpRegenPerLevel              = file.GetFloat("Data", "MPRegenPerLevel", MpRegenPerLevel);
            AttackSpeedPerLevel          = file.GetFloat("Data", "AttackSpeedPerLevel", AttackSpeedPerLevel);
            IsMelee                      = file.GetString("Data", "IsMelee", IsMelee ? "true" : "false").Equals("true");
            PathfindingCollisionRadius   =
                file.GetFloat("Data", "PathfindingCollisionRadius", PathfindingCollisionRadius);
            GameplayCollisionRadius = file.GetFloat("Data", "GameplayCollisionRadius", GameplayCollisionRadius);
            Enum.TryParse <PrimaryAbilityResourceType>(file.GetString("Data", "PARType", ParType.ToString()),
                                                       out var tempPar);
            ParType = tempPar;

            for (var i = 0; i < 4; i++)
            {
                SpellNames[i] = file.GetString("Data", $"Spell{i + 1}", SpellNames[i]);
            }

            for (var i = 0; i < 4; i++)
            {
                SpellsUpLevels[i] = file.GetIntArray("Data", $"SpellsUpLevels{i + 1}", SpellsUpLevels[i]);
            }

            MaxLevels = file.GetIntArray("Data", "MaxLevels", MaxLevels);
            for (var i = 0; i < 8; i++)
            {
                ExtraSpells[i] = file.GetString("Data", $"ExtraSpell{i + 1}", ExtraSpells[i]);
            }

            for (var i = 0; i < 6; i++)
            {
                Passives[i].PassiveNameStr     = file.GetString("Data", $"Passive{i + 1}Name", Passives[i].PassiveNameStr);
                Passives[i].PassiveAbilityName = PassiveData.GetPassiveAbilityNameFromScriptFile(name, packages);
                Passives[i].PassiveLevels      = file.GetMultiInt("Data", $"Passive{i + 1}Level", 6, -1);
            }
        }
Пример #2
0
        public void Load(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            var file = new ContentFile();

            try
            {
                var path = _game.Config.ContentManager.GetUnitStatPath(name);
                _logger.Debug($"Loading {name}'s Stats  from path: {Path.GetFullPath(path)}!");
                var text = File.ReadAllText(Path.GetFullPath(path));
                file = JsonConvert.DeserializeObject <ContentFile>(text);
            }
            catch (ContentNotFoundException notfound)
            {
                _logger.Warn($"Stats for {name} was not found: {notfound.Message}");
                return;
            }

            BaseHp                     = file.GetFloat("Data", "BaseHP", BaseHp);
            BaseMp                     = file.GetFloat("Data", "BaseMP", BaseMp);
            BaseDamage                 = file.GetFloat("Data", "BaseDamage", BaseDamage);
            AttackRange                = file.GetFloat("Data", "AttackRange", AttackRange);
            MoveSpeed                  = file.GetInt("Data", "MoveSpeed", MoveSpeed);
            Armor                      = file.GetFloat("Data", "Armor", Armor);
            SpellBlock                 = file.GetFloat("Data", "SpellBlock", SpellBlock);
            BaseStaticHpRegen          = file.GetFloat("Data", "BaseStaticHPRegen", BaseStaticHpRegen);
            BaseStaticMpRegen          = file.GetFloat("Data", "BaseStaticMPRegen", BaseStaticMpRegen);
            AttackDelayOffsetPercent   = file.GetFloat("Data", "AttackDelayOffsetPercent", AttackDelayOffsetPercent);
            HpPerLevel                 = file.GetFloat("Data", "HPPerLevel", HpPerLevel);
            MpPerLevel                 = file.GetFloat("Data", "MPPerLevel", MpPerLevel);
            DamagePerLevel             = file.GetFloat("Data", "DamagePerLevel", DamagePerLevel);
            ArmorPerLevel              = file.GetFloat("Data", "ArmorPerLevel", ArmorPerLevel);
            SpellBlockPerLevel         = file.GetFloat("Data", "SpellBlockPerLevel", SpellBlockPerLevel);
            HpRegenPerLevel            = file.GetFloat("Data", "HPRegenPerLevel", HpRegenPerLevel);
            MpRegenPerLevel            = file.GetFloat("Data", "MPRegenPerLevel", MpRegenPerLevel);
            AttackSpeedPerLevel        = file.GetFloat("Data", "AttackSpeedPerLevel", AttackSpeedPerLevel);
            IsMelee                    = file.GetString("Data", "IsMelee", IsMelee ? "Yes" : "No").Equals("yes");
            PathfindingCollisionRadius =
                file.GetFloat("Data", "PathfindingCollisionRadius", PathfindingCollisionRadius);
            GameplayCollisionRadius = file.GetFloat("Data", "GameplayCollisionRadius", GameplayCollisionRadius);
            Enum.TryParse <PrimaryAbilityResourceType>(file.GetString("Data", "PARType", ParType.ToString()),
                                                       out var tempPar);
            ParType = tempPar;

            for (var i = 0; i < 4; i++)
            {
                SpellNames[i] = file.GetString("Data", $"Spell{i + 1}", SpellNames[i]);
            }

            for (var i = 0; i < 4; i++)
            {
                SpellsUpLevels[i] = file.GetIntArray("Data", $"SpellsUpLevels{i + 1}", SpellsUpLevels[i]);
            }

            MaxLevels = file.GetIntArray("Data", "MaxLevels", MaxLevels);
            for (var i = 0; i < 8; i++)
            {
                ExtraSpells[i] = file.GetString("Data", $"ExtraSpell{i + 1}", ExtraSpells[i]);
            }

            for (var i = 0; i < 6; i++)
            {
                Passives[i].PassiveNameStr = file.GetString("Data", $"Passive{i + 1}Name", Passives[i].PassiveNameStr);
                Passives[i].PassiveLuaName =
                    file.GetString("Data", $"Passive{i + 1}LuaName", Passives[i].PassiveLuaName);
                Passives[i].PassiveLevels = file.GetMultiInt("Data", $"Passive{i + 1}Level", 6, -1);
            }
        }