FogParticle.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. using SlimDX;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace Client.MirGraphics.Particles
  8. {
  9. public class FogParticle : Particle
  10. {
  11. private static int xwidth = (int)(512 * (Math.Ceiling(Settings.ScreenWidth / 512M) + 2));
  12. private static int ywidth = (int)(512 * (Math.Ceiling(Settings.ScreenHeight / 512M) + 2));
  13. private Vector2 xreset = new Vector2(xwidth, 0);
  14. private Vector2 yreset = new Vector2(0, ywidth);
  15. public FogParticle(ParticleEngine engine, ParticleImageInfo image)
  16. {
  17. Engine = engine;
  18. ImageInfo = image;
  19. }
  20. public override void Update()
  21. {
  22. if (CMain.Now < NextUpdateTime) return;
  23. NextUpdateTime = CMain.Now.AddMilliseconds(50);
  24. Position += Velocity;
  25. }
  26. }
  27. public class SandParticle : Particle
  28. {
  29. private static int xwidth = (int)(800 * (Math.Ceiling(Settings.ScreenWidth / 800M) + 2));
  30. private static int ywidth = (int)(600 * (Math.Ceiling(Settings.ScreenHeight / 600M) + 2));
  31. private Vector2 xreset = new Vector2(xwidth, 0);
  32. private Vector2 yreset = new Vector2(0, ywidth);
  33. public SandParticle(ParticleEngine engine, ParticleImageInfo image)
  34. {
  35. Engine = engine;
  36. ImageInfo = image;
  37. }
  38. public override void Update()
  39. {
  40. if (CMain.Now < NextUpdateTime) return;
  41. NextUpdateTime = CMain.Now.AddMilliseconds(50);
  42. Position += Velocity;
  43. }
  44. protected override void OnPositionChanged()
  45. {
  46. if (Position.Y < -ImageInfo.Size.Height * 2)
  47. Position += yreset;
  48. else if (Position.Y > Settings.ScreenHeight + ImageInfo.Size.Height)
  49. Position -= yreset;
  50. else if (Position.X < -ImageInfo.Size.Width * 2)
  51. Position += xreset;
  52. else if (Position.X > Settings.ScreenWidth + ImageInfo.Size.Width)
  53. Position -= xreset;
  54. }
  55. }
  56. public class SnowParticle : Particle
  57. {
  58. private static int xwidth = (int)(400 * (Math.Ceiling(Settings.ScreenWidth / 400M) + 2));
  59. private static int ywidth = (int)(400 * (Math.Ceiling(Settings.ScreenHeight / 400M) + 2));
  60. private Vector2 xreset = new Vector2(xwidth, 0);
  61. private Vector2 yreset = new Vector2(0, ywidth);
  62. public SnowParticle(ParticleEngine engine, ParticleImageInfo image)
  63. {
  64. Engine = engine;
  65. ImageInfo = image;
  66. }
  67. public override void Update()
  68. {
  69. if (CMain.Now < NextUpdateTime) return;
  70. NextUpdateTime = CMain.Now.AddMilliseconds(50);
  71. Position += Velocity;
  72. }
  73. protected override void OnPositionChanged()
  74. {
  75. if (Position.Y < -ImageInfo.Size.Height * 2)
  76. Position += yreset;
  77. else if (Position.Y > Settings.ScreenHeight + ImageInfo.Size.Height)
  78. Position -= yreset;
  79. else if (Position.X < -ImageInfo.Size.Width * 2)
  80. Position += xreset;
  81. else if (Position.X > Settings.ScreenWidth + ImageInfo.Size.Width)
  82. Position -= xreset;
  83. }
  84. }
  85. public class FlowerParticle : Particle
  86. {
  87. private static int xwidth = (int)(400 * (Math.Ceiling(Settings.ScreenWidth / 400M) + 2));
  88. private static int ywidth = (int)(400 * (Math.Ceiling(Settings.ScreenHeight / 400M) + 2));
  89. private Vector2 xreset = new Vector2(xwidth, 0);
  90. private Vector2 yreset = new Vector2(0, ywidth);
  91. public FlowerParticle(ParticleEngine engine, ParticleImageInfo image)
  92. {
  93. Engine = engine;
  94. ImageInfo = image;
  95. }
  96. public override void Update()
  97. {
  98. if (CMain.Now < NextUpdateTime) return;
  99. NextUpdateTime = CMain.Now.AddMilliseconds(20);
  100. Position += Velocity;
  101. }
  102. protected override void OnPositionChanged()
  103. {
  104. if (Position.Y < -ImageInfo.Size.Height * 2)
  105. Position += yreset;
  106. else if (Position.Y > Settings.ScreenHeight + ImageInfo.Size.Height)
  107. Position -= yreset;
  108. else if (Position.X < -ImageInfo.Size.Width * 2)
  109. Position += xreset;
  110. else if (Position.X > Settings.ScreenWidth + ImageInfo.Size.Width)
  111. Position -= xreset;
  112. }
  113. }
  114. }