public static SerializablePieceType serializePieceType(Manager.PieceType pieceType) { if (pieceType == null) { return(new SerializablePieceType("none", 0)); } string name = pieceType.getTypeName(); switch (name) { case "standard": case "bomb": { SerializablePieceType serializablePieceType = new SerializablePieceType(name, 1); serializablePieceType.values[0] = ((Manager.NumberedPieceType)pieceType).number.ToString(); return(serializablePieceType); } default: { return(new SerializablePieceType(name, 0)); } } }
public static Manager.PieceType deserializePieceType(SerializablePieceType pieceType) { switch (pieceType.type) { case "standard": return(new Manager.StandardPieceType(int.Parse(pieceType.values[0]))); case "wall": return(new Manager.WallPieceType()); case "bomb": return(new Manager.BombPieceType(int.Parse(pieceType.values[0]))); case "incrementer": return(new Manager.IncrementerPieceType()); } return(null); }