PappaP

GameSaveManager:ResetScriptables()

Mar 9th, 2020
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.38 KB | None | 0 0
  1. public void ResetScriptables()
  2.     {
  3.         Debug.Log("Resetting Scriptables");
  4.         for (int i = 0; i < objects.Count; i++)
  5.         {
  6.          
  7.             switch (objects[i].GetType().FullName)
  8.             {
  9.                 case "FloatValue":
  10.                     FloatValue ftmp = (FloatValue)objects[i];
  11.                     ftmp.RuntimeValue = ftmp.initialValue;
  12.                     Debug.Log("resetting FloatValue");
  13.                     break;
  14.  
  15.                 case "BoolValue":
  16.                     BoolValue btmp = (BoolValue)objects[i];
  17.                     btmp.RuntimeValue = btmp.initialValue;
  18.                     Debug.Log("resetting BoolValue");
  19.                     break;
  20.  
  21.                 case "Inventory":
  22.                     Inventory itmp = (Inventory)objects[i];
  23.                     itmp.coins = 0;
  24.                     itmp.maxMagic = 10;
  25.                     itmp.items.Clear();
  26.                     itmp.numberOfKeys = 0;
  27.                     Debug.Log("Inventory Reset");
  28.                     break;
  29.  
  30.                  
  31.  
  32.                 default:
  33.                     break;
  34.             }
  35.  
  36.  
  37.  
  38.  
  39.             if(File.Exists(Application.persistentDataPath +
  40.                 string.Format($"/{i}.dat")))
  41.             {
  42.                 File.Delete(Application.persistentDataPath +
  43.                 string.Format($"/{i}.dat"));
  44.             }
  45.  
  46.  
  47.         }
  48.     }
Advertisement
Add Comment
Please, Sign In to add comment