/// <summary> /// 配方列中是否包含物品 /// </summary> /// <param name="tabFormula">配方列</param> /// <param name="nItemDataID">物品</param> /// <returns>是否包含</returns> /// 1、配方为空,则不包含; /// 2、物品ID无效,则包含; private bool IsStuffInFormula(Tab_QianKunDaiFormula tabFormula, int nItemDataID) { if (null == tabFormula) { return(false); } if (GlobeVar.INVALID_ID == nItemDataID) { return(true); } for (int ii = 0; ii < tabFormula.getStuffIDCount(); ++ii) { int nStuffID = tabFormula.GetStuffIDbyIndex(ii); if (GlobeVar.INVALID_ID == nStuffID) { return(false); } if (nStuffID == nItemDataID) { return(true); } } return(false); }
bool IsAllStuffRight(Tab_QianKunDaiFormula tabFormula, bool bAllGem) { // 暂时宝石参与的乾坤袋配方 只有升级和洗宝石两种 全宝石不考虑普通合成 if (tabFormula.Type == (int)FORMULA_TYPE.TYPE_GEMLEVELUP) { // 只可能3个同级 同属性宝石 if (!bAllGem) { return(false); } // 先判断同等级 选择宝石等级数量为1 且需要等于配方填的等级 if (false == IsGemFormulaSameLevel(tabFormula)) { return(false); } // 判断同属性 if (GetChooseGemClassCount() != 1) { return(false); } return(true); } else if (tabFormula.Type == (int)FORMULA_TYPE.TYPE_GEMREFRESH) { // 只可能3个同级 属性互不相同宝石 if (!bAllGem) { return(false); } // 先判断同等级 选择宝石等级数量为1 且需要等于配方填的等级 if (false == IsGemFormulaSameLevel(tabFormula)) { return(false); } // 判断属性互不相同 if (GetChooseGemClassCount() != tabFormula.GetStuffCountbyIndex(0)) { return(false); } return(true); } else { int nStuffKinds = 0; for (int i = 0; i < tabFormula.getStuffIDCount(); i++) { if (tabFormula.GetStuffIDbyIndex(i) != GlobeVar.INVALID_ID) { nStuffKinds += 1; } } if (nStuffKinds != m_ChooseStuffKinds.Count || nStuffKinds <= 0) { return(false); } for (int i = 0; i < tabFormula.getStuffIDCount(); i++) { if (!m_ChooseStuffKinds.ContainsKey(tabFormula.GetStuffIDbyIndex(i)) && tabFormula.GetStuffIDbyIndex(i) != GlobeVar.INVALID_ID) { return(false); } } return(true); } }
void CombineFormulaOK() { if (m_RightFormula == null) { return; } // 确认可合成最大数量 若大于1 则弹出数量确认框 // 最大合成数量 即为各种素材的最小组数 int nMinHoldGroup = 999; if (m_RightFormula.Type == (int)FORMULA_TYPE.TYPE_GEMLEVELUP) { if (m_ChooseStuffGuid.Count > 0) { GameItem item = GameManager.gameManager.PlayerDataPool.BackPack.GetItemByGuid(m_ChooseStuffGuid[0]); if (item != null && item.IsValid()) { if (m_ChooseStuffKinds.ContainsKey(item.DataID)) { if (m_RightFormula.GetStuffCountbyIndex(0) > 0) { nMinHoldGroup = m_ChooseStuffKinds[item.DataID] / m_RightFormula.GetStuffCountbyIndex(0); } else { nMinHoldGroup = m_ChooseStuffKinds[item.DataID] / 3; } } } } } else if (m_RightFormula.Type == (int)FORMULA_TYPE.TYPE_GEMREFRESH) { foreach (KeyValuePair <int, int> pair in m_ChooseStuffKinds) { if (nMinHoldGroup > pair.Value) { nMinHoldGroup = pair.Value; } } } else { // 查找配方时已经确定 玩家选择的材料种类数和配方中的种类数必须相等 for (int i = 0; i < m_RightFormula.getStuffIDCount(); i++) { int nStuffID = m_RightFormula.GetStuffIDbyIndex(i); int nStuffCount = m_RightFormula.GetStuffCountbyIndex(i); if (nStuffID != GlobeVar.INVALID_ID && m_ChooseStuffKinds.ContainsKey(nStuffID)) { int nPlayerHoldCount = m_ChooseStuffKinds[nStuffID]; int nPlayerHoldGroup = nPlayerHoldCount / nStuffCount; if (nMinHoldGroup > nPlayerHoldGroup) { nMinHoldGroup = nPlayerHoldGroup; } } } } m_MaxCombineCount = nMinHoldGroup; m_NumChoose.SetActive(true); m_CurCombineNum = 1; m_NumChooseInput.value = "1"; m_MaxCombineCountLabel.text = StrDictionary.GetClientDictionaryString("#{2098}", nMinHoldGroup); SetCombineTotalMoney(); }