EnviromentSetting.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. using static System.Net.WebRequestMethods;
  8. /* 本文件包含EnviromentSetting 主要功能上游戏运行环境设定
  9. */
  10. public static class EnviromentSetting
  11. {
  12. // 服务器ip 正式发布需要替换掉ip
  13. public static string serverIp = "http://101.34.23.118";
  14. //language.json读取和存放
  15. public static string langFilePath = "Assets/Resources/Data/languages.json";
  16. public static Dictionary<string, object> languageData = null;
  17. // access Token
  18. public static string accessToken;
  19. public static DateTime accessTokenReceivedTime;
  20. // 不需要access Token的请求
  21. public static string[] accessTokenWhiteList = {
  22. "/api/login/token/",
  23. "/api/game/quick_start/",
  24. "/api/login/"
  25. };
  26. //系统语言 default=en
  27. public static string languageCode = "en";
  28. //操作系统
  29. public static string platform = "NA";
  30. // Unity Unique Id
  31. public static string UUID = null;
  32. // 狗的数据库
  33. public static string dogDBFilePath = "Assets/Resources/Data/dogDB.json";
  34. public static DogBreed[] dogBreeds;
  35. //用于获取多层级Dictionary中的value
  36. public static string GetValueAtPath(Dictionary<string, object> root, string[] path)
  37. {
  38. Dictionary<string, object> current = root;
  39. int count = 0;
  40. foreach (string key in path)
  41. {
  42. string rawValue = current[key].ToString();
  43. rawValue = Regex.Replace(rawValue, @"[\r\n]", "");
  44. if (count == path.Length-1)
  45. {
  46. return rawValue;
  47. }
  48. Dictionary<string, object> value = JsonConvert.DeserializeObject<Dictionary<string, object>>(rawValue);
  49. current = value;
  50. count++;
  51. }
  52. return null;
  53. }
  54. }