Module_card_test.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Graphics;
  3. using System;
  4. namespace FF8
  5. {
  6. internal 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.SpriteBatchStartStencil();
  74. Memory.spriteBatch.GraphicsDevice.Clear(Color.Black);
  75. Memory.Cards.Draw(id, dst);
  76. Memory.font.RenderBasicText(Font.CipherDirty($"{CardValue[pointer].ToString().Replace('_', ' ')}\npos: {pos}\ncol: {col}\nrow: {row}\nx: {Memory.Cards.GetEntry(id).X}\ny: {Memory.Cards.GetEntry(id).Y}\nwidth: {Memory.Cards.GetEntry(id).Width}\nheight: {Memory.Cards.GetEntry(id).Height}"),
  77. (int)(vp.Width * 0.10f), (int)(vp.Height * 0.05f), 1f, 2f, 0, 1);
  78. Memory.SpriteBatchEnd();
  79. }
  80. }
  81. private static void Initialize()
  82. {
  83. CardValue = (Cards.ID[])Enum.GetValues(typeof(Cards.ID));
  84. Array.Sort(CardValue);
  85. }
  86. #endregion Methods
  87. }
  88. }