private void button_AddEffect_Click(object sender, EventArgs e) { if (comboBox_Effects.SelectedItem != null) { s_effect effect = new s_effect(); effect.effectName = comboBox_Effects.SelectedItem.ToString(); listBox_Effects.Items.Add(effect.effectName); effect = addSettingsToEffect(effect); effect.conditions = new List <s_condition>(); instances[listBox_Enemys.SelectedIndex].effects.Add(effect); } }
private s_effect addSettingsToEffect(s_effect _effect) { string line; _effect.effectSettings = new List <s_settings>(); // Read the file and display it line by line. System.IO.StreamReader file = new System.IO.StreamReader(textBox_GamePfade.Text + "\\effects\\scripts\\StatusEffect.gd"); while ((line = file.ReadLine()) != null) { if (line.Contains("export")) { s_settings set = new s_settings(); set.valueType = line.Substring(line.IndexOf('(') + 1, line.IndexOf(')') - (line.IndexOf('(') + 1)); int varEnd = line.IndexOf("var") + 4; set.settingName = line.Substring(varEnd, (line.IndexOf(' ', varEnd) > 0 ? line.IndexOf(' ', varEnd) : line.Length) - varEnd); _effect.effectSettings.Add(set); } } file.Close(); try { file = new System.IO.StreamReader(textBox_GamePfade.Text + "\\effects\\scripts\\" + _effect.effectName.Substring(0, _effect.effectName.Length - 4) + "gd"); while ((line = file.ReadLine()) != null) { if (line.Contains("export")) { s_settings set = new s_settings(); set.valueType = line.Substring(line.IndexOf('(') + 1, line.IndexOf(')') - (line.IndexOf('(') + 1)); int varEnd = line.IndexOf("var") + 4; set.settingName = line.Substring(varEnd, (line.IndexOf(' ', varEnd) > 0 ? line.IndexOf(' ', varEnd) : line.Length) - varEnd); _effect.effectSettings.Add(set); } } file.Close(); } catch { } return(_effect); }