public static PlayerAct Deserealize(SerializedPlayerAct serialized) { PlayerAct playerAct = new PlayerAct { Act = (PlayerAct.ActType)serialized.act, PlayerColor = (PlayerColor)serialized.playerColor }; if (playerAct.Act != PlayerAct.ActType.Move) { return(playerAct); } playerAct.From = new Cell(serialized.fromVertical, serialized.fromHorizontal); playerAct.To = new Cell(serialized.toVertical, serialized.toHorizontal); return(playerAct); }
public static SerializedPlayerAct Serialize(PlayerAct playerAct) { SerializedPlayerAct result = new SerializedPlayerAct { act = (int)playerAct.Act, playerColor = (int)playerAct.PlayerColor }; if (playerAct.Act != PlayerAct.ActType.Move) { return(result); } result.fromVertical = playerAct.From.Vertical; result.fromHorizontal = playerAct.From.Horizontal; result.toVertical = playerAct.To.Vertical; result.toHorizontal = playerAct.To.Horizontal; return(result); }
private void CmdAct(SerializedPlayerAct serializedPlayerAct) { PlayerAct playerAct = SerializedPlayerAct.Deserealize(serializedPlayerAct); PlayerActedEvent(playerAct); }
private void PlayerActed(PlayerAct playerAct) { playerAct.PlayerColor = playerColor; CmdAct(SerializedPlayerAct.Serialize(playerAct)); }