Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. // IN GAME MANAGER ....
  2.         public void SaveObjects ()
  3.     {
  4.         var saveables = FindObjectsOfType<AbstractSaveableMb> ();
  5.         for (int i = 0; i < saveables.Length; ++i) {
  6.             var id = saveables [i].gameObject.name;
  7.             var data = saveables [i].GetSaveData ();
  8.             SavedData [id] = data;
  9.         }
  10.     }
  11.  
  12.     public void LoadObjects ()
  13.     {
  14.         var enumerator = SavedData.GetEnumerator();
  15.         while( enumerator.MoveNext() )
  16.         {
  17.             print (enumerator.Current.Key + enumerator.Current.Value);
  18.             var restoreObj = GameObject.Find (enumerator.Current.Key).GetComponent<AbstractSaveableMb> ();
  19.             restoreObj.RestoreData (enumerator.Current.Value);
  20.         }
  21.     }
  22.  
  23.  
  24.  
  25.  
  26.  
  27. // IN ELEVATOR SCRIPT ....
  28.  
  29. public override void RestoreData (object data) // tell RestoreDate that ElevInfo is the object data
  30.     {
  31.         ElevInfo = (ElevatorInfo) data;
  32.  
  33.         print ("restore data has been called.. on .. " + ElevInfo.Floor);
  34.         if (floor != ElevInfo.Floor) {
  35.             floor = ElevInfo.Floor;
  36.         }
  37.  
  38.         if (floor == 0) { // Then, play the correct animation depending on the newly updated elevator state.
  39.             animator.Play (idleBottomAnimation.name);
  40.         }
  41.         if (floor == 1) {
  42.             animator.Play (idleTopAnimation.name);
  43.         }
  44.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement