Ejemplo n.º 1
0
            public static void Save(List <SkillData> CustomDefinitions)
            {
                if (!Directory.Exists(Dir_Definitions))
                {
                    Directory.CreateDirectory(Dir_Definitions);
                }

                var files = Directory.GetFiles(Dir_Definitions);

                if (files.Any())
                {
                    foreach (var file in files)
                    {
                        var    m        = Regex.Match(file, @"definitions\\(.*)", RegexOptions.Singleline);
                        string filename = m.Groups[1].Value;
                        if (CustomDefinitions.FirstOrDefault(x => x.Name == filename.Replace(".bin", "")) == null)
                        {
                            File.Delete((file));
                        }
                    }
                }

                foreach (var definition in CustomDefinitions)
                {
                    try
                    {
                        _SkillData data = Convert_ToStruct(definition);

                        BinaryFile.WriteToFile <_SkillData>(Dir_Definitions + @"\" + data.Name + ".bin", data);
                    }
                    catch
                    {
                    }
                }
            }
Ejemplo n.º 2
0
            private static _SkillData Convert_ToStruct(SkillData Data)
            {
                try
                {
                    _SkillData Struct = new _SkillData();

                    _SkillPower Power = new _SkillPower();
                    Power.IsPrimaryResource = Data.Power.IsPrimaryResource;
                    Power.Name         = Data.Power.Name;
                    Power.PowerSNO     = Data.Power.PowerSNO;
                    Power.ResourceCost = Data.Power.ResourceCost;

                    List <_Rune> Runes = new List <_Rune>();
                    foreach (var rune in Data.Power.Runes)
                    {
                        _Rune newRune = new _Rune();
                        newRune.Name        = rune.Name;
                        newRune.RuneIndex   = rune.RuneIndex;
                        newRune._DamageType = rune._DamageType;

                        Runes.Add(newRune);
                    }

                    Power.Runes = Runes;

                    Struct.Power = Power;

                    Struct.Name = Data.Name;

                    _Rune SelectedRune = new _Rune();
                    SelectedRune.Name        = Data.SelectedRune.Name;
                    SelectedRune.RuneIndex   = Data.SelectedRune.RuneIndex;
                    SelectedRune._DamageType = Data.SelectedRune._DamageType;

                    Struct.SelectedRune = SelectedRune;

                    List <_CastCondition> CastConditions = new List <_CastCondition>();
                    foreach (var condition in Data.CastConditions)
                    {
                        _CastCondition newConditions = new _CastCondition();
                        newConditions.ConditionGroup = condition.ConditionGroup;
                        newConditions.Type           = condition.Type;
                        newConditions.ValueNames     = condition.ValueNames;
                        newConditions.Values         = condition.Values;

                        CastConditions.Add(newConditions);
                    }

                    Struct.CastConditions = CastConditions;


                    return(Struct);
                }
                catch
                {
                    return(default(_SkillData));
                }
            }
Ejemplo n.º 3
0
            private static SkillData Convert_ToClass(_SkillData Data)
            {
                try
                {
                    List <Rune> Runes = new List <Rune>();
                    foreach (var rune in Data.Power.Runes)
                    {
                        Rune newRune = new Rune(rune.Name, rune.RuneIndex, rune._DamageType);

                        Runes.Add(newRune);
                    }

                    SkillPower Power = new SkillPower(Data.Power.PowerSNO, Data.Power.Name, Runes,
                                                      Data.Power.ResourceCost, Data.Power.IsPrimaryResource, false);

                    Rune SelectedRune = new Rune(Data.SelectedRune.Name, Data.SelectedRune.RuneIndex,
                                                 Data.SelectedRune._DamageType);

                    List <CastCondition> CastConditions = new List <CastCondition>();

                    if (Data.CastConditions != null)
                    {
                        foreach (var condition in Data.CastConditions)
                        {
                            CastCondition newCondition = new CastCondition(condition.ConditionGroup, condition.Type,
                                                                           condition.Values, condition.ValueNames);

                            newCondition.comment = condition.comment;
                            newCondition.enabled = condition._enabled;

                            newCondition.version = condition.version;

                            fixCastConditionByVersion(newCondition);

                            CastConditions.Add(newCondition);
                        }
                    }

                    SkillData Class = new SkillData(Power, Data.Name, SelectedRune, CastConditions);

                    return(Class);
                }
                catch
                {
                    return(default(SkillData));
                }
            }
Ejemplo n.º 4
0
            public static List <SkillData> Load()
            {
                try
                {
                    List <SkillData> CustomDefinitions = new List <SkillData>();

                    if (Directory.Exists(Dir_Definitions))
                    {
                        var files = Directory.GetFiles(Dir_Definitions);

                        foreach (var file in files)
                        {
                            bool failed;

                            _SkillData _skilldata = BinaryFile.ReadFromFile <_SkillData>(file, out failed);

                            if (!failed)
                            {
                                SkillData newSkillData = Convert_ToClass(_skilldata);

                                CustomDefinitions.Add(newSkillData);
                            }
                            else
                            {
                                _SkillData_int _skilldata_int = BinaryFile.ReadFromFile <_SkillData_int>(file, out failed);

                                SkillData newSkillData = Convert_ToClass(_skilldata_int);

                                CustomDefinitions.Add(newSkillData);
                            }
                        }
                    }

                    return(CustomDefinitions);
                }
                catch
                {
                    return(new List <SkillData>());
                }
            }