/// <summary> /// Removes a child ModelComponent from the UnitList if it is contained by this. Fires /// off an UnitRemovedEvent. /// </summary> /// <param name="child"></param> public override void RemoveChild(ModelComponent child) { base.RemoveChild(child); if (UnitRemovedEvent != null && child is UnitComponent) { UnitRemovedEventArgs args = new UnitRemovedEventArgs(); args.Unit = (UnitComponent)child; UnitRemovedEvent(this, args); } }
/// <summary> /// Trigger function in the event of unit being removed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void onUnitRemoved(object sender, UnitRemovedEventArgs e) { e.Unit.MovedEventHandlers -= updateLocationOfUnit; e.Unit.HPChangedEventHandlers -= killUnit; }
/// <summary> /// Trigger function in the event of unit being removed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void onUnitRemoved(object sender, UnitRemovedEventArgs e) { /** UnitUI component = (UnitUI)componentToUI[e.Unit]; component.Dispose(); RemoveChild(component); componentToUI.Remove(e.Unit); * */ e.Unit.MovedEventHandlers -= updateLocationOfUnit; e.Unit.HPChangedEventHandlers -= killUnit; }