123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System;
- using System.Linq;
- using Newtonsoft.Json.Linq;
- /// <summary>
- /// 宝石列表vo[就是界面上有显示可以合成几个宝石数量的]
- /// </summary>
- public class GemDataVo
- {
- public GemDataVo(int id)
- {
- this.gemId = id;
- //this.num = num;
- }
- /// <summary>
- /// 宝石id
- /// </summary>
- public int gemId { get; set; }
- /// <summary>
- /// 名称
- /// </summary>
- public string name
- {
- get
- {
- return this.itemMo.name;
- }
- }
- /// <summary>
- /// 可以合成的数量
- /// </summary>
- public int comploseNum
- {
- get
- {
- //int lv = this.gemMo.levellimit;
- //if (UserProxy.Instance.player.gemInfo.level < lv)
- //{
- // return 0;
- //}
- Dictionary<string, ItemVo> collectItemDic = UserProxy.Instance.player.collectItem.collectItemDic;
- //查看是否已经存在图纸
- if (this.gemMo.drawItem != string.Empty && !collectItemDic.ContainsKey(this.gemMo.drawItem))
- {
- return 0;
- }
- //配方宝石
- string[] list = this.gemMo.composeGem.Split(',');
- string formulaId = list[0];
- int formulanum = int.Parse(list[1]);
- //配方金币
- int gold = int.Parse(this.gemMo.composeGold);
- //合成需要的材料
- string materialId = "";
- int num = 0;
- int mCount = 0;
- if (this.gemMo.composeMaterial != string.Empty)
- {
- string[] sList = this.gemMo.composeMaterial.Split(',');
- materialId = sList[0];
- num = int.Parse(sList[1]);
- mCount = collectItemDic[materialId].count;
- }
- //按照配方宝石算可以合成几个宝石
- int count = 0;
- if (collectItemDic.ContainsKey(formulaId))
- {
- count = collectItemDic[formulaId].count;
- }
-
- int n = (int)Math.Floor(1.0f*count / formulanum);
- Debug.Log("n-----------------------"+n);
-
- int userGold = UserProxy.Instance.player.baseInfo.gold;
-
- int index = 0;
- for (int i = 0; i < n; i++)
- {
- userGold -= gold;
- if (userGold <= 0)
- {
- break;
- }
- if (this.gemMo.composeMaterial != string.Empty)
- {
- mCount -= num;
- if (mCount <= 0)
- {
- break;
- }
- }
-
- index += 1;
- }
- return index;
- }
- }
- public sm_gem_formula gemMo
- {
- get
- {
- return GameConfigData.Ins.Getgem_formulaMo(this.gemId);
- }
- }
- /// <summary>
- /// 配方信息
- /// </summary>
- /// <param name="gemId"></param>
- /// <param name="num"></param>
- /// <returns></returns>
- public formulaVo getCurComplseGemFormulaVo(int gemId,int num = 1)
- {
- formulaVo vo = new formulaVo(gemId, num);
- return vo;
- }
- /// <summary>
- /// mo
- /// </summary>
- public sm_item_base itemMo
- {
- get
- {
- return sm_item_base.GetMoById(this.gemId);
- }
- }
- }
- /// <summary>
- /// 配方vo
- /// </summary>
- public class formulaVo
- {
- public formulaVo(int id,int num)
- {
- this.gemId = id;
- this.num = num;
- }
- /// <summary>
- /// 合成的宝石id
- /// </summary>
- public int gemId { get; set; }
- /// <summary>
- /// 合成宝石数量
- /// </summary>
- public int num { get; set; }
- /// <summary>
- /// 配方宝石id
- /// </summary>
- public int gId
- {
- get
- {
- string[] sList = this.formulaMo.composeGem.Split(',');
- return int.Parse(sList[0]) * this.num;
- }
- }
- public int gIdNum
- {
- get
- {
- string[] sList = this.formulaMo.composeGem.Split(',');
- return int.Parse(sList[1]);
- }
- }
- /// <summary>
- /// 配方金币
- /// </summary>
- public int gold
- {
- get
- {
- return int.Parse(this.formulaMo.composeGold);
- }
- }
- /// <summary>
- /// 合成宝石需要的金币是否充足 true;充足
- /// </summary>
- public bool isEnoughGold
- {
- get
- {
- if (UserProxy.Instance.player.baseInfo.gold >= this.gold*this.num)
- {
- return true;
- }
- return false;
- }
- }
- /// <summary>
- /// 配方中消耗的宝石数量是否充足 true;充足
- /// </summary>
- public bool isEnoughGem
- {
- get
- {
- if (UserProxy.Instance.player.collectItem.collectItemDic.ContainsKey(this.gId.ToString()) && UserProxy.Instance.player.collectItem.collectItemDic[this.gId.ToString()].count >= this.num)
- {
- return true;
- }
- return false;
- }
- }
- /// <summary>
- /// 辅助材料
- /// </summary>
- public int materialId
- {
- get
- {
- if (this.formulaMo.composeMaterial != string.Empty)
- {
- return int.Parse(this.formulaMo.composeMaterial.Split(',')[0]);
- }
- return 0;
- }
- }
- /// <summary>
- /// 数量
- /// </summary>
- public int materialNnm
- {
- get
- {
- if (this.formulaMo.composeMaterial != string.Empty)
- {
- return int.Parse(this.formulaMo.composeMaterial.Split(',')[1]) * this.num;
- }
- return 0;
- }
- }
- public sm_gem_formula formulaMo
- {
- get
- {
- return GameConfigData.Ins.Getgem_formulaMo(this.gemId);
- }
- }
- }
- /// <summary>
- /// 研究等级vo
- /// </summary>
- public class ResearchVo
- {
- /// <summary>
- /// 当前的研究等级
- /// </summary>
- public int level
- {
- get
- {
- return UserProxy.Instance.player.gemInfo.level;
- }
- }
- /// <summary>
- /// 已经解锁的宝石信息
- /// </summary>
- public List<ItemVo> unlockGemList
- {
- get
- {
- List<ItemVo> unlockGemList = new List<ItemVo>();
- int count = GameConfigData.Ins.gem_researchlevel.Count;
- if (this.level >= count)
- {
- return unlockGemList;
- }
- string[] sList = GameConfigData.Ins.Getgem_researchlevelMo(this.level).unlockGemIds.Split(',');
- foreach (string id in sList)
- {
- ItemVo vo = new ItemVo();
- vo.typeId = id;
- unlockGemList.Add(vo);
- }
- return unlockGemList;
- }
- }
- /// <summary>
- /// 下一研究等级解锁的宝石信息
- /// </summary>
- public List<ItemVo> nextUnlockGemList
- {
- get
- {
- List<ItemVo> nextUnlockGemList = new List<ItemVo>();
- int count = GameConfigData.Ins.gem_researchlevel.Count;
- if (this.level >= count)
- {
- return nextUnlockGemList;
- }
- string[] sList = GameConfigData.Ins.Getgem_researchlevelMo(this.level+1).unlockGemIds.Split(',');
- foreach (string id in sList)
- {
- ItemVo vo = new ItemVo();
- vo.typeId = id;
- nextUnlockGemList.Add(vo);
- }
- return nextUnlockGemList;
- }
- }
- /// <summary>
- /// 下一研究等级需要的玩家等级限制
- /// </summary>
- public int userLevelLimit
- {
- get
- {
- int count = GameConfigData.Ins.gem_researchlevel.Count;
- if (this.level >= count)
- {
- return 0;
- }
-
- return GameConfigData.Ins.Getgem_researchlevelMo(this.level + 1).userlevelLimit;
- }
- }
- /// <summary>
- /// 升下一等级需要消耗金币
- /// </summary>
- public int costGold
- {
- get
- {
- if (this.level >= 5)
- {
- return 0;
- }
- return int.Parse(GameConfigData.Ins.Getgem_researchlevelMo(this.level + 1).unlockLevelGoldCost);
- }
- }
- public bool isEnoughGold
- {
- get
- {
- if (UserProxy.Instance.player.baseInfo.gold < this.costGold)
- {
- return false;
- }
- return true;
- }
- }
- }
|