GameCollectEquips.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. using Newtonsoft.Json.Linq;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. /// <summary>
  5. /// 玩家装备仓库集合
  6. /// </summary>
  7. public class GameCollectEquips
  8. {
  9. /// <summary>
  10. /// 装备集合
  11. /// </summary>
  12. public Dictionary<int, UserEquipmentVo> equipments = new Dictionary<int, UserEquipmentVo>();
  13. /// <summary>
  14. /// 武器记录
  15. /// </summary>
  16. public List<string> weaponRecord = new List<string>();
  17. /// <summary>
  18. /// 查询当前英雄可用的装备列表
  19. /// </summary>
  20. /// <param name="heroTypeid"></param>
  21. /// <returns></returns>
  22. public List<UserEquipmentVo> FindUseableEquips(int heroTypeid)
  23. {
  24. var li = new List<UserEquipmentVo>();
  25. foreach (var kv in equipments)
  26. {
  27. var mo = sm_item_weapon.GetMoById(int.Parse(kv.Value.typeId));
  28. if (null != mo)
  29. {
  30. string[] heroList = mo.hero_id.Split(',');
  31. foreach (string hero_id in heroList)
  32. {
  33. if (hero_id == heroTypeid.ToString())
  34. {
  35. li.Add(kv.Value);
  36. }
  37. }
  38. }
  39. }
  40. return li;
  41. }
  42. public void InitItemData(JObject store)
  43. {
  44. if (store["equipment"] != null)
  45. {
  46. // {uid:{typeId:"",level:x,...},uid:{...},...}
  47. equipments = store["equipment"].ToObject<Dictionary<int, UserEquipmentVo>>();
  48. foreach (var kv in equipments)
  49. {
  50. kv.Value.uid = kv.Key.ToString();
  51. }
  52. }
  53. if (store["weaponRecord"] != null)
  54. {
  55. this.weaponRecord.Clear();
  56. JArray arr = JArray.Parse(store["weaponRecord"].ToString());
  57. foreach (JToken id in arr)
  58. {
  59. this.weaponRecord.Add(id.ToString());
  60. }
  61. }
  62. }
  63. }
  64. /// <summary>
  65. /// 玩家装备数据结构
  66. /// </summary>
  67. public class UserEquipmentVo : ItemVo
  68. {
  69. /// <summary>
  70. /// 模板id
  71. /// </summary>
  72. //public new int typeId;
  73. /// <summary>
  74. /// 装备英雄的id, 默认0
  75. /// </summary>
  76. public int herouid;
  77. // todo: 其它字段带补充(后期加入强化后 --王刚2020年1月2日14:13:59)
  78. #region 暂空
  79. /// <summary>
  80. /// 当前星级
  81. /// </summary>
  82. public int starLevel;
  83. /// <summary>
  84. /// 当前星级上限
  85. /// </summary>
  86. public int maxStar;
  87. /// <summary>
  88. /// 当前等级
  89. /// </summary>
  90. //public new int level;
  91. /// <summary>
  92. /// 当前经验
  93. /// </summary>
  94. public int exp;
  95. /// <summary>
  96. /// 下一等级经验
  97. /// </summary>
  98. public int nextExp
  99. {
  100. get
  101. {
  102. if (this.starLimitLv == this.level)
  103. {
  104. return exp;
  105. }
  106. //var mo = GameConfigData.Ins.Getweapon_levelexpMo(this.level+1);
  107. var mo = GameConfigData.Ins.Getweapon_levelexpMo(EquipMo().quality, this.level + 1);
  108. if (mo != null)
  109. {
  110. return mo.requiredExp;
  111. }
  112. var lastMo = GameConfigData.Ins.Getweapon_levelexpMo(EquipMo().quality, this.level);
  113. if (lastMo != null)
  114. {
  115. return lastMo.requiredExp;
  116. }
  117. return 0;
  118. }
  119. }
  120. /// <summary>
  121. /// 是否锁定(锁定后不会被误卖)
  122. /// </summary>
  123. public int isLocked;
  124. /// <summary>
  125. /// 是否使用中(装备)
  126. /// </summary>
  127. public int WhoIsUsing { get { return this.herouid; } }
  128. /// <summary>
  129. /// 等级
  130. /// </summary>
  131. public int level { get; set; }
  132. /// <summary>
  133. /// 消耗的道具----突破
  134. /// </summary>
  135. public List<ItemVo> costItem_tupo
  136. {
  137. get
  138. {
  139. List<ItemVo> list = new List<ItemVo>();
  140. if (this.starLevel >= 5)
  141. {
  142. return list;
  143. }
  144. sm_weaponextra_level mo = sm_weaponextra_level.GetMoById(int.Parse(this.typeId), this.starLevel + 1);
  145. string[] sList = mo.costItems.Split(';');
  146. foreach (string item in sList)
  147. {
  148. string[] str = item.Split(',');
  149. ItemVo vo = new ItemVo();
  150. vo.typeId = str[0];
  151. vo.count = int.Parse(str[1]);
  152. list.Add(vo);
  153. }
  154. //ItemVo itVo = new ItemVo();
  155. //itVo.typeId = mo.segID.ToString();
  156. //itVo.count = mo.segNum;
  157. //list.Add(itVo);
  158. return list;
  159. }
  160. }
  161. /// <summary>
  162. /// 总览属性
  163. /// </summary>
  164. public Dictionary<EHeroProperties, int> baseAttr
  165. {
  166. get
  167. {
  168. Dictionary<EHeroProperties, int> attr = new Dictionary<EHeroProperties, int>();
  169. sm_weaponextra_level mo = sm_weaponextra_level.GetMoById(int.Parse(this.typeId), this.starLevel);
  170. //生命
  171. int hp = mo.hp + (this.level - 1) * mo.hpRate;
  172. //Debug.Log("当前等级-----hp--------" + hp);
  173. //float addHp = hp + hp * (1.0f*this.Mo().GetYanlingExt().additional_hpUpperlimit/100);
  174. if (hp != 0)
  175. {
  176. attr[EHeroProperties.HP] = hp;
  177. }
  178. int mp = mo.nengliangzhi + (this.level - 1) * mo.nengliangzhiRate;
  179. if (mp != 0)
  180. {
  181. attr[EHeroProperties.NENGLIANGZHI] = mp;
  182. }
  183. //暴击
  184. int crit = mo.baoji + (this.level - 1) * mo.baojiRate;
  185. //Debug.Log("当前等级-----crit--------" + crit);
  186. //float addCrit = crit + crit * 1.0f * this.Mo().GetYanlingExt().additional_critDamage/100;
  187. if (crit != 0)
  188. {
  189. attr[EHeroProperties.CRICITAL] = crit;
  190. }
  191. //物理攻击
  192. int phyAtk = mo.wuligongji + (this.level - 1) * mo.wuligongjiRate;
  193. //Debug.Log("当前等级-------phyAtk------" + phyAtk);
  194. //float addPhyAtk = phyAtk + phyAtk * 1.0f * this.Mo().GetYanlingExt().additional_phyDamage/100;
  195. if (phyAtk != 0)
  196. {
  197. attr[EHeroProperties.WULIGONGJI] = phyAtk;
  198. }
  199. //防御护甲
  200. int phyDef = mo.fangyuhujia + (this.level - 1) * mo.fangyuhujiaRate;
  201. //Debug.Log("当前等级-----phyDef--------" + phyDef);
  202. //float addPhyDef = phyDef + phyDef * 1.0f * this.Mo().GetYanlingExt().additional_phyDefend/100;
  203. if (phyDef != 0)
  204. {
  205. attr[EHeroProperties.FANGYUHUJIA] = phyDef;
  206. }
  207. //攻击速度--废弃
  208. //int atkSpeed = mo.gongjisudu + (this.level - 1) * mo.gongjisuduRate;
  209. //Debug.Log("当前等级----atkSpeed---------" + atkSpeed);
  210. //float addAtkSpeed = atkSpeed + atkSpeed * 1.0f * this.Mo().GetYanlingExt().additional_atkSpeed/100;
  211. //if (atkSpeed != 0)
  212. //{
  213. // attr[EHeroProperties.ATKSPEED] = atkSpeed;
  214. //}
  215. //法术强度
  216. int fashuqiangdu = mo.fashuqiangdu + (this.level - 1) * mo.fashuqiangduRate;
  217. if (fashuqiangdu != 0)
  218. {
  219. attr[EHeroProperties.FASHUQIANGDU] = fashuqiangdu;
  220. }
  221. //魔法抗性
  222. int mofakangxing = mo.mofakangxing + (this.level - 1) * mo.mofakangxingRate;
  223. if (mofakangxing != 0)
  224. {
  225. attr[EHeroProperties.MOFAKANGXING] = mofakangxing;
  226. }
  227. int yanli = mo.yanli + (this.level - 1) * mo.yanliRate;
  228. if (yanli != 0)
  229. {
  230. attr[EHeroProperties.YANLI] = yanli;
  231. }
  232. return attr;
  233. }
  234. }
  235. /// <summary>
  236. /// 突破后属性变化值
  237. /// </summary>
  238. public Dictionary<EHeroProperties, int> changeAttr
  239. {
  240. get
  241. {
  242. Dictionary<EHeroProperties, int> attr = new Dictionary<EHeroProperties, int>();
  243. int nextStar = this.starLevel + 1;
  244. if (this.starLevel >= 5)
  245. {
  246. nextStar = 5;
  247. }
  248. sm_weaponextra_level mo = sm_weaponextra_level.GetMoById(int.Parse(this.typeId), nextStar);
  249. //生命
  250. int hp = mo.hp + (this.level - 1) * mo.hpRate;
  251. if (hp != 0)
  252. {
  253. attr[EHeroProperties.HP] = hp;
  254. }
  255. int mp = mo.nengliangzhi + (this.level - 1) * mo.nengliangzhiRate;
  256. if (mp != 0)
  257. {
  258. attr[EHeroProperties.NENGLIANGZHI] = mp;
  259. }
  260. //暴击
  261. int crit = mo.baoji + (this.level - 1) * mo.baojiRate;
  262. if (crit != 0)
  263. {
  264. attr[EHeroProperties.CRICITAL] = crit;
  265. }
  266. //物理攻击
  267. int phyAtk = mo.wuligongji + (this.level - 1) * mo.wuligongjiRate;
  268. if (phyAtk != 0)
  269. {
  270. attr[EHeroProperties.WULIGONGJI] = phyAtk;
  271. }
  272. //防御护甲
  273. int phyDef = mo.fangyuhujia + (this.level - 1) * mo.fangyuhujiaRate;
  274. if (phyDef != 0)
  275. {
  276. attr[EHeroProperties.FANGYUHUJIA] = phyDef;
  277. }
  278. //攻击速度
  279. //int atkSpeed = mo.gongjisudu + (this.level - 1) * mo.gongjisuduRate;
  280. //if (atkSpeed != 0)
  281. //{
  282. // attr[EHeroProperties.ATKSPEED] = atkSpeed;
  283. //}
  284. //法术强度
  285. int fashuqiangdu = mo.fashuqiangdu + (this.level - 1) * mo.fashuqiangduRate;
  286. if (fashuqiangdu != 0)
  287. {
  288. attr[EHeroProperties.FASHUQIANGDU] = fashuqiangdu;
  289. }
  290. //魔法抗性
  291. int mofakangxing = mo.mofakangxing + (this.level - 1) * mo.mofakangxingRate;
  292. if (mofakangxing != 0)
  293. {
  294. attr[EHeroProperties.MOFAKANGXING] = mofakangxing;
  295. }
  296. int yanli = mo.yanli + (this.level - 1) * mo.yanliRate;
  297. if (yanli != 0)
  298. {
  299. attr[EHeroProperties.YANLI] = yanli;
  300. }
  301. return attr;
  302. }
  303. }
  304. /// <summary>
  305. /// 当前星级限制的等级
  306. /// </summary>
  307. public int starLimitLv
  308. {
  309. get
  310. {
  311. sm_weaponextra_level mo = sm_weaponextra_level.GetMoById(int.Parse(this.typeId), this.starLevel);
  312. if (mo == null)
  313. {
  314. return 0;
  315. }
  316. return mo.promoteLv;
  317. }
  318. }
  319. /// <summary>
  320. /// 突破的玩家等级限制
  321. /// </summary>
  322. public int userLimitLv
  323. {
  324. get
  325. {
  326. if (this.starLevel >= 5)
  327. {
  328. return 0;
  329. }
  330. sm_weaponextra_level mo = sm_weaponextra_level.GetMoById(int.Parse(this.typeId), this.starLevel + 1);
  331. return mo.userlvLimit;
  332. }
  333. }
  334. /// <summary>
  335. /// 突破后的星级等级限制
  336. /// </summary>
  337. public int lastStarLimitLv_Tupo
  338. {
  339. get
  340. {
  341. if (this.starLevel >= 5)
  342. {
  343. return 0;
  344. }
  345. sm_weaponextra_level mo = sm_weaponextra_level.GetMoById(int.Parse(this.typeId), this.starLevel + 1);
  346. if (mo == null)
  347. {
  348. return 0;
  349. }
  350. return mo.promoteLv;
  351. }
  352. }
  353. /// <summary>
  354. /// 是不是升级按钮 true:是
  355. /// </summary>
  356. public bool isUpgrade
  357. {
  358. get
  359. {
  360. if (this.starLevel >= 5)
  361. {
  362. return true;
  363. }
  364. //&& UserProxy.Instance.player.baseInfo.level >= sm_heroextra_level_tupo.GetMoById(int.Parse(this.typeId), this.curStar + 1).userlvLimit
  365. if (this.level >= this.starLimitLv)
  366. {
  367. return false;
  368. }
  369. return true;
  370. }
  371. }
  372. /// <summary>
  373. /// 升级需要的材料道具
  374. /// </summary>
  375. public List<ItemVo> costItem_Upgrade
  376. {
  377. get
  378. {
  379. List<ItemVo> list = new List<ItemVo>();
  380. if (this.starLevel >= 5)
  381. {
  382. return list;
  383. }
  384. List<sm_item_stones_type> stonelist = sm_item_stones_type.getItemStoneList(Enum_CostItemStonesType.Wuqi);
  385. if (stonelist.Count == 0)
  386. {
  387. return list;
  388. }
  389. Dictionary<string, ItemVo> collectItemDic = UserProxy.Instance.player.collectItem.collectItemDic;
  390. foreach (sm_item_stones_type item in stonelist)
  391. {
  392. string typeId = item.typeId.ToString();
  393. foreach (KeyValuePair<string, ItemVo> kv in collectItemDic)
  394. {
  395. if (kv.Value.typeId == typeId)
  396. {
  397. ItemVo itVo = new ItemVo();
  398. itVo.typeId = typeId;
  399. itVo.count = kv.Value.count;
  400. list.Add(itVo);
  401. }
  402. }
  403. }
  404. return list;
  405. }
  406. }
  407. /// <summary>
  408. ///
  409. /// </summary>
  410. public int costGold_tupo
  411. {
  412. get
  413. {
  414. if (this.starLevel >= 5)
  415. {
  416. return 0;
  417. }
  418. sm_weaponextra_level mo = sm_weaponextra_level.GetMoById(int.Parse(this.typeId), this.starLevel + 1);
  419. return mo.gold;
  420. }
  421. }
  422. #endregion
  423. /// <summary>
  424. /// 获取装备的Mo(基础数据), 武器扩展数据请继续.GetWeaponExt();
  425. /// </summary>
  426. /// <returns></returns>
  427. public sm_item_base EquipMo()
  428. {
  429. return sm_item_base.GetMoById(int.Parse(this.typeId));
  430. }
  431. #region-------->武器商店
  432. /// <summary>
  433. /// 是否已经售罄 true:是
  434. /// </summary>
  435. public bool isSellOut { get; set; }
  436. //{
  437. // get
  438. // {
  439. // UserProxy.Instance.player.weaponReward
  440. // return false;
  441. // }
  442. //}
  443. /// <summary>
  444. /// 售价
  445. /// </summary>
  446. public int cost { get; set; }
  447. public int limitNum
  448. {
  449. get
  450. {
  451. return 1;
  452. }
  453. }
  454. #endregion
  455. }