private void addAbilityButton_Click(object sender, EventArgs e) { AbilitiesForm d = new AbilitiesForm(); if (d.ShowDialog() == DialogResult.OK) { Type abilityType = asm.GetType("Elena." + d.SelectedNode().Name); bool propertyGenerated; MonsterAbility ability; try { ability = (MonsterAbility)Activator.CreateInstance(abilityType); propertyGenerated = true; } catch { propertyGenerated = false; ability = new NullAbility(); } if (propertyGenerated) { if (selectedAbility.IsNull) { monster.AddAbility(ability); } else { monster.AddAbility(ability, selectedAbility); } selectedAbility = new NullAbility(); } this.UpdateData(); } }
private void delAbilButton_Click(object sender, EventArgs e) { if (!selectedAbility.IsNull) { if (selectedAbility.IsBaseAbility()) { monster.Abilities.Remove(selectedAbility); } else { monster.RemoveModifier((AbilityModifier)selectedAbility); } selectedAbility = new NullAbility(); this.UpdateData(); } }
private void abilsList_AfterSelect(object sender, TreeViewEventArgs e) { MonsterAbility a = FindAbilityInTree(abilsList.SelectedNode, abilsList.SelectedNode.Parent); if (a.IsNull != true) { selectedAbility = a; editAbilButton.Enabled = selectedAbility.IsEditable(); } else { selectedAbility = new NullAbility(); editAbilButton.Enabled = false; } }
public void AddAbility(MonsterAbility ability) { if (ability.Prepare(this)) { if (slotsUsed + ability.SlotCost() > slots) { ability.Complain(1); } else { //if it's an actual ability, it'll be inserted as a root node //otherwise, it'll be inserted as a child node of whatever //ability it's modifying if (ability.IsBaseAbility()) { abilities.Add(ability); } else { MonsterAbility parent = ability.GetParent(); parent.AddModifier((AbilityModifier)ability); } } } }
public void AddAbility(MonsterAbility ability, MonsterAbility parent) { bool validToAdd = true; if (validToAdd) { //catch case wherein a modifier is selected if (parent.IsBaseAbility() && !ability.IsBaseAbility()) { ability.SetupParent(parent); if (ability.Prepare(this)) { if (slotsUsed + ability.SlotCost() > slots) { ability.Complain(1); } else { parent.AddModifier((AbilityModifier)ability); } } } else { AddAbility(ability); } } }
public override void SetupParent(MonsterAbility parent) { modifiedAbility = (AbstractAbility)parent; }
public virtual void SetupParent(MonsterAbility parent) { }