public void AddAnimation(IAnimationRigidBody animation, string name = null) { if (name != null) { animation.Name = name; } if ((animation.Name ?? "").Equals("")) { animation.Name = "Ani" + "::" + animation.GetHashCode().ToString(); } int i = Animations.IndexOf(animation); if (i < 0) { Animations.Add(animation); } else { Animations[i] = animation; } animation.Sprite = this; animation.SetTimingSource(TimingSource.Sources.Manual); animation.IsActive = Animated; if ((animation is IAnimKeyInput) && (_parentContainer != null)) { var kani = animation as IAnimKeyInput; _parentContainer.WindowKeyDown += kani.OnKeyDown; _parentContainer.WindowKeyUp += kani.OnKeyUp; } }
public void RemoveAnimation(IAnimationRigidBody animation) { try { if ((animation is IAnimKeyInput) && (_parentContainer != null)) { var kani = animation as IAnimKeyInput; _parentContainer.WindowKeyDown -= kani.OnKeyDown; _parentContainer.WindowKeyUp -= kani.OnKeyUp; } Animations.Remove(animation); } catch (Exception e) { Debug.WriteLine("Animation {0} not present in {1}.", animation.Name, Name); } }
public void Animation_OnDispose(IAnimationRigidBody animation) { RemoveAnimation(animation); }
public void AddAnimation(IAnimationRigidBody animation, string name = null) { if (name != null) animation.Name = name; if ((animation.Name ?? "").Equals("")) animation.Name = "Ani" + "::" + animation.GetHashCode().ToString(); int i = Animations.IndexOf(animation); if (i < 0) Animations.Add(animation); else Animations[i] = animation; animation.Sprite = this; animation.SetTimingSource(TimingSource.Sources.Manual); animation.IsActive = Animated; if ((animation is IAnimKeyInput) && (_parentContainer != null)) { var kani = animation as IAnimKeyInput; _parentContainer.WindowKeyDown += kani.OnKeyDown; _parentContainer.WindowKeyUp += kani.OnKeyUp; } }