Exemplo n.º 1
0
        public void SaveBuilding()
        {
            buildings[editing].Name = BuildingName.text;
            var container = new SlotContainer();

            foreach (var mat in material_dropdowns.elements)
            {
                var drop = mat.GetComponent <MaterialDropDown>();
                int amount;
                if (!drop.GetAmount(out amount))
                {
                    return;
                }
                container.AddSlot(BuildingMaterial.existingMaterials[drop.GetMaterialName()], amount);
            }
            buildings[editing].SetContainer(container);
            FileManager.SaveBuildings(buildings);

            Refresh();
        }
Exemplo n.º 2
0
        private static SlotContainer ParseBuildingMaterials(string filename)
        {
            var result  = new SlotContainer();
            var content = File.ReadAllLines(filename);

            BuildingMaterial material = new BuildingMaterial();
            int amount;

            for (int i = 0; i < content.Length; i++)
            {
                if (i % 2 == 0)
                {
                    material = BuildingMaterial.existingMaterials[content[i]];
                }
                else
                {
                    amount = int.Parse(content[i]);
                    result.AddSlot(material, amount);
                }
            }

            return(result);
        }