AttackPermanentAction.cs 1.2 KB

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