G2A Many GEOs
SHARE
TWEET

Untitled

a guest Mar 26th, 2019 65 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 WorldData serialization implementation.
  11.     /// </summary>
  12.     public class SaveGameType_WorldData : 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 ( World.WorldData );
  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.             World.WorldData worldData = ( World.WorldData )value;
  35.             writer.WriteProperty ( "worldName", worldData.worldName );
  36.             writer.WriteProperty ( "width", worldData.width );
  37.             writer.WriteProperty ( "height", worldData.height );
  38.             writer.WriteProperty ( "tiles", worldData.tiles );
  39.         }
  40.  
  41.         /// <summary>
  42.         /// Read the data using the reader.
  43.         /// </summary>
  44.         /// <param name="reader">Reader.</param>
  45.         public override object Read ( ISaveGameReader reader )
  46.         {
  47.             World.WorldData worldData = new World.WorldData();
  48.             ReadInto(worldData, reader);
  49.             return worldData;
  50.  
  51.             // return base.Read(reader);
  52.         }
  53.  
  54.         /// <summary>
  55.         /// Read the data into the specified value.
  56.         /// </summary>
  57.         /// <param name="value">Value.</param>
  58.         /// <param name="reader">Reader.</param>
  59.         public override void ReadInto ( object value, ISaveGameReader reader )
  60.         {
  61.             World.WorldData worldData = ( World.WorldData )value;
  62.             foreach ( string property in reader.Properties )
  63.             {
  64.                 switch ( property )
  65.                 {
  66.                     case "worldName":
  67.                         worldData.worldName = reader.ReadProperty<System.String> ();
  68.                         break;
  69.                     case "width":
  70.                         worldData.width = reader.ReadProperty<System.Int32> ();
  71.                         break;
  72.                     case "height":
  73.                         worldData.height = reader.ReadProperty<System.Int32> ();
  74.                         break;
  75.                     case "tiles":
  76.                         worldData.tiles = reader.ReadProperty<Tile[,]> ();
  77.                         break;
  78.                 }
  79.             }
  80.         }
  81.        
  82.     }
  83.  
  84. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top