Module_card_test.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Graphics;
  3. using System;
  4. namespace FF8
  5. {
  6. public class Module_card_test
  7. {
  8. #region Fields
  9. private static Mode currentMode;
  10. private static Cards.ID[] CardValue;
  11. private static int pointer = -1;
  12. private static int time;
  13. #endregion Fields
  14. #region Enums
  15. private enum Mode
  16. {
  17. Initialize,
  18. Draw,
  19. Wait
  20. }
  21. #endregion Enums
  22. #region Methods
  23. public static void Draw()
  24. {
  25. switch (currentMode)
  26. {
  27. case Mode.Initialize:
  28. break;
  29. case Mode.Wait:
  30. case Mode.Draw:
  31. DrawFace();
  32. break;
  33. }
  34. }
  35. public static void Update()
  36. {
  37. switch (currentMode)
  38. {
  39. case Mode.Initialize:
  40. Initialize();
  41. currentMode++;
  42. break;
  43. case Mode.Draw:
  44. pointer++;
  45. if (pointer >= CardValue.Length) pointer = 0;
  46. currentMode++;
  47. break;
  48. case Mode.Wait:
  49. time += Memory.gameTime.ElapsedGameTime.Milliseconds;
  50. if (time > 2000)
  51. {
  52. currentMode--;
  53. time = 0;
  54. }
  55. else
  56. Memory.SuppressDraw = true;
  57. break;
  58. }
  59. }
  60. private static void DrawFace()
  61. {
  62. if (pointer >= 0)
  63. {
  64. Viewport vp = Memory.graphics.GraphicsDevice.Viewport;
  65. var id = CardValue[pointer];
  66. uint pos = (uint)id;
  67. //int i = cards.GetEntry(id).File;
  68. uint col = (uint)(Memory.Cards.GetEntry(id).X / Memory.Cards.GetEntry(id).Width) +1;
  69. uint row = (uint)(Memory.Cards.GetEntry(id).Y / Memory.Cards.GetEntry(id).Width) +1;
  70. float scale = vp.Height / Memory.Cards.GetEntry(id).Height;
  71. Rectangle dst = new Rectangle(new Point(0), (Memory.Cards.GetEntry(id).Size * scale).ToPoint());
  72. dst.Offset(vp.Width / 2 - dst.Center.X, 0);
  73. Memory.SpriteBatchStartAlpha();
  74. Memory.spriteBatch.GraphicsDevice.Clear(Color.Black);
  75. Memory.Cards.Draw(id, dst);
  76. Memory.font.RenderBasicText(
  77. $"{CardValue[pointer].ToString().Replace('_', ' ')}\n" +
  78. $"pos: {pos}\n" +
  79. $"col: {col}\n" +
  80. $"row: {row}\n" +
  81. $"x: {Memory.Cards.GetEntry(id).X}\n" +
  82. $"y: {Memory.Cards.GetEntry(id).Y}\n" +
  83. $"width: {Memory.Cards.GetEntry(id).Width}\n" +
  84. $"height: {Memory.Cards.GetEntry(id).Height}",
  85. (int)(vp.Width * 0.10f), (int)(vp.Height * 0.05f), lineSpacing: 1);
  86. Memory.SpriteBatchEnd();
  87. }
  88. }
  89. private static void Initialize()
  90. {
  91. CardValue = (Cards.ID[])Enum.GetValues(typeof(Cards.ID));
  92. Array.Sort(CardValue);
  93. }
  94. #endregion Methods
  95. }
  96. }