ConveyorCraft

ConveyorCraft is a factory-building game, where you have to create items using machines and transport those items to the center of the map where you can then sell them. The project started because we had to make a game for school where we were freelancers, then we came up with ConveyorCraft. I did this together with Bo van den Berg & David van Rijn. After a short conversation, I was the one who took charge of the management (of the project), but of course, I only made my decisions if everyone agreed. I've mainly worked on SaveSystem, PlaceScript, and some smaller stuff. I've provided support/bug fixes when needed. I use Singletons and for saving, I use a combination of JSON (for the location of machines/items) and Binaryformater (money, etc.).


Project Info:

Team members: David van Rijn & Bo van den Berg
Project Time: Year 2 Semester 3.2 (03-03-2021 till 26-03-2021)
Engine: Unity
Code Languages: C#
Design Patterns: Singleton & FlyWeight


Code:


public void SaveAllData() //Saves all the Data
    {
        UIManager.instance.ShowSaveIcon(true);
        List machineSaveData = new List();
        if (transformerGrid.grid.Count > 0)
        {
            foreach (Vector2Int machine in transformerGrid.grid.Keys) //Goes thru the Machine Grid.
            {
                Transformer tempTransformer = transformerGrid.grid[machine];
                if(tempTransformer == null) Debug.Log(machine);

                int tempFilterID;
                if (tempTransformer.filterdItem != null) tempFilterID = tempTransformer.filterdItem.itemInfo.itemID;
                else tempFilterID = -1;

                MachineData tempData = new MachineData //Creates new MachineData
                {
                    position = machine,
                    rotation = tempTransformer.transform.rotation.eulerAngles.z,
                    machineType = (int)tempTransformer.transformerType,
                    craftingID = tempTransformer.recepie.craftID,
                    filterID = tempFilterID
                };
                machineSaveData.Add(tempData);
            }
        }
        List itemSaveData = new List();
        if(itemGrid.grid.Count > 0)
        {
            foreach (Vector2Int item in itemGrid.grid.Keys) //Goes thru the items in the itemgrid
            {
                List itemInfo = new List();
                for (int i = 0; i < itemGrid.grid[item].Count; i++)
                {
                    itemInfo.Add(itemGrid.grid[item][i].itemInfo.itemID);
                }
                ItemData tempItem = new ItemData //Creates New ItemData
                {
                    position = item,
                    itemID = itemInfo,
                };
                itemSaveData.Add(tempItem);
            }
        }

        //Saves to file with SaveSystem
        SaveSystem.Save(fileName, machineSaveData, CurrencyManager.instance, FindObjectOfType(), itemSaveData);
        UIManager.instance.Invoke("ShowSaveIcon", 2);
    }

}

Saves all machines and items placed in the world.