Guest User

Untitled

a guest
Mar 26th, 2019
23
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5.  
  6. namespace BayatGames.SaveGamePro.Serialization.Types
  7. {
  8.  
  9.     /// <summary>
  10.     /// Save Game Type Tile serialization implementation.
  11.     /// </summary>
  12.     public class SaveGameType_Tile : SaveGameType
  13.     {
  14.  
  15.         /// <summary>
  16.         /// Gets the associated type for this custom type.
  17.         /// </summary>
  18.         /// <value>The type of the associated.</value>
  19.         public override Type AssociatedType
  20.         {
  21.             get
  22.             {
  23.                 return typeof ( Tile );
  24.             }
  25.         }
  26.  
  27.         /// <summary>
  28.         /// Write the specified value using the writer.
  29.         /// </summary>
  30.         /// <param name="value">Value.</param>
  31.         /// <param name="writer">Writer.</param>
  32.         public override void Write ( object value, ISaveGameWriter writer )
  33.         {
  34.             Tile tile = ( Tile )value;
  35.             writer.WriteProperty ( "tileName", tile.tileName );
  36.             writer.WriteProperty ( "Type", tile.Type );
  37.         }
  38.  
  39.         /// <summary>
  40.         /// Read the data using the reader.
  41.         /// </summary>
  42.         /// <param name="reader">Reader.</param>
  43.         public override object Read ( ISaveGameReader reader )
  44.         {
  45.             Tile tile = new Tile();
  46.             ReadInto(tile, reader);
  47.             return tile;
  48.             // return base.Read ( reader );
  49.         }
  50.  
  51.         /// <summary>
  52.         /// Read the data into the specified value.
  53.         /// </summary>
  54.         /// <param name="value">Value.</param>
  55.         /// <param name="reader">Reader.</param>
  56.         public override void ReadInto ( object value, ISaveGameReader reader )
  57.         {
  58.             Tile tile = ( Tile )value;
  59.             foreach ( string property in reader.Properties )
  60.             {
  61.                 switch ( property )
  62.                 {
  63.                     case "tileName":
  64.                         tile.tileName = reader.ReadProperty<System.String> ();
  65.                         break;
  66.                     case "Type":
  67.                         tile.Type = reader.ReadProperty<TileType> ();
  68.                         break;
  69.  
  70.                 }
  71.             }
  72.         }
  73.        
  74.     }
  75.  
  76. }
RAW Paste Data