ConfigObject.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. using UnityEngine;
  2. using Newtonsoft.Json.Linq;
  3. using System.Collections.Generic;
  4. /// <summary>
  5. /// 配置数据结构
  6. /// </summary>
  7. public class ConfigObject:Dictionary<string,JObject>{}
  8. /// <summary>
  9. /// 已知设置可以在这里添加
  10. /// </summary>
  11. class LocalSettings {
  12. static int _comboCount = 0;
  13. static float _battleRuntime = 0;
  14. /// <summary>
  15. /// 这里我是定义了一个布尔变量, 也可以定义结构复杂的类型,
  16. /// 同样利用Value<T>方法转为强类型,然后在其他地方使用.
  17. /// 默认值的话,需要自己处理好,因为,一开始可能并不存在这个变量.
  18. /// </summary>
  19. static public bool IsBeginAnimationPlayed
  20. {
  21. get
  22. {
  23. var r = GameCfg.LocalSettings["BeginAnimationPlayed"];
  24. return (null != r ? r.Value<bool>() : false); // 默认值
  25. }
  26. set
  27. {
  28. GameCfg.LocalSettings["BeginAnimationPlayed"] = value;
  29. }
  30. }
  31. static public string DefaultUserName {
  32. get
  33. {
  34. var r = GameCfg.LocalSettings["DefaultUserName"];
  35. return (null != r ? r.Value<string>() : ""); // 默认值
  36. }
  37. set
  38. {
  39. GameCfg.LocalSettings["DefaultUserName"] = value;
  40. }
  41. }
  42. static public string DefaultPassword {
  43. get
  44. {
  45. var r = GameCfg.LocalSettings["DefaultPassword"];
  46. return (null != r ? r.Value<string>() : ""); // 默认值
  47. }
  48. set
  49. {
  50. GameCfg.LocalSettings["DefaultPassword"] = value;
  51. }
  52. }
  53. static public bool IsAgreementChecked {
  54. get {
  55. var b = GameCfg.LocalSettings["IsAgreementChecked"];
  56. return (null != b ? b.Value<bool>() : false);
  57. }
  58. set { GameCfg.LocalSettings["IsAgreementChecked"] = value; }
  59. }
  60. static public int LoadingWinSmallTipsIndex
  61. {
  62. get
  63. {
  64. var b = GameCfg.LocalSettings["LoadingWinSmallTipsIndex"];
  65. return (null != b ? b.Value<int>() : 0);
  66. }
  67. set { GameCfg.LocalSettings["LoadingWinSmallTipsIndex"] = value; }
  68. }
  69. /// <summary>
  70. /// 设置当前主界面
  71. /// </summary>
  72. static public string DisplayHeroUID
  73. {
  74. get
  75. {
  76. var r = GameCfg.LocalSettings["DisplayHeroUID"];
  77. return (null != r ? r.Value<string>() : ""); // 默认值
  78. }
  79. set
  80. {
  81. GameCfg.LocalSettings["DisplayHeroUID"] = value;
  82. }
  83. }
  84. ///// <summary>
  85. ///// 设置个人配置队伍信息
  86. ///// </summary>
  87. //static public Info_HeroTeamConfig MyFightTeam
  88. //{
  89. // get
  90. // {
  91. // var r = GameCfg.LocalSettings["MyFightTeam"];
  92. // return (null != r ? r.ToObject<Info_HeroTeamConfig>() : null); // 默认值
  93. // }
  94. // set
  95. // {
  96. // JToken ttoke = JToken.FromObject(value);
  97. // GameCfg.LocalSettings["MyFightTeam"] = ttoke;
  98. // }
  99. //}
  100. /// <summary>
  101. ///
  102. /// </summary>
  103. static public int MusicVolume
  104. {
  105. get
  106. {
  107. var r = GameCfg.LocalSettings["MusicVolume"];
  108. return (null != r ? r.Value<int>() : 50); // 默认值
  109. }
  110. set
  111. {
  112. GameCfg.LocalSettings["MusicVolume"] = value;
  113. }
  114. }
  115. /// <summary>
  116. ///
  117. /// </summary>
  118. static public int EffectVolume
  119. {
  120. get
  121. {
  122. var r = GameCfg.LocalSettings["EffectVolume"];
  123. return (null != r ? r.Value<int>() : 50); // 默认值
  124. }
  125. set
  126. {
  127. GameCfg.LocalSettings["EffectVolume"] = value;
  128. }
  129. }
  130. /// <summary>
  131. /// 关卡地图弹出的状态记录
  132. /// 1= 直接进入地图放大状态,显示当前所在位置
  133. /// 0= 世界地图模式状态
  134. /// </summary>
  135. static public int ArenasMapFlag_IsNewPlayer
  136. {
  137. get
  138. {
  139. var r = GameCfg.LocalSettings["ArenasMapFlag"];
  140. return (null != r ? r.Value<int>() : 0); // 默认值
  141. }
  142. set
  143. {
  144. GameCfg.LocalSettings["ArenasMapFlag"] = value;
  145. }
  146. }
  147. /// <summary>
  148. ///
  149. /// </summary>
  150. static public int PlayerImageBorderId
  151. {
  152. get
  153. {
  154. var r = GameCfg.LocalSettings["PlayerImageBorderId"];
  155. return (null != r ? r.Value<int>() : 0); // 默认值
  156. }
  157. set
  158. {
  159. GameCfg.LocalSettings["PlayerImageBorderId"] = value;
  160. }
  161. }
  162. /// <summary>
  163. /// 最大连击
  164. /// </summary>
  165. static public int MaxCombCount
  166. {
  167. get;
  168. set;
  169. }
  170. /// <summary>
  171. /// 战斗连击
  172. /// </summary>
  173. static public int BattleComboCount
  174. {
  175. get
  176. {
  177. return _comboCount;
  178. }
  179. set
  180. {
  181. _comboCount = value;
  182. }
  183. }
  184. /// <summary>
  185. /// 战斗用时
  186. /// </summary>
  187. static public float BattleRuntime
  188. {
  189. get
  190. {
  191. return _battleRuntime;
  192. }
  193. set
  194. {
  195. _battleRuntime = value;
  196. }
  197. }
  198. }