示例#1
0
        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;
            }
        }
示例#2
0
 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);
     }
 }
示例#3
0
 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);
     }
 }
示例#4
0
 public void Animation_OnDispose(IAnimationRigidBody animation)
 {
     RemoveAnimation(animation);
 }
示例#5
0
        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;
            }
        }
示例#6
0
 public void Animation_OnDispose(IAnimationRigidBody animation)
 {
     RemoveAnimation(animation);
 }