protected override VisibleAnimationObjectKeyFrame CopyAsVisibleAnimationObjectKeyFrame(AnimationClass.AnimationLayer ActiveLayer) { AnimatedChainKeyFrame NewAnimatedBitmapKeyFrame = new AnimatedChainKeyFrame(); NewAnimatedBitmapKeyFrame.UpdateFrom(this); NewAnimatedBitmapKeyFrame._ChainLengthInPixel = _ChainLengthInPixel; NewAnimatedBitmapKeyFrame.ListChainSplinePoints = new List <Vector2>(ListChainSplinePoints); return(NewAnimatedBitmapKeyFrame); }
public AnimatedChainTimeline(BinaryReader BR, ContentManager Content) : base(BR, TimelineType) { ListCurrentChainSplinePoints = new List <Vector2>(); Origin = new Point(BR.ReadInt32(), BR.ReadInt32()); ChainLinkPath = BR.ReadString(); if (Content != null && !string.IsNullOrEmpty(ChainLinkPath)) { ChainLink = new AnimatedSprite(Content, "Animations/Sprites/" + ChainLinkPath, Vector2.Zero); ChainLink.Origin = new Vector2(BR.ReadSingle(), BR.ReadSingle()); } ChainEndPath = BR.ReadString(); if (Content != null && !string.IsNullOrEmpty(ChainEndPath)) { ChainEnd = new AnimatedSprite(Content, "Animations/Sprites/" + ChainEndPath, Vector2.Zero); ChainEnd.Origin = new Vector2(BR.ReadSingle(), BR.ReadSingle()); } ChainStartPath = BR.ReadString(); if (Content != null && !string.IsNullOrEmpty(ChainStartPath)) { ChainStart = new AnimatedSprite(Content, "Animations/Sprites/" + ChainStartPath, Vector2.Zero); ChainStart.Origin = new Vector2(BR.ReadSingle(), BR.ReadSingle()); } int DicAnimationSpriteKeyFrameCount = BR.ReadInt32(); for (int E = 0; E < DicAnimationSpriteKeyFrameCount; E++) { int Key = BR.ReadInt32(); AnimatedChainKeyFrame NewAnimatedBitmapKeyFrame = new AnimatedChainKeyFrame(BR); DicAnimationKeyFrame.Add(Key, NewAnimatedBitmapKeyFrame); } }
public override void MouseMoveExtra(int KeyFrame, int RealX, int RealY, int MouseChangeX, int MouseChangeY) { AnimatedChainKeyFrame ActiveObjectKeyFrame = (AnimatedChainKeyFrame)CreateOrRetriveKeyFrame(null, KeyFrame); for (int C = 0; C < ActiveObjectKeyFrame.ListChainSplinePoints.Count; C++) { int KeyFrameX = (int)ActiveObjectKeyFrame.ListChainSplinePoints[C].X - 2; int KeyFrameY = (int)ActiveObjectKeyFrame.ListChainSplinePoints[C].Y - 2; if (RealX >= KeyFrameX && RealX < KeyFrameX + 5 && RealY >= KeyFrameY && RealY < KeyFrameY + 5) { ActiveObjectKeyFrame.ListChainSplinePoints[C] = new Vector2(ActiveObjectKeyFrame.ListChainSplinePoints[C].X + MouseChangeX, ActiveObjectKeyFrame.ListChainSplinePoints[C].Y + MouseChangeY); ListCurrentChainSplinePoints[C] = ActiveObjectKeyFrame.ListChainSplinePoints[C]; break; } } base.MouseMoveExtra(KeyFrame, RealX, RealY, MouseChangeX, MouseChangeY); }
public override void UpdateAnimationObject(int KeyFrame) { //An Event is being executed. if (NextEvent != null) { UpdateAnimationSprite(KeyFrame); for (int L = 0; L < NextActiveKeyFrame.ListChainSplinePoints.Count; ++L) { Vector2 Result = NextActiveKeyFrame.ListChainSplinePointsMoveValue[L] * (KeyFrame - EventKeyFrameOld); ListCurrentChainSplinePoints[L] = new Vector2(ListCurrentChainSplinePointsOld[L].X + (int)Result.X, ListCurrentChainSplinePointsOld[L].Y + (int)Result.Y); } } if (ChainLink != null) { ChainLink.Update(ChainLink.FramesPerSecond * (1 / 60f)); if (ChainLink.AnimationEnded) { ChainLink.LoopAnimation(); } } if (ChainEnd != null) { ChainEnd.Update(ChainEnd.FramesPerSecond * (1 / 60f)); if (ChainEnd.AnimationEnded) { ChainEnd.LoopAnimation(); } } if (ChainStart != null) { ChainStart.Update(ChainStart.FramesPerSecond * (1 / 60f)); if (ChainStart.AnimationEnded) { ChainStart.LoopAnimation(); } } AnimatedChainKeyFrame ActiveKeyFrame; VisibleAnimationObjectKeyFrame ActiveAnimationSpriteKeyFrame; if (DicAnimationKeyFrame.TryGetValue(KeyFrame, out ActiveAnimationSpriteKeyFrame)) { ActiveKeyFrame = (AnimatedChainKeyFrame)ActiveAnimationSpriteKeyFrame; //If that animation has already been used, skip it. if (ActiveKeyFrame.IsUsed) { return; } int NextKeyFrame = ActiveKeyFrame.NextKeyFrame; OnNewKeyFrameAnimationSprite(ActiveKeyFrame); CurrentChainLengthInPixel = ActiveKeyFrame.ChainLengthInPixel; ListCurrentChainSplinePoints = new List <Vector2>(ActiveKeyFrame.ListChainSplinePoints); ListCurrentChainSplinePointsOld = new List <Vector2>(ActiveKeyFrame.ListChainSplinePoints); if (DicAnimationKeyFrame.TryGetValue(NextKeyFrame, out ActiveAnimationSpriteKeyFrame)) { NextActiveKeyFrame = (AnimatedChainKeyFrame)ActiveAnimationSpriteKeyFrame; if (NextActiveKeyFrame.IsProgressive) { OnProgressiveNextKeyFrameAnimationSprite(NextActiveKeyFrame, KeyFrame, NextKeyFrame); float KeyFrameChange = KeyFrame - NextKeyFrame; for (int L = 0; L < ActiveKeyFrame.ListChainSplinePoints.Count; ++L) { NextActiveKeyFrame.ListChainSplinePointsMoveValue[L] = new Vector2((ActiveKeyFrame.ListChainSplinePoints[L].X - NextActiveKeyFrame.ListChainSplinePoints[L].X) / KeyFrameChange, (ActiveKeyFrame.ListChainSplinePoints[L].Y - NextActiveKeyFrame.ListChainSplinePoints[L].Y) / KeyFrameChange); } } else { NextEvent = null; } } } }