StorageDataManager.cs 743 B

123456789101112131415161718192021222324252627282930
  1. using System.Collections.Generic;
  2. namespace GFGGame
  3. {
  4. public class StorageDataManager : SingletonBase<StorageDataManager>
  5. {
  6. private Dictionary<int, int> _storangeInfoById = new Dictionary<int, int>();
  7. public void Clear()
  8. {
  9. _storangeInfoById.Clear();
  10. }
  11. public void InitStorageInfo(int key, int value)
  12. {
  13. if (!_storangeInfoById.ContainsKey(key))
  14. {
  15. _storangeInfoById.Add(key, value);
  16. }
  17. _storangeInfoById[key] = value;
  18. }
  19. public int GetStorageValue(int key)
  20. {
  21. int value = 0;
  22. _storangeInfoById.TryGetValue(key, out value);
  23. return value;
  24. }
  25. }
  26. }