ActivatePermanentAction.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using ExitGames.Client.Photon;
  2. public class ActivatePermanentAction : MainPhaseAction
  3. {
  4. int PermanentIndex;
  5. int SkillIndex;
  6. public ActivatePermanentAction(int permanentIndex, int skillIndex)
  7. {
  8. PermanentIndex = permanentIndex;
  9. SkillIndex = skillIndex;
  10. }
  11. public ActivatePermanentAction(byte[] bytes)
  12. {
  13. PermanentIndex = -1;
  14. SkillIndex = -1;
  15. Deserialize(bytes);
  16. }
  17. public override void Execute(TurnStateMachine stateMachine)
  18. {
  19. stateMachine.SetActSkill(PermanentIndex, SkillIndex);
  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 SkillIndex, 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(SkillIndex, bytes, ref index);
  33. return bytes;
  34. }
  35. }