PlayCardAction.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using ExitGames.Client.Photon;
  2. public class PlayCardAction : MainPhaseAction
  3. {
  4. int CardIndex;
  5. int TargetFrameID;
  6. int[] JogressEvoRootsFrameIDs;
  7. int BurstTamerFrameID;
  8. int[] AppFusionFrameIDs;
  9. public PlayCardAction(int cardIndex, int targetFrameID, int[] jogressEvoRootsFrameIDs, int burstTamerFrameID, int[] appFusionFrameIDs)
  10. {
  11. CardIndex = cardIndex;
  12. TargetFrameID = targetFrameID;
  13. JogressEvoRootsFrameIDs = jogressEvoRootsFrameIDs;
  14. BurstTamerFrameID = burstTamerFrameID;
  15. AppFusionFrameIDs = appFusionFrameIDs;
  16. }
  17. public PlayCardAction(byte[] bytes)
  18. {
  19. CardIndex = -1;
  20. TargetFrameID = -1;
  21. JogressEvoRootsFrameIDs = null;
  22. BurstTamerFrameID = -1;
  23. AppFusionFrameIDs = null;
  24. Deserialize(bytes);
  25. }
  26. public override void Execute(TurnStateMachine stateMachine)
  27. {
  28. stateMachine.SetPlayCard(CardIndex, TargetFrameID, JogressEvoRootsFrameIDs, BurstTamerFrameID, AppFusionFrameIDs);
  29. }
  30. public override void Deserialize(byte[] bytes)
  31. {
  32. int index = 0;
  33. Protocol.Deserialize(out CardIndex, bytes, ref index);
  34. Protocol.Deserialize(out TargetFrameID, bytes, ref index);
  35. Protocol.Deserialize(out int JogressSize, bytes, ref index);
  36. if (JogressSize > 0)
  37. {
  38. JogressEvoRootsFrameIDs = new int[JogressSize];
  39. for (int i = 0; i < JogressSize; i++)
  40. {
  41. Protocol.Deserialize(out JogressEvoRootsFrameIDs[i], bytes, ref index);
  42. }
  43. }
  44. Protocol.Deserialize(out BurstTamerFrameID, bytes, ref index);
  45. Protocol.Deserialize(out int AppFuseSize, bytes, ref index);
  46. if (AppFuseSize > 0)
  47. {
  48. AppFusionFrameIDs = new int[AppFuseSize];
  49. for (int i = 0; i < AppFuseSize; i++)
  50. {
  51. Protocol.Deserialize(out AppFusionFrameIDs[i], bytes, ref index);
  52. }
  53. }
  54. }
  55. public override byte[] Serialize()
  56. {
  57. int JogressSize = JogressEvoRootsFrameIDs != null ? JogressEvoRootsFrameIDs.Length : 0;
  58. int AppFuseSize = AppFusionFrameIDs != null ? AppFusionFrameIDs.Length : 0;
  59. byte[] bytes = new byte[sizeof(int) * (5 + JogressSize + AppFuseSize)];
  60. int index = 0;
  61. Protocol.Serialize(CardIndex, bytes, ref index);
  62. Protocol.Serialize(TargetFrameID, bytes, ref index);
  63. Protocol.Serialize(JogressSize, bytes, ref index);
  64. if (JogressSize > 0)
  65. {
  66. for (int i = 0; i < JogressSize; i++)
  67. {
  68. Protocol.Serialize(JogressEvoRootsFrameIDs[i], bytes, ref index);
  69. }
  70. }
  71. Protocol.Serialize(BurstTamerFrameID, bytes, ref index);
  72. Protocol.Serialize(AppFuseSize, bytes, ref index);
  73. if (AppFuseSize > 0)
  74. {
  75. for (int i = 0; i < AppFuseSize; i++)
  76. {
  77. Protocol.Serialize(AppFusionFrameIDs[i], bytes, ref index);
  78. }
  79. }
  80. return bytes;
  81. }
  82. }