GemDataVo.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System;
  5. using System.Linq;
  6. using Newtonsoft.Json.Linq;
  7. /// <summary>
  8. /// 宝石列表vo[就是界面上有显示可以合成几个宝石数量的]
  9. /// </summary>
  10. public class GemDataVo
  11. {
  12. public GemDataVo(int id)
  13. {
  14. this.gemId = id;
  15. //this.num = num;
  16. }
  17. /// <summary>
  18. /// 宝石id
  19. /// </summary>
  20. public int gemId { get; set; }
  21. /// <summary>
  22. /// 名称
  23. /// </summary>
  24. public string name
  25. {
  26. get
  27. {
  28. return this.itemMo.name;
  29. }
  30. }
  31. /// <summary>
  32. /// 可以合成的数量
  33. /// </summary>
  34. public int comploseNum
  35. {
  36. get
  37. {
  38. //int lv = this.gemMo.levellimit;
  39. //if (UserProxy.Instance.player.gemInfo.level < lv)
  40. //{
  41. // return 0;
  42. //}
  43. Dictionary<string, ItemVo> collectItemDic = UserProxy.Instance.player.collectItem.collectItemDic;
  44. //查看是否已经存在图纸
  45. if (this.gemMo.drawItem != string.Empty && !collectItemDic.ContainsKey(this.gemMo.drawItem))
  46. {
  47. return 0;
  48. }
  49. //配方宝石
  50. string[] list = this.gemMo.composeGem.Split(',');
  51. string formulaId = list[0];
  52. int formulanum = int.Parse(list[1]);
  53. //配方金币
  54. int gold = int.Parse(this.gemMo.composeGold);
  55. //合成需要的材料
  56. string materialId = "";
  57. int num = 0;
  58. int mCount = 0;
  59. if (this.gemMo.composeMaterial != string.Empty)
  60. {
  61. string[] sList = this.gemMo.composeMaterial.Split(',');
  62. materialId = sList[0];
  63. num = int.Parse(sList[1]);
  64. mCount = collectItemDic[materialId].count;
  65. }
  66. //按照配方宝石算可以合成几个宝石
  67. int count = 0;
  68. if (collectItemDic.ContainsKey(formulaId))
  69. {
  70. count = collectItemDic[formulaId].count;
  71. }
  72. int n = (int)Math.Floor(1.0f*count / formulanum);
  73. Debug.Log("n-----------------------"+n);
  74. int userGold = UserProxy.Instance.player.baseInfo.gold;
  75. int index = 0;
  76. for (int i = 0; i < n; i++)
  77. {
  78. userGold -= gold;
  79. if (userGold <= 0)
  80. {
  81. break;
  82. }
  83. if (this.gemMo.composeMaterial != string.Empty)
  84. {
  85. mCount -= num;
  86. if (mCount <= 0)
  87. {
  88. break;
  89. }
  90. }
  91. index += 1;
  92. }
  93. return index;
  94. }
  95. }
  96. public sm_gem_formula gemMo
  97. {
  98. get
  99. {
  100. return GameConfigData.Ins.Getgem_formulaMo(this.gemId);
  101. }
  102. }
  103. /// <summary>
  104. /// 配方信息
  105. /// </summary>
  106. /// <param name="gemId"></param>
  107. /// <param name="num"></param>
  108. /// <returns></returns>
  109. public formulaVo getCurComplseGemFormulaVo(int gemId,int num = 1)
  110. {
  111. formulaVo vo = new formulaVo(gemId, num);
  112. return vo;
  113. }
  114. /// <summary>
  115. /// mo
  116. /// </summary>
  117. public sm_item_base itemMo
  118. {
  119. get
  120. {
  121. return sm_item_base.GetMoById(this.gemId);
  122. }
  123. }
  124. }
  125. /// <summary>
  126. /// 配方vo
  127. /// </summary>
  128. public class formulaVo
  129. {
  130. public formulaVo(int id,int num)
  131. {
  132. this.gemId = id;
  133. this.num = num;
  134. }
  135. /// <summary>
  136. /// 合成的宝石id
  137. /// </summary>
  138. public int gemId { get; set; }
  139. /// <summary>
  140. /// 合成宝石数量
  141. /// </summary>
  142. public int num { get; set; }
  143. /// <summary>
  144. /// 配方宝石id
  145. /// </summary>
  146. public int gId
  147. {
  148. get
  149. {
  150. string[] sList = this.formulaMo.composeGem.Split(',');
  151. return int.Parse(sList[0]) * this.num;
  152. }
  153. }
  154. public int gIdNum
  155. {
  156. get
  157. {
  158. string[] sList = this.formulaMo.composeGem.Split(',');
  159. return int.Parse(sList[1]);
  160. }
  161. }
  162. /// <summary>
  163. /// 配方金币
  164. /// </summary>
  165. public int gold
  166. {
  167. get
  168. {
  169. return int.Parse(this.formulaMo.composeGold);
  170. }
  171. }
  172. /// <summary>
  173. /// 合成宝石需要的金币是否充足 true;充足
  174. /// </summary>
  175. public bool isEnoughGold
  176. {
  177. get
  178. {
  179. if (UserProxy.Instance.player.baseInfo.gold >= this.gold*this.num)
  180. {
  181. return true;
  182. }
  183. return false;
  184. }
  185. }
  186. /// <summary>
  187. /// 配方中消耗的宝石数量是否充足 true;充足
  188. /// </summary>
  189. public bool isEnoughGem
  190. {
  191. get
  192. {
  193. if (UserProxy.Instance.player.collectItem.collectItemDic.ContainsKey(this.gId.ToString()) && UserProxy.Instance.player.collectItem.collectItemDic[this.gId.ToString()].count >= this.num)
  194. {
  195. return true;
  196. }
  197. return false;
  198. }
  199. }
  200. /// <summary>
  201. /// 辅助材料
  202. /// </summary>
  203. public int materialId
  204. {
  205. get
  206. {
  207. if (this.formulaMo.composeMaterial != string.Empty)
  208. {
  209. return int.Parse(this.formulaMo.composeMaterial.Split(',')[0]);
  210. }
  211. return 0;
  212. }
  213. }
  214. /// <summary>
  215. /// 数量
  216. /// </summary>
  217. public int materialNnm
  218. {
  219. get
  220. {
  221. if (this.formulaMo.composeMaterial != string.Empty)
  222. {
  223. return int.Parse(this.formulaMo.composeMaterial.Split(',')[1]) * this.num;
  224. }
  225. return 0;
  226. }
  227. }
  228. public sm_gem_formula formulaMo
  229. {
  230. get
  231. {
  232. return GameConfigData.Ins.Getgem_formulaMo(this.gemId);
  233. }
  234. }
  235. }
  236. /// <summary>
  237. /// 研究等级vo
  238. /// </summary>
  239. public class ResearchVo
  240. {
  241. /// <summary>
  242. /// 当前的研究等级
  243. /// </summary>
  244. public int level
  245. {
  246. get
  247. {
  248. return UserProxy.Instance.player.gemInfo.level;
  249. }
  250. }
  251. /// <summary>
  252. /// 已经解锁的宝石信息
  253. /// </summary>
  254. public List<ItemVo> unlockGemList
  255. {
  256. get
  257. {
  258. List<ItemVo> unlockGemList = new List<ItemVo>();
  259. int count = GameConfigData.Ins.gem_researchlevel.Count;
  260. if (this.level >= count)
  261. {
  262. return unlockGemList;
  263. }
  264. string[] sList = GameConfigData.Ins.Getgem_researchlevelMo(this.level).unlockGemIds.Split(',');
  265. foreach (string id in sList)
  266. {
  267. ItemVo vo = new ItemVo();
  268. vo.typeId = id;
  269. unlockGemList.Add(vo);
  270. }
  271. return unlockGemList;
  272. }
  273. }
  274. /// <summary>
  275. /// 下一研究等级解锁的宝石信息
  276. /// </summary>
  277. public List<ItemVo> nextUnlockGemList
  278. {
  279. get
  280. {
  281. List<ItemVo> nextUnlockGemList = new List<ItemVo>();
  282. int count = GameConfigData.Ins.gem_researchlevel.Count;
  283. if (this.level >= count)
  284. {
  285. return nextUnlockGemList;
  286. }
  287. string[] sList = GameConfigData.Ins.Getgem_researchlevelMo(this.level+1).unlockGemIds.Split(',');
  288. foreach (string id in sList)
  289. {
  290. ItemVo vo = new ItemVo();
  291. vo.typeId = id;
  292. nextUnlockGemList.Add(vo);
  293. }
  294. return nextUnlockGemList;
  295. }
  296. }
  297. /// <summary>
  298. /// 下一研究等级需要的玩家等级限制
  299. /// </summary>
  300. public int userLevelLimit
  301. {
  302. get
  303. {
  304. int count = GameConfigData.Ins.gem_researchlevel.Count;
  305. if (this.level >= count)
  306. {
  307. return 0;
  308. }
  309. return GameConfigData.Ins.Getgem_researchlevelMo(this.level + 1).userlevelLimit;
  310. }
  311. }
  312. /// <summary>
  313. /// 升下一等级需要消耗金币
  314. /// </summary>
  315. public int costGold
  316. {
  317. get
  318. {
  319. if (this.level >= 5)
  320. {
  321. return 0;
  322. }
  323. return int.Parse(GameConfigData.Ins.Getgem_researchlevelMo(this.level + 1).unlockLevelGoldCost);
  324. }
  325. }
  326. public bool isEnoughGold
  327. {
  328. get
  329. {
  330. if (UserProxy.Instance.player.baseInfo.gold < this.costGold)
  331. {
  332. return false;
  333. }
  334. return true;
  335. }
  336. }
  337. }