ActivateCardAction.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using ExitGames.Client.Photon;
  2. using UnityEngine;
  3. public class ActivateCardAction : MainPhaseAction
  4. {
  5. int CardIndex;
  6. int SkillIndex;
  7. public ActivateCardAction(int cardIndex, int skillIndex)
  8. {
  9. CardIndex = cardIndex;
  10. SkillIndex = skillIndex;
  11. }
  12. public ActivateCardAction(byte[] bytes)
  13. {
  14. CardIndex = -1;
  15. SkillIndex = -1;
  16. Deserialize(bytes);
  17. }
  18. public override void Execute(TurnStateMachine stateMachine)
  19. {
  20. stateMachine.SetActCardSkill(CardIndex, SkillIndex);
  21. }
  22. public override void Deserialize(byte[] bytes)
  23. {
  24. int index = 0;
  25. Protocol.Deserialize(out CardIndex, bytes, ref index);
  26. Protocol.Deserialize(out SkillIndex, bytes, ref index);
  27. }
  28. public override byte[] Serialize()
  29. {
  30. byte[] bytes = new byte[sizeof(int) * 2];
  31. int index = 0;
  32. Protocol.Serialize(CardIndex, bytes, ref index);
  33. Protocol.Serialize(SkillIndex, bytes, ref index);
  34. return bytes;
  35. }
  36. }