public GunNozzleTimeline(BinaryReader BR, RobotAnimation Owner) : base(BR, TimelineType) { Origin = new Point(Width / 2, Height / 2); this.Owner = Owner; if (Owner != null) { this.OwnerWeapon = Owner.ActiveAddedWeapon; } _SpawnFrame = BR.ReadInt32(); _DeathFrame = BR.ReadInt32(); _ShootSecondaryWeapon = BR.ReadBoolean(); int DicAnimationSpriteKeyFrameCount = BR.ReadInt32(); for (int E = 0; E < DicAnimationSpriteKeyFrameCount; E++) { int Key = BR.ReadInt32(); VisibleAnimationObjectKeyFrame NewAnimatedBitmapKeyFrame = new VisibleAnimationObjectKeyFrame(BR); DicAnimationKeyFrame.Add(Key, NewAnimatedBitmapKeyFrame); } }
public CollisionBoxTimeline(BinaryReader BR, RobotAnimation Owner) : base(BR, TimelineType) { this.Owner = Owner; int ListCollisionPolygonCount = BR.ReadInt32(); ListCollisionPolygon = new List <Polygon>(ListCollisionPolygonCount); ListOriginalPolygon = new List <Polygon>(); for (int P = ListCollisionPolygonCount - 1; P >= 0; --P) { Polygon NewPolygon = new Polygon(BR, 1, 1); ListCollisionPolygon.Add(new Polygon(NewPolygon)); ListOriginalPolygon.Add(new Polygon(NewPolygon)); } ComputeSourceRectangle(); Origin = new Point(Width / 2, Height / 2); int DicAnimationSpriteKeyFrameCount = BR.ReadInt32(); for (int E = 0; E < DicAnimationSpriteKeyFrameCount; E++) { int Key = BR.ReadInt32(); VisibleAnimationObjectKeyFrame NewAnimatedBitmapKeyFrame = new VisibleAnimationObjectKeyFrame(BR); DicAnimationKeyFrame.Add(Key, NewAnimatedBitmapKeyFrame); } }
public SpriteSheetTimeline(BinaryReader BR, ContentManager Content) : base(BR, TimelineType) { SpriteSheetName = BR.ReadString(); SourceRectangle = new Rectangle(); SourceRectangle.X = BR.ReadInt32(); SourceRectangle.Y = BR.ReadInt32(); SourceRectangle.Width = BR.ReadInt32(); SourceRectangle.Height = BR.ReadInt32(); int DicAnimationSpriteKeyFrameCount = BR.ReadInt32(); for (int E = 0; E < DicAnimationSpriteKeyFrameCount; E++) { int Key = BR.ReadInt32(); VisibleAnimationObjectKeyFrame NewAnimatedBitmapKeyFrame = new VisibleAnimationObjectKeyFrame(BR); DicAnimationKeyFrame.Add(Key, NewAnimatedBitmapKeyFrame); } if (Content != null) { SpriteSheet = Content.Load <Texture2D>("Animations/Sprite Sheets/" + SpriteSheetName); } Origin = new Point(Width / 2, Height / 2); }
public ParticleEmitterTimeline(BinaryReader BR, ContentManager Content) : base(BR, TimelineType) { Matrix view = Matrix.Identity; Matrix Projection = Matrix.CreateOrthographicOffCenter(0, 800, 600, 0, 0, 1); Matrix HalfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0); Projection = view * (HalfPixelOffset * Projection); Particle3DSample.ParticleSettings ParticleSettings = new Particle3DSample.ParticleSettings(); ParticleSettings.TextureName = BR.ReadString(); ParticleSettings.MaxParticles = 20000; ParticleSettings.MinScale = new Vector2(1, 1); ParticleSettings.DurationInSeconds = 1d; ParticleSettings.Gravity = new Vector2(0, 0); ParticleSettings.NumberOfImages = 16; ParticleSettings.BlendState = BlendState.AlphaBlend; ParticleSettings.StartingAlpha = 0.7f; ParticleSettings.EndAlpha = 0.1f; _SpawnOffset = new Vector2(BR.ReadSingle(), BR.ReadSingle()); _SpawnOffsetRandom = new Vector2(BR.ReadSingle(), BR.ReadSingle()); SpawnSpeed = new Vector2(BR.ReadSingle(), BR.ReadSingle()); SpawnSpeedRandom = new Vector2(BR.ReadSingle(), BR.ReadSingle()); ParticlesPerSeconds = BR.ReadDouble(); ParticleSettings.DurationInSeconds = BR.ReadSingle(); float SpeedMultiplier = BR.ReadSingle(); ParticleSettings.NumberOfImages = BR.ReadInt32(); ParticleSettings.Gravity = new Vector2(BR.ReadSingle(), BR.ReadSingle()); Vector2 Size = new Vector2(BR.ReadSingle(), BR.ReadSingle()); ParticleSettings.MinScale = new Vector2(BR.ReadSingle(), BR.ReadSingle()); ParticleSettings.StartingAlpha = BR.ReadSingle(); ParticleSettings.EndAlpha = BR.ReadSingle(); _ParticleBlendState = (ParticleBlendStates)BR.ReadByte(); TimeBetweenEachParticle = 1 / ParticlesPerSeconds; ParticleSystem = new Particle3DSample.ParticleSystem(ParticleSettings); ParticleSystem.LoadContent(Content, GameScreen.GraphicsDevice, Projection); this.SpeedMultiplier = SpeedMultiplier; this.Size = Size; UpdateSize(); int DicAnimationSpriteKeyFrameCount = BR.ReadInt32(); for (int E = 0; E < DicAnimationSpriteKeyFrameCount; E++) { int Key = BR.ReadInt32(); VisibleAnimationObjectKeyFrame NewAnimatedBitmapKeyFrame = new VisibleAnimationObjectKeyFrame(BR); DicAnimationKeyFrame.Add(Key, NewAnimatedBitmapKeyFrame); } Origin = new Point(Width / 2, Height / 2); }
public override void UpdateAnimationObject(int KeyFrame) { //An Event is being executed. if (NextEvent != null) { UpdateAnimationSprite(KeyFrame); } VisibleAnimationObjectKeyFrame ActiveKeyFrame; if (DicAnimationKeyFrame.TryGetValue(KeyFrame, out ActiveKeyFrame)) { //If that animation has already been used, skip it. if (ActiveKeyFrame.IsUsed) { return; } int NextKeyFrame = ActiveKeyFrame.NextKeyFrame; OnNewKeyFrameAnimationSprite(ActiveKeyFrame); if (DicAnimationKeyFrame.TryGetValue(NextKeyFrame, out ActiveKeyFrame)) { if (ActiveKeyFrame.IsProgressive) { OnProgressiveNextKeyFrameAnimationSprite(ActiveKeyFrame, KeyFrame, NextKeyFrame); } else { NextEvent = null; } } } if (AnimationMarker != null) { AnimationMarker.UpdateKeyFrame(AnimationMarker.ActiveKeyFrame); AnimationMarker.ActiveKeyFrame++; if (AnimationMarker.LoopEnd > 0 && AnimationMarker.ActiveKeyFrame >= AnimationMarker.LoopEnd) { AnimationMarker.ActiveKeyFrame = AnimationMarker.LoopStart; AnimationMarker.CurrentQuote = ""; AnimationMarker.ListActiveSFX.Clear(); for (int L = 0; L < AnimationMarker.ListAnimationLayer.Count; L++) { AnimationMarker.ListAnimationLayer[L].ResetAnimationLayer(); } AnimationMarker.UpdateKeyFrame(0); if (AnimationMarker.ActiveKeyFrame > 0) { AnimationMarker.UpdateKeyFrame(AnimationMarker.ActiveKeyFrame); } } } }
public override void UpdateAnimationObject(int KeyFrame) { if (ActiveSprite == null) { return; } //An Event is being executed. if (NextEvent != null) { PixelPerSecond = PixelPerSecondOld + (int)(AnimationValue * (KeyFrame - EventKeyFrameOld)); _MaxWidth = MaxWidthOld + (int)(MaxWidthValue * (KeyFrame - EventKeyFrameOld)); UpdateAnimationSprite(KeyFrame); } Offset += PixelPerSecond * (1 / 60f); AnimatedTileKeyFrame ActiveKeyFrame; VisibleAnimationObjectKeyFrame ActiveAnimationSpriteKeyFrame; if (DicAnimationKeyFrame.TryGetValue(KeyFrame, out ActiveAnimationSpriteKeyFrame)) { ActiveKeyFrame = (AnimatedTileKeyFrame)ActiveAnimationSpriteKeyFrame; //If that animation has already been used, skip it. if (ActiveKeyFrame.IsUsed) { return; } int NextKeyFrame = ActiveKeyFrame.NextKeyFrame; OnNewKeyFrameAnimationSprite(ActiveKeyFrame); PixelPerSecond = ActiveKeyFrame.PixelPerSecond; MaxWidth = ActiveKeyFrame.MaxWidth; if (DicAnimationKeyFrame.TryGetValue(NextKeyFrame, out ActiveAnimationSpriteKeyFrame)) { ActiveKeyFrame = (AnimatedTileKeyFrame)ActiveAnimationSpriteKeyFrame; if (ActiveKeyFrame.IsProgressive) { OnProgressiveNextKeyFrameAnimationSprite(ActiveKeyFrame, KeyFrame, NextKeyFrame); PixelPerSecondOld = PixelPerSecond; MaxWidthOld = MaxWidth; float KeyFrameChange = KeyFrame - NextKeyFrame; //Calculate of how many pixel the AnimatedBitmap will move per step. AnimationValue = (PixelPerSecond - ActiveKeyFrame.PixelPerSecond) / KeyFrameChange; MaxWidthValue = (MaxWidth - ActiveKeyFrame.MaxWidth) / KeyFrameChange; } else { NextEvent = null; } } } }
public override void UpdateAnimationObject(int KeyFrame) { if (ActiveSprite == null) { return; } //An Event is being executed. if (NextEvent != null) { ActiveSprite.FramesPerSecond = AnimationSpeedOld + (int)(AnimationValue * (KeyFrame - EventKeyFrameOld)); UpdateAnimationSprite(KeyFrame); } ActiveSprite.Update(ActiveSprite.FramesPerSecond * (1 / 60f)); if (ActiveSprite.AnimationEnded) { ActiveSprite.LoopAnimation(); } AnimatedBitmapKeyFrame ActiveKeyFrame; VisibleAnimationObjectKeyFrame ActiveAnimationSpriteKeyFrame; if (DicAnimationKeyFrame.TryGetValue(KeyFrame, out ActiveAnimationSpriteKeyFrame)) { ActiveKeyFrame = (AnimatedBitmapKeyFrame)ActiveAnimationSpriteKeyFrame; //If that animation has already been used, skip it. if (ActiveKeyFrame.IsUsed) { return; } int NextKeyFrame = ActiveKeyFrame.NextKeyFrame; OnNewKeyFrameAnimationSprite(ActiveKeyFrame); ActiveSprite.FramesPerSecond = ActiveKeyFrame.FramesPerSecond; if (DicAnimationKeyFrame.TryGetValue(NextKeyFrame, out ActiveAnimationSpriteKeyFrame)) { ActiveKeyFrame = (AnimatedBitmapKeyFrame)ActiveAnimationSpriteKeyFrame; if (ActiveKeyFrame.IsProgressive) { OnProgressiveNextKeyFrameAnimationSprite(ActiveKeyFrame, KeyFrame, NextKeyFrame); AnimationSpeedOld = ActiveSprite.FramesPerSecond; float KeyFrameChange = KeyFrame - NextKeyFrame; //Calculate of how many pixel the AnimatedBitmap will move per step. AnimationValue = (ActiveSprite.FramesPerSecond - ActiveKeyFrame.FramesPerSecond) / KeyFrameChange; } else { NextEvent = null; } } } }
public override void UpdateAnimationObject(int KeyFrame) { //An Event is being executed. if (NextEvent != null) { UpdateAnimationSprite(KeyFrame); } VisibleAnimationObjectKeyFrame ActiveKeyFrame; VisibleAnimationObjectKeyFrame ActiveAnimationSpriteKeyFrame; if (DicAnimationKeyFrame.TryGetValue(KeyFrame, out ActiveAnimationSpriteKeyFrame)) { ActiveKeyFrame = ActiveAnimationSpriteKeyFrame; //If that animation has already been used, skip it. if (ActiveKeyFrame.IsUsed) { return; } int NextKeyFrame = ActiveKeyFrame.NextKeyFrame; OnNewKeyFrameAnimationSprite(ActiveKeyFrame); for (int C = ListCollisionPolygon.Count - 1; C >= 0; --C) { ListCollisionPolygon[C].Offset(Position.X, Position.Y); } if (Owner != null) { MeleeBox NewAttackBox = new MeleeBox(_Damage, Owner, (DeathFrame - SpawnFrame) / FramesPerSeconds, true); for (int C = ListCollisionPolygon.Count - 1; C >= 0; --C) { ListCollisionPolygon[C].Offset(Owner.Position.X - Owner.AnimationOrigin.Position.X, Owner.Position.Y - Owner.AnimationOrigin.Position.Y); } NewAttackBox.ListCollisionPolygon = ListCollisionPolygon; //TODO: delete the attack box is the animation is cancelled Owner.CreateAttackBox(NewAttackBox); } if (DicAnimationKeyFrame.TryGetValue(NextKeyFrame, out ActiveAnimationSpriteKeyFrame)) { ActiveKeyFrame = ActiveAnimationSpriteKeyFrame; if (ActiveKeyFrame.IsProgressive) { OnProgressiveNextKeyFrameAnimationSprite(ActiveKeyFrame, KeyFrame, NextKeyFrame); } else { NextEvent = null; } } } }
public override void UpdateAnimationObject(int KeyFrame) { Progress = 0; //An Event is being executed. if (NextEvent != null) { Progress = (KeyFrame - EventKeyFrameOld) / (float)(NextEventKeyFrame - EventKeyFrameOld); int OldDamageCurrent = DamageCurrent; DamageCurrent = DamageOld + (int)(DamageChangeValue * Progress); if (Owner != null) { Owner.DamageEnemyUnit(DamageCurrent - OldDamageCurrent); } UpdateAnimationSprite(KeyFrame); } DamageKeyFrame ActiveKeyFrame; VisibleAnimationObjectKeyFrame ActiveAnimationSpriteKeyFrame; if (DicAnimationKeyFrame.TryGetValue(KeyFrame, out ActiveAnimationSpriteKeyFrame)) { ActiveKeyFrame = (DamageKeyFrame)ActiveAnimationSpriteKeyFrame; //If that animation has already been used, skip it. if (ActiveKeyFrame.IsUsed) { return; } int NextKeyFrame = ActiveKeyFrame.NextKeyFrame; OnNewKeyFrameAnimationSprite(ActiveKeyFrame); ComputeRealDamage(ActiveKeyFrame); if (DicAnimationKeyFrame.TryGetValue(NextKeyFrame, out ActiveAnimationSpriteKeyFrame)) { DamageKeyFrame NextActiveKeyFrame = (DamageKeyFrame)ActiveAnimationSpriteKeyFrame; if (NextActiveKeyFrame.IsProgressive) { OnProgressiveNextKeyFrameAnimationSprite(NextActiveKeyFrame, KeyFrame, NextKeyFrame); ComputeNextDamage(NextActiveKeyFrame); } else { NextEvent = null; } } if (Owner != null && (!ActiveKeyFrame.IsProgressive || KeyFrame == SpawnFrame)) { Owner.DamageEnemyUnit(DamageCurrent); } } }
public override void UpdateAnimationObject(int KeyFrame) { //An Event is being executed. if (NextEvent != null) { UpdateAnimationSprite(KeyFrame); } VisibleAnimationObjectKeyFrame ActiveKeyFrame; VisibleAnimationObjectKeyFrame ActiveAnimationSpriteKeyFrame; if (DicAnimationKeyFrame.TryGetValue(KeyFrame, out ActiveAnimationSpriteKeyFrame)) { ActiveKeyFrame = ActiveAnimationSpriteKeyFrame; //If that animation has already been used, skip it. if (ActiveKeyFrame.IsUsed) { return; } int NextKeyFrame = ActiveKeyFrame.NextKeyFrame; OnNewKeyFrameAnimationSprite(ActiveKeyFrame); if (Owner != null) { if (_ShootSecondaryWeapon) { Owner.Shoot(Position, _ShootSecondaryWeapon); } else if (OwnerWeapon != null) { int i = Owner.PrimaryWeapons.ActiveWeapons.IndexOf(OwnerWeapon); Owner.Shoot(Position, OwnerWeapon, i); } } if (DicAnimationKeyFrame.TryGetValue(NextKeyFrame, out ActiveAnimationSpriteKeyFrame)) { ActiveKeyFrame = ActiveAnimationSpriteKeyFrame; if (ActiveKeyFrame.IsProgressive) { OnProgressiveNextKeyFrameAnimationSprite(ActiveKeyFrame, KeyFrame, NextKeyFrame); } else { NextEvent = null; } } } }
public AnimationOriginTimeline(BinaryReader BR) : base(BR, TimelineType) { Origin = new Point(BR.ReadInt32(), BR.ReadInt32()); int DicAnimationSpriteKeyFrameCount = BR.ReadInt32(); for (int E = 0; E < DicAnimationSpriteKeyFrameCount; E++) { int Key = BR.ReadInt32(); VisibleAnimationObjectKeyFrame NewAnimatedBitmapKeyFrame = new VisibleAnimationObjectKeyFrame(BR); DicAnimationKeyFrame.Add(Key, NewAnimatedBitmapKeyFrame); } }
public SceneObjectTimeline(BinaryReader BR, SceneObject SceneObject) : base(BR, TimelineType) { this.SceneObject = SceneObject; int DicAnimationSpriteKeyFrameCount = BR.ReadInt32(); for (int E = 0; E < DicAnimationSpriteKeyFrameCount; E++) { int Key = BR.ReadInt32(); VisibleAnimationObjectKeyFrame NewAnimatedBitmapKeyFrame = new VisibleAnimationObjectKeyFrame(BR); DicAnimationKeyFrame.Add(Key, NewAnimatedBitmapKeyFrame); } }
public override void UpdateAnimationObject(int KeyFrame) { //An Event is being executed. if (NextEvent != null) { UpdateAnimationSprite(KeyFrame); } else { Position = PositionOld; ScaleFactor = ScaleFactorOld; Angle = AngleOld; Alpha = AlphaOld; DrawingDepth = DrawingDepthOld; } VisibleAnimationObjectKeyFrame ActiveKeyFrame; VisibleAnimationObjectKeyFrame ActiveAnimationSpriteKeyFrame; if (DicAnimationKeyFrame.TryGetValue(KeyFrame, out ActiveAnimationSpriteKeyFrame)) { ActiveKeyFrame = ActiveAnimationSpriteKeyFrame; //If that animation has already been used, skip it. if (ActiveKeyFrame.IsUsed) { return; } int NextKeyFrame = ActiveKeyFrame.NextKeyFrame; OnNewKeyFrameAnimationSprite(ActiveKeyFrame); if (DicAnimationKeyFrame.TryGetValue(NextKeyFrame, out ActiveAnimationSpriteKeyFrame)) { ActiveKeyFrame = ActiveAnimationSpriteKeyFrame; if (ActiveKeyFrame.IsProgressive) { OnProgressiveNextKeyFrameAnimationSprite(ActiveKeyFrame, KeyFrame, NextKeyFrame); } else { NextEvent = null; } } } }
public override void UpdateAnimationObject(int KeyFrame) { //An Event is being executed. if (NextEvent != null) { UpdateAnimationSprite(KeyFrame); } 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); if (DicAnimationKeyFrame.TryGetValue(NextKeyFrame, out ActiveAnimationSpriteKeyFrame)) { ActiveKeyFrame = (AnimatedChainKeyFrame)ActiveAnimationSpriteKeyFrame; if (ActiveKeyFrame.IsProgressive) { OnProgressiveNextKeyFrameAnimationSprite(ActiveKeyFrame, KeyFrame, NextKeyFrame); float KeyFrameChange = KeyFrame - NextKeyFrame; //Calculate of how many pixel the AnimatedBitmap will move per step. } else { NextEvent = null; } } } }
private ENTimeline(BinaryReader BR, ContentManager Content) : base(BR, TimelineType) { _SpawnFrame = BR.ReadInt32(); _DeathFrame = BR.ReadInt32(); fntDamage = Content.Load <SpriteFont>("Fonts/Finlander Font"); int DicAnimationSpriteKeyFrameCount = BR.ReadInt32(); for (int E = 0; E < DicAnimationSpriteKeyFrameCount; E++) { int Key = BR.ReadInt32(); ENKeyFrame NewAnimatedBitmapKeyFrame = new ENKeyFrame(BR); DicAnimationKeyFrame.Add(Key, NewAnimatedBitmapKeyFrame); } }
public override void UpdateAnimationObject(int KeyFrame) { //An Event is being executed. if (NextEvent != null) { UpdateAnimationSprite(KeyFrame); } VisibleAnimationObjectKeyFrame ActiveKeyFrame; VisibleAnimationObjectKeyFrame ActiveAnimationSpriteKeyFrame; if (DicAnimationKeyFrame.TryGetValue(KeyFrame, out ActiveAnimationSpriteKeyFrame)) { ActiveKeyFrame = ActiveAnimationSpriteKeyFrame; //If that animation has already been used, skip it. if (ActiveKeyFrame.IsUsed) { return; } int NextKeyFrame = ActiveKeyFrame.NextKeyFrame; OnNewKeyFrameAnimationSprite(ActiveKeyFrame); for (int C = ListCollisionPolygon.Count - 1; C >= 0; --C) { ListCollisionPolygon[C].Offset(Position.X, Position.Y); } if (DicAnimationKeyFrame.TryGetValue(NextKeyFrame, out ActiveAnimationSpriteKeyFrame)) { ActiveKeyFrame = ActiveAnimationSpriteKeyFrame; if (ActiveKeyFrame.IsProgressive) { OnProgressiveNextKeyFrameAnimationSprite(ActiveKeyFrame, KeyFrame, NextKeyFrame); } else { NextEvent = null; } } } }
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 UpdateAnimationObject(int KeyFrame) { Progress = 0; //An Event is being executed. if (NextEvent != null) { Progress = (KeyFrame - EventKeyFrameOld) / (float)(NextEventKeyFrame - EventKeyFrameOld); UpdateAnimationSprite(KeyFrame); } VisibleAnimationObjectKeyFrame ActiveKeyFrame; VisibleAnimationObjectKeyFrame ActiveAnimationSpriteKeyFrame; if (DicAnimationKeyFrame.TryGetValue(KeyFrame, out ActiveAnimationSpriteKeyFrame)) { ActiveKeyFrame = (VisibleAnimationObjectKeyFrame)ActiveAnimationSpriteKeyFrame; //If that animation has already been used, skip it. if (ActiveKeyFrame.IsUsed) { return; } int NextKeyFrame = ActiveKeyFrame.NextKeyFrame; OnNewKeyFrameAnimationSprite(ActiveKeyFrame); if (DicAnimationKeyFrame.TryGetValue(NextKeyFrame, out ActiveAnimationSpriteKeyFrame)) { VisibleAnimationObjectKeyFrame NextActiveKeyFrame = (VisibleAnimationObjectKeyFrame)ActiveAnimationSpriteKeyFrame; if (NextActiveKeyFrame.IsProgressive) { OnProgressiveNextKeyFrameAnimationSprite(NextActiveKeyFrame, KeyFrame, NextKeyFrame); } else { NextEvent = null; } } } }
private UITimeline(BinaryReader BR, ContentManager Content) : base(BR, TimelineType) { fntFinlanderFont = Content.Load <SpriteFont>("Fonts/Finlander Font"); sprBarExtraLargeBackground = Content.Load <Texture2D>("Battle/Bars/Extra Long Bar"); sprBarExtraLargeEN = Content.Load <Texture2D>("Battle/Bars/Extra Long Energy"); sprBarExtraLargeHP = Content.Load <Texture2D>("Battle/Bars/Extra Long Health"); sprInfinity = Content.Load <Texture2D>("Battle/Infinity"); _SpawnFrame = BR.ReadInt32(); _DeathFrame = BR.ReadInt32(); int DicAnimationSpriteKeyFrameCount = BR.ReadInt32(); for (int E = 0; E < DicAnimationSpriteKeyFrameCount; E++) { int Key = BR.ReadInt32(); VisibleAnimationObjectKeyFrame NewAnimatedBitmapKeyFrame = new VisibleAnimationObjectKeyFrame(BR); DicAnimationKeyFrame.Add(Key, NewAnimatedBitmapKeyFrame); } }
public ChargeAttackTimeline(BinaryReader BR, RobotAnimation Owner) : base(BR, TimelineType) { Origin = new Point(Width / 2, Height / 2); this.Owner = Owner; _SpawnFrame = BR.ReadInt32(); _DeathFrame = BR.ReadInt32(); _ShootSecondaryWeapon = BR.ReadBoolean(); _MaxCharge = BR.ReadInt32(); _ChargeAmountPerFrame = BR.ReadInt32(); int DicAnimationSpriteKeyFrameCount = BR.ReadInt32(); for (int E = 0; E < DicAnimationSpriteKeyFrameCount; E++) { int Key = BR.ReadInt32(); VisibleAnimationObjectKeyFrame NewAnimatedBitmapKeyFrame = new VisibleAnimationObjectKeyFrame(BR); DicAnimationKeyFrame.Add(Key, NewAnimatedBitmapKeyFrame); } }
public AnimatedBitmapTimeline(BinaryReader BR, ContentManager Content) : base(BR, TimelineType) { Origin = new Point(BR.ReadInt32(), BR.ReadInt32()); BitmapName = BR.ReadString(); if (Content != null) { ActiveSprite = new AnimatedSprite(Content, "Animations/Sprites/" + BitmapName, Vector2.Zero); } int DicAnimationSpriteKeyFrameCount = BR.ReadInt32(); for (int E = 0; E < DicAnimationSpriteKeyFrameCount; E++) { int Key = BR.ReadInt32(); AnimatedBitmapKeyFrame NewAnimatedBitmapKeyFrame = new AnimatedBitmapKeyFrame(BR); DicAnimationKeyFrame.Add(Key, NewAnimatedBitmapKeyFrame); } }
public AnimatedTileTimeline(BinaryReader BR, ContentManager Content) : base(BR, TimelineType) { Origin = new Point(BR.ReadInt32(), BR.ReadInt32()); BitmapName = BR.ReadString(); if (Content != null) { ActiveSprite = Content.Load <Texture2D>("Animations/Sprites/" + BitmapName); } _MaxWidth = BR.ReadInt32(); int DicAnimationSpriteKeyFrameCount = BR.ReadInt32(); for (int E = 0; E < DicAnimationSpriteKeyFrameCount; E++) { int Key = BR.ReadInt32(); AnimatedTileKeyFrame NewAnimatedBitmapKeyFrame = new AnimatedTileKeyFrame(BR); DicAnimationKeyFrame.Add(Key, NewAnimatedBitmapKeyFrame); } }
public MarkerTimeline(BinaryReader BR, ContentManager Content) : base(BR, TimelineType) { BitmapName = BR.ReadString(); _MarkerType = BR.ReadString(); if (!string.IsNullOrEmpty(BitmapName) && Content != null) { Sprite = Content.Load <Texture2D>("Animations/Sprites/" + BitmapName); } Origin = new Point(Width / 2, Height / 2); int DicAnimationSpriteKeyFrameCount = BR.ReadInt32(); for (int E = 0; E < DicAnimationSpriteKeyFrameCount; E++) { int Key = BR.ReadInt32(); VisibleAnimationObjectKeyFrame NewAnimatedBitmapKeyFrame = new VisibleAnimationObjectKeyFrame(BR); DicAnimationKeyFrame.Add(Key, NewAnimatedBitmapKeyFrame); } }
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; } } } }
public override void UpdateAnimationObject(int KeyFrame) { double TimeElapsedInSeconds = 1 / 60d; TimeElapsedSinceLastParticle += TimeElapsedInSeconds; while (TimeElapsedSinceLastParticle >= TimeBetweenEachParticle) { TimeElapsedSinceLastParticle -= TimeBetweenEachParticle; Vector2 SpawnPosition = new Vector2(Position.X + SpawnOffset.X + (float)Random.NextDouble() * SpawnOffsetRandom.X, Position.Y + SpawnOffset.Y + (float)Random.NextDouble() * SpawnOffsetRandom.Y); Vector2 ParticleSpeed = new Vector2(SpawnSpeed.X + (float)Random.NextDouble() * SpawnSpeedRandom.X, SpawnSpeed.Y + (float)Random.NextDouble() * SpawnSpeedRandom.Y); ParticleSystem.AddParticle(SpawnPosition, ParticleSpeed); } ParticleSystem.Update(TimeElapsedInSeconds); //An Event is being executed. if (NextEvent != null) { UpdateAnimationSprite(KeyFrame); } else { Position = PositionOld; ScaleFactor = ScaleFactorOld; Angle = AngleOld; Alpha = AlphaOld; DrawingDepth = DrawingDepthOld; } VisibleAnimationObjectKeyFrame ActiveKeyFrame; VisibleAnimationObjectKeyFrame ActiveAnimationSpriteKeyFrame; if (DicAnimationKeyFrame.TryGetValue(KeyFrame, out ActiveAnimationSpriteKeyFrame)) { ActiveKeyFrame = ActiveAnimationSpriteKeyFrame; //If that animation has already been used, skip it. if (ActiveKeyFrame.IsUsed) { return; } int NextKeyFrame = ActiveKeyFrame.NextKeyFrame; OnNewKeyFrameAnimationSprite(ActiveKeyFrame); if (DicAnimationKeyFrame.TryGetValue(NextKeyFrame, out ActiveAnimationSpriteKeyFrame)) { ActiveKeyFrame = ActiveAnimationSpriteKeyFrame; if (ActiveKeyFrame.IsProgressive) { OnProgressiveNextKeyFrameAnimationSprite(ActiveKeyFrame, KeyFrame, NextKeyFrame); } else { NextEvent = null; } } } }
public PolygonCutterTimeline(BinaryReader BR, AnimationClass.AnimationLayer ActiveLayer) : base(BR, TimelineType) { this.ActiveLayer = ActiveLayer; _PolygonCutterType = (PolygonCutterTypes)BR.ReadByte(); _PolygonCutterSpecialEffect = (PolygonCutterSpecialEffects)BR.ReadByte(); ListPolygon = new List <Polygon>(); float MinX = float.MaxValue; float MaxX = float.MinValue; float MinY = float.MaxValue; float MaxY = float.MinValue; foreach (Polygon ActivePolygon in ListPolygon) { for (int V = 0; V < ActivePolygon.VertexCount; V++) { int VertexX = (int)ActivePolygon.ArrayVertex[V].X; int VertexY = (int)ActivePolygon.ArrayVertex[V].Y; if (VertexX < MinX) { MinX = VertexX; } if (VertexX > MaxX) { MaxX = VertexX; } if (VertexY < MinY) { MinY = VertexY; } if (VertexY > MaxY) { MaxY = VertexY; } } } SourceRectangle = new Rectangle((int)MinX, (int)MinY, (int)(MaxX - MinX), (int)(MaxY - MinY)); Origin = new Point(Width / 2, Height / 2); int DicAnimationSpriteKeyFrameCount = BR.ReadInt32(); for (int E = 0; E < DicAnimationSpriteKeyFrameCount; E++) { int Key = BR.ReadInt32(); PolygonCutterKeyFrame NewPolygonCutterKeyFrame = new PolygonCutterKeyFrame(BR, ActiveLayer); DicAnimationKeyFrame.Add(Key, NewPolygonCutterKeyFrame); } int FirstKey = int.MaxValue; foreach (int ActiveKey in DicAnimationKeyFrame.Keys) { if (FirstKey > ActiveKey) { FirstKey = ActiveKey; } } PolygonCutterKeyFrame FirstKeyFrame = (PolygonCutterKeyFrame)DicAnimationKeyFrame[FirstKey]; for (int P = 0; P < FirstKeyFrame.ListPolygon.Count; P++) { Polygon ActivePolygon = new Polygon(FirstKeyFrame.ListPolygon[P]); ListPolygon.Add(ActivePolygon); } }
public override void UpdateAnimationObject(int KeyFrame) { //An Event is being executed. if (NextEvent != null && ArrayMoveValue != null) { UpdateAnimationSprite(KeyFrame); for (int P = 0; P < ListPolygon.Count; P++) { for (int V = 0; V < ListPolygon[P].ArrayVertex.Length; V++) { Vector2 Result = ArrayMoveValue[P][V] * (KeyFrame - EventKeyFrameOld); ListPolygon[P].ArrayVertex[V] = new Vector2(EventOld.ListPolygon[P].ArrayVertex[V].X + (int)Result.X, EventOld.ListPolygon[P].ArrayVertex[V].Y + (int)Result.Y); } if (PolygonCutterType == PolygonCutterTypes.Crop) { ListPolygon[P].ComputeColorAndUVCoordinates(ActiveLayer.Owner.ScreenWidth, ActiveLayer.Owner.ScreenHeight); } ListPolygon[P].ComputePerpendicularAxis(); ListPolygon[P].UpdateWorldPosition(Position, Angle); } } VisibleAnimationObjectKeyFrame ActiveKeyFrame; if (DicAnimationKeyFrame.TryGetValue(KeyFrame, out ActiveKeyFrame)) { //If that animation has already been used, skip it. if (ActiveKeyFrame.IsUsed) { return; } int NextKeyFrame = ActiveKeyFrame.NextKeyFrame; OnNewKeyFrameAnimationSprite(ActiveKeyFrame); PolygonCutterKeyFrame ActivePolygonCutterKeyFrame = (PolygonCutterKeyFrame)ActiveKeyFrame; EventOld = ActivePolygonCutterKeyFrame; if (DicAnimationKeyFrame.TryGetValue(NextKeyFrame, out ActiveKeyFrame)) { PolygonCutterKeyFrame NextActivePolygonCutterKeyFrame = (PolygonCutterKeyFrame)ActiveKeyFrame; //Get the next polygons. if (NextActivePolygonCutterKeyFrame.ListPolygon.Count != ListPolygon.Count) { ListPolygon.Clear(); for (int P = 0; P < NextActivePolygonCutterKeyFrame.ListPolygon.Count; P++) { Polygon ActivePolygon = new Polygon(NextActivePolygonCutterKeyFrame.ListPolygon[P]); ListPolygon.Add(ActivePolygon); } } for (int P = 0; P < NextActivePolygonCutterKeyFrame.ListPolygon.Count; P++) { Polygon ActivePolygon = NextActivePolygonCutterKeyFrame.ListPolygon[P]; if (PolygonCutterType == PolygonCutterTypes.Crop) { ActivePolygon.ComputeColorAndUVCoordinates(AnimationClass.GraphicsDevice.PresentationParameters.BackBufferWidth, AnimationClass.GraphicsDevice.PresentationParameters.BackBufferHeight); } } if (ActiveKeyFrame.IsProgressive) { OnProgressiveNextKeyFrameAnimationSprite(ActiveKeyFrame, KeyFrame, NextKeyFrame); float KeyFrameChange = KeyFrame - NextKeyFrame; ArrayMoveValue = null; if (ActivePolygonCutterKeyFrame.ListPolygon.Count == NextActivePolygonCutterKeyFrame.ListPolygon.Count) { ArrayMoveValue = new Vector2[NextActivePolygonCutterKeyFrame.ListPolygon.Count][]; for (int P = 0; P < NextActivePolygonCutterKeyFrame.ListPolygon.Count; P++) { if (ActivePolygonCutterKeyFrame.ListPolygon[P].ArrayVertex.Length != NextActivePolygonCutterKeyFrame.ListPolygon[P].ArrayVertex.Length) { ArrayMoveValue = null; break; } else { ArrayMoveValue[P] = new Vector2[NextActivePolygonCutterKeyFrame.ListPolygon[P].ArrayVertex.Length]; for (int V = 0; V < NextActivePolygonCutterKeyFrame.ListPolygon[P].ArrayVertex.Length; V++) { ArrayMoveValue[P][V] = new Vector2( (ActivePolygonCutterKeyFrame.ListPolygon[P].ArrayVertex[V].X - NextActivePolygonCutterKeyFrame.ListPolygon[P].ArrayVertex[V].X) / KeyFrameChange, (ActivePolygonCutterKeyFrame.ListPolygon[P].ArrayVertex[V].Y - NextActivePolygonCutterKeyFrame.ListPolygon[P].ArrayVertex[V].Y) / KeyFrameChange); } } } } } else { NextEvent = null; } } } }