EnviromentSetting.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using System.Text.RegularExpressions;
  6. using Newtonsoft.Json;
  7. /* 本文件包含EnviromentSetting 主要功能上游戏运行环境设定
  8. */
  9. public static class EnviromentSetting
  10. {
  11. // 服务器ip
  12. public const string serverIp = "101.34.23.118";
  13. //language.json读取和存放
  14. public static string langFilePath = "Assets/Resources/Data/languages.json";
  15. public static Dictionary<string, object> languageData = null;
  16. // access Token
  17. public static string accessToken;
  18. //系统语言 default=en
  19. public static string languageCode = "en";
  20. //操作系统
  21. public static string platform = "NA";
  22. // Unity Unique Id
  23. public static string UUID = null;
  24. // 狗的数据库
  25. public static string dogDBFilePath = "Assets/Resources/Data/dogDB.json";
  26. public static DogBreed[] dogBreeds;
  27. //用于获取多层级Dictionary中的value
  28. public static string GetValueAtPath(Dictionary<string, object> root, string[] path)
  29. {
  30. Dictionary<string, object> current = root;
  31. int count = 0;
  32. foreach (string key in path)
  33. {
  34. string rawValue = current[key].ToString();
  35. rawValue = Regex.Replace(rawValue, @"[\r\n]", "");
  36. if (count == path.Length-1)
  37. {
  38. return rawValue;
  39. }
  40. Dictionary<string, object> value = JsonConvert.DeserializeObject<Dictionary<string, object>>(rawValue);
  41. current = value;
  42. count++;
  43. }
  44. return null;
  45. }
  46. }