Beispiel #1
0
        /// <summary>
        /// 获取原料列表
        /// </summary>
        /// <param name="formulaID"></param>
        /// <param name="Gettype"></param>
        /// <returns></returns>
        public static List <FormulaItem> GetFormulaItemList(int formulaID, MaterialProductType Gettype)
        {
            List <FormulaItem>       result  = new List <FormulaItem>();
            Dictionary <int, ushort> infoDic = GetFormulaMaterialList(formulaID, Gettype);

            if (infoDic.Count == 0)
            {
                return(result);
            }
            if (infoDic != null)
            {
                foreach (KeyValuePair <int, ushort> kvp in infoDic)
                {
                    Material    ma   = MaterialModule.GetMaterialByMaterialID(kvp.Key);
                    FormulaItem item = new FormulaItem(ma, kvp.Value);
                    result.Add(item);
                }
            }
            return(result);
        }
Beispiel #2
0
        private static Dictionary <int, ushort> GetFormulaMaterialList(int formulaID, MaterialProductType Gettype)
        {
            FormulaData fm = GetFormulaDataByID(formulaID);

            if (string.IsNullOrEmpty(fm.InputMaterialList) || string.IsNullOrEmpty(fm.OutputMaterial))
            {
                Debug.LogError("Manufacture List is null , formulaID  = " + formulaID);
            }
            switch (Gettype)
            {
            case MaterialProductType.Enhance:
                var dic = TryParseMaterialList(fm.EnhanceMaterial);
                if (dic.Count == 0 || dic.Count == 1)
                {
                    return(dic);
                }
                else
                {
                    Debug.LogError("GetEnhanceMaterial Error ! formulaID=" + formulaID);
                    return(new Dictionary <int, ushort>());
                }

            case MaterialProductType.Input:
                var inputDic = TryParseMaterialList(fm.InputMaterialList);
                if (inputDic.Count > 3)
                {
                    Debug.LogError("FormulaLimit Error Input Max is 3! formulaID=" + formulaID);
                }
                return(inputDic);

            case MaterialProductType.Output:
                var outputDic = TryParseMaterialList(fm.OutputMaterial);
                if (outputDic.Count == 1)
                {
                    return(outputDic);
                }
                else
                {
                    Debug.LogError("Get OutPut Material Error ! formulaID=" + formulaID);
                    return(new Dictionary <int, ushort>());
                }

            default:
                Debug.LogError("GetManufactureMaterialList Type Error !");
                return(null);
            }
        }