using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using System.Linq;
using Newtonsoft.Json.Linq;
///
/// 宝石列表vo[就是界面上有显示可以合成几个宝石数量的]
///
public class GemDataVo
{
public GemDataVo(int id)
{
this.gemId = id;
//this.num = num;
}
///
/// 宝石id
///
public int gemId { get; set; }
///
/// 名称
///
public string name
{
get
{
return this.itemMo.name;
}
}
///
/// 可以合成的数量
///
public int comploseNum
{
get
{
//int lv = this.gemMo.levellimit;
//if (UserProxy.Instance.player.gemInfo.level < lv)
//{
// return 0;
//}
Dictionary 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);
}
}
///
/// 配方信息
///
///
///
///
public formulaVo getCurComplseGemFormulaVo(int gemId,int num = 1)
{
formulaVo vo = new formulaVo(gemId, num);
return vo;
}
///
/// mo
///
public sm_item_base itemMo
{
get
{
return sm_item_base.GetMoById(this.gemId);
}
}
}
///
/// 配方vo
///
public class formulaVo
{
public formulaVo(int id,int num)
{
this.gemId = id;
this.num = num;
}
///
/// 合成的宝石id
///
public int gemId { get; set; }
///
/// 合成宝石数量
///
public int num { get; set; }
///
/// 配方宝石id
///
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]);
}
}
///
/// 配方金币
///
public int gold
{
get
{
return int.Parse(this.formulaMo.composeGold);
}
}
///
/// 合成宝石需要的金币是否充足 true;充足
///
public bool isEnoughGold
{
get
{
if (UserProxy.Instance.player.baseInfo.gold >= this.gold*this.num)
{
return true;
}
return false;
}
}
///
/// 配方中消耗的宝石数量是否充足 true;充足
///
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;
}
}
///
/// 辅助材料
///
public int materialId
{
get
{
if (this.formulaMo.composeMaterial != string.Empty)
{
return int.Parse(this.formulaMo.composeMaterial.Split(',')[0]);
}
return 0;
}
}
///
/// 数量
///
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);
}
}
}
///
/// 研究等级vo
///
public class ResearchVo
{
///
/// 当前的研究等级
///
public int level
{
get
{
return UserProxy.Instance.player.gemInfo.level;
}
}
///
/// 已经解锁的宝石信息
///
public List unlockGemList
{
get
{
List unlockGemList = new List();
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;
}
}
///
/// 下一研究等级解锁的宝石信息
///
public List nextUnlockGemList
{
get
{
List nextUnlockGemList = new List();
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;
}
}
///
/// 下一研究等级需要的玩家等级限制
///
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;
}
}
///
/// 升下一等级需要消耗金币
///
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;
}
}
}