// sets the animation parameters for this uielement // start is the start position of the animation. if null, it uses the current position of the element // end is the end position of the animation. if null, it uses the current position of the element // animation is the animation delegate to use. if null, it uses the old animation delegate. // if the old delegate is null, returns false and this uielement is not animation ready public bool SetAnimation(Vector2 start, Vector2 end, CritterCamp.Core.Lib.Helpers.Animation animation) { if (start == null) { StartAnimationPosition = Position; } else { StartAnimationPosition = start; } if (end == null) { EndAnimationPosition = Position; } else { EndAnimationPosition = end; } if (animation == null) { if (AnimationDel == null) { return false; } } else { AnimationDel = animation; } AnimationReady = true; // set this uielement ready to animate return true; }
// sets the animation parameters for this uielement. // if startAtCurrent is true, then the animation is from start to start+offset // otherwise, the animation is from start+offset to start public virtual bool SetAnimationOffset(Vector2 offset, CritterCamp.Core.Lib.Helpers.Animation animation, bool startAtCurrent) { if (startAtCurrent) { return SetAnimation(Position, Position + offset, animation); } else { return SetAnimation(Position + offset, Position, animation); } }
// sets the offset for all the elements in this view public override bool SetAnimationOffset(Vector2 offset, CritterCamp.Core.Lib.Helpers.Animation animation, bool startAtCurrent) { bool result = true; lock (UIElements) { // pass on the animation parameters to all the children result &= base.SetAnimationOffset(offset, animation, startAtCurrent); foreach (UIElement uie in UIElements) { result &= uie.SetAnimationOffset(offset, animation, startAtCurrent); } } return result; }