Enemies.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using System.Linq;
  2. using Microsoft.Xna.Framework;
  3. using OpenVIII.IGMDataItem;
  4. namespace OpenVIII.IGMData.Target
  5. {
  6. public class Enemies : Base
  7. {
  8. #region Properties
  9. public Party Target_Party { get; set; }
  10. #endregion Properties
  11. #region Methods
  12. public static Enemies Create(Rectangle pos) =>
  13. Create<Enemies>(6, 1, new Box { Pos = pos, Title = Icons.ID.TARGET }, 2, 3);
  14. public override void Inputs_Left()
  15. {
  16. if (CURSOR_SELECT - Rows < 0)
  17. {
  18. Cursor_Status &= ~Cursor_Status.Enabled;
  19. Target_Party.Cursor_Status |= Cursor_Status.Enabled;
  20. Target_Party.CURSOR_SELECT = CURSOR_SELECT % Rows;
  21. while (Target_Party.BLANKS[Target_Party.CURSOR_SELECT] && Target_Party.CURSOR_SELECT > 0)
  22. {
  23. Target_Party.CURSOR_SELECT--;
  24. }
  25. }
  26. else
  27. {
  28. SetCursor_select(CURSOR_SELECT - Rows);
  29. while (BLANKS[CURSOR_SELECT] && CURSOR_SELECT != 0)
  30. {
  31. CURSOR_SELECT--;
  32. }
  33. }
  34. base.Inputs_Left();
  35. }
  36. public override bool Inputs_OKAY() => false;
  37. public override void Inputs_Right()
  38. {
  39. if (CURSOR_SELECT + Rows > Count || (ITEM[CURSOR_SELECT + Rows, 0] == null || !ITEM[CURSOR_SELECT + Rows, 0].Enabled) || BLANKS[CURSOR_SELECT + Rows])
  40. {
  41. Cursor_Status &= ~Cursor_Status.Enabled;
  42. Target_Party.Cursor_Status |= Cursor_Status.Enabled;
  43. Target_Party.CURSOR_SELECT = CURSOR_SELECT % Rows;
  44. while (Target_Party.BLANKS[Target_Party.CURSOR_SELECT] && Target_Party.CURSOR_SELECT > 0)
  45. {
  46. Target_Party.CURSOR_SELECT--;
  47. }
  48. }
  49. else
  50. {
  51. SetCursor_select(CURSOR_SELECT + Rows);
  52. while (BLANKS[CURSOR_SELECT] && CURSOR_SELECT != 0)
  53. {
  54. CURSOR_SELECT--;
  55. }
  56. }
  57. base.Inputs_Right();
  58. }
  59. public void Random() => SetCursor_select(BLANKS.Cast<bool>().Select((enabled, index) => new { enabled, index }).Where(x => !x.enabled).Random().index);
  60. public override void Refresh()
  61. {
  62. if (Memory.State?.Characters != null)
  63. {
  64. var pos = 0;
  65. if (Enemy.Party != null)
  66. {
  67. foreach (var e in Enemy.Party)
  68. {
  69. //if(e.EII)
  70. ITEM[pos, 0] = new Text { Data = e.Name, Pos = SIZE[pos], FontColor = Font.ColorID.White };
  71. ITEM[pos, 0].Show();
  72. BLANKS[pos] = false;
  73. pos++;
  74. }
  75. for (; pos < Count; pos++)
  76. {
  77. ITEM[pos, 0]?.Hide();
  78. BLANKS[pos] = true;
  79. }
  80. }
  81. }
  82. }
  83. protected override void InitCursor(int i, int col, int row, bool zero = false)
  84. {
  85. base.InitCursor(i, col, row, zero);
  86. CURSOR[i].X += 8;
  87. }
  88. protected override void InitShift(int i, int col, int row)
  89. {
  90. base.InitShift(i, col, row);
  91. SIZE[i].Inflate(-8, -20);
  92. SIZE[i].Offset(2 + (-4 * col), 0);
  93. SIZE[i].Y -= 7 * row + 2;
  94. //SIZE[i].Inflate(-22, -8);
  95. //SIZE[i].Offset(0, 12 + (-8 * row));
  96. SIZE[i].Height = (int)(12 * TextScale.Y);
  97. }
  98. #endregion Methods
  99. }
  100. }