public void Save(BinaryWriter BW) { BW.Write(BackgroundPath); BW.Write(ListBackgroundLink.Count); foreach (AnimationBackgroundLink ActiveLink in ListBackgroundLink) { ActiveLink.Save(BW); } }
public override void Draw(CustomSpriteBatch g, float CameraX, float CameraY, int ScreenWidth, int ScreenHeight) { float FinalX = SpriteCenter.X; if (_UseParallaxScrolling) { FinalX += ((CurrentPosition.X - CameraX) * (1 - _Depth)) % ScreenWidth; } else { FinalX += (CurrentPosition.X - CameraX) % ScreenWidth; } float FinalY = SpriteCenter.Y; if (_UseParallaxScrolling) { FinalY += ((CurrentPosition.Y - CameraY) * (1 - _Depth)); } else { FinalY += (CurrentPosition.Y - CameraY) % ScreenHeight; } int StartX = 0; int RepeatXNumber = 1; if (_RepeatX) { StartX = -1; RepeatXNumber = (int)Math.Ceiling(ScreenWidth / (double)BackgroundChain.sprBackground.Width) + 1; } int StartY = 0; int RepeatYNumber = 1; if (_RepeatY) { StartY = -1; RepeatYNumber = (int)Math.Ceiling(ScreenHeight / (double)BackgroundChain.sprBackground.Height) + 1; } bool FlipX = false; bool FlipY = false; for (int X = StartX; X < RepeatXNumber; ++X) { for (int Y = StartY; Y < RepeatYNumber; ++Y) { SpriteEffects FlipEffect = SpriteEffects.None; if (FlipX) { FlipEffect = SpriteEffects.FlipHorizontally; } if (FlipY) { FlipEffect |= SpriteEffects.FlipVertically; } Vector2 FinalPos = new Vector2(FinalX + X * BackgroundChain.sprBackground.Width, FinalY + Y * BackgroundChain.sprBackground.Height); g.Draw(BackgroundChain.sprBackground, FinalPos, null, _Color, 0, SpriteCenter, 1, FlipEffect, _Depth); foreach (AnimationBackgroundLink ActiveLink in BackgroundChain.ListBackgroundLink) { ActiveLink.Draw(g, FinalPos, _Depth, ScreenWidth, ScreenHeight); } if (_FlipOnRepeatY) { FlipY = !FlipY; } } if (_FlipOnRepeatX) { FlipX = !FlipX; } } }