예제 #1
0
        public static List <MaterialCostItem> GetShipMaterialCost(int shipID)
        {
            List <MaterialCostItem> costList = new List <MaterialCostItem>();
            var meta = GetWarshipDataByKey(shipID);

            if (meta != null)
            {
                var list = Utility.TryParseStringList(meta.MaterialCost, ',');
                if (list.Count > Config.GlobalConfigData.Assemble_MaterialCost_MaxNum)
                {
                    Debug.LogError("Assemble ship MaterialCost Num can not be larger than " + Config.GlobalConfigData.Assemble_MaterialCost_MaxNum + "  shipID=" + shipID);
                }
                for (int i = 0; i < list.Count; i++)
                {
                    var maData = Utility.TryParseStringList(list[i], ':');
                    if (maData.Count == 2)
                    {
                        int materialID        = Utility.TryParseInt(maData[0]);
                        MaterialCostItem item = new MaterialCostItem(materialID, Utility.TryParseInt(maData[1]));
                        if (item.InitSuccess)
                        {
                            costList.Add(item);
                        }
                    }
                    else
                    {
                        Debug.LogError("Assemble ship MaterialCost FormatError!  PartID=" + shipID);
                    }
                }
            }
            return(costList);
        }
예제 #2
0
 public void SetUpItem(MaterialCostItem item)
 {
     _item        = item;
     _icon.sprite = item.model.Icon;
     _name.text   = item.model.Name;
     _count.text  = item.count.ToString();
 }