Пример #1
0
        private void lbItems_SelectedIndexChanged(object sender, EventArgs e)
        {
            int     id      = getIDfromListBox();
            cEffect cEffect = cImport.EffectData.Find(p => p.ID.Equals(id));

            if (cEffect != null)
            {
                tbName.Text = cEffect.Name;
                tbNote.Text = cEffect.Note;

                getItemsWithEffect(cEffect.Name);
                getTitlesWithEffect(cEffect.Name);
                getMonstersWithEffect(cEffect.Name);
                getSkillsWithEffect(cEffect.Name);
            }
        }
Пример #2
0
 public void AddEffect(eEffectType type)
 {
     cEffect tempEffect = new cEffect();
     tempEffect.Initialize(type);
     m_lAllEffects.Add(tempEffect);
 }
Пример #3
0
        public static void GetEffects(string fileDir = null)
        {
            string effectConfigName = "effect-data.json";

            if (string.IsNullOrEmpty(fileDir) && Path.GetExtension(fileDir) == ".json")
            {
                try
                {
                    dynamic effectJsonFile = JsonConvert.DeserializeObject(File.ReadAllText(effectConfigName));

                    cEffect cEffect = new cEffect
                    {
                        ID   = effectJsonFile.ID,
                        Name = effectJsonFile.effectName,
                        Note = effectJsonFile.effectNote
                    };

                    // cEffectStructure.UsedByItemID = effectJsonFile.effectUsedByItem;
                    // cEffectStructure.UsedByTitleID = effectJsonFile.effectUsedByTitle;
                }
                catch
                {
                    //
                }
            }
            else
            {
                if (Path.GetExtension(fileDir) == ".txt") //read effect names with \n on end of the line
                {
                    EffectData = new List <cEffect>();

                    int index = 1;
                    Parallel.ForEach(File.ReadLines(fileDir), new ParallelOptions {
                        MaxDegreeOfParallelism = 1
                    }, line =>
                    {
                        if (line.Contains("_"))
                        {
                            string[] lineSplitted = (line.Contains("\t") ? line : line + "\t").Split('\t');

                            cEffect cEffect = new cEffect
                            {
                                ID   = index,
                                Name = lineSplitted[0],
                                Note = lineSplitted[1]
                            };

                            EffectData.Add(cEffect);
                        }
                        index++;
                    });
                }
                else if (Path.GetExtension(fileDir) == ".json")
                {
                    try
                    {
                        dynamic effectJsonFile = JsonConvert.DeserializeObject(File.ReadAllText(fileDir));

                        cEffect cEffect = new cEffect
                        {
                            Name = effectJsonFile.effectName,
                            Note = effectJsonFile.effectNote
                        };
                    }
                    catch
                    {
                        //
                    }
                }
            }
        }