Beispiel #1
0
    private void LoadIndustrise()
    {
        MaterialData[] materialList   = FIleSys.GetAllInstances <MaterialData>();
        string[]       industriseJson = FIleSys.OpenFile <string[]>(Path + "/industrise.bin");
        for (int i = 0; i < industriseJson.Length; i++)
        {
            Dictionary <string, object> industriseValue = GetObject <Dictionary <string, object> >(industriseJson[i]);

            Industrise curIndustrise = new Industrise((Vector2Int)industriseValue["pos"], map, FIleSys.GetAllInstances <IndustriseData>()[(Int64)(industriseValue["industriseData"])]);
            curIndustrise.materialProductionRatio = (float)((double)industriseValue["materialPoduction"]);

            if (industriseValue.ContainsKey("inpute"))
            {
                foreach (KeyValuePair <int, int> curMaterial in (Dictionary <int, int>)industriseValue["inpute"])
                {
                    curIndustrise.materialsInpute[materialList[curMaterial.Key]] = curMaterial.Value;
                }
            }

            if (industriseValue.ContainsKey("outpute"))
            {
                foreach (KeyValuePair <int, int> curMaterial in (Dictionary <int, int>)industriseValue["outpute"])
                {
                    curIndustrise.materialsOutpute[materialList[curMaterial.Key]] = curMaterial.Value;
                }
            }

            map.industrises.Add(curIndustrise);
        }
    }
Beispiel #2
0
 private void SaveIndustrise()
 {
     string[] industriseJson = new string[map.industrises.Count];
     for (int i = 0; i < industriseJson.Length; i++)
     {
         Industrise curIndustrise = map.industrises[i];
         Dictionary <string, object> industriseDic = new Dictionary <string, object>();
         industriseDic.Add("pos", curIndustrise.MasterPos);
         industriseDic.Add("materialPoduction", curIndustrise.materialProductionRatio);
         industriseDic.Add("industriseData", Array.IndexOf(FIleSys.GetAllInstances <IndustriseData>(), curIndustrise.industriseData));
         for (int j = 0; j < 1; j++)
         {
             Dictionary <int, int>          material = new Dictionary <int, int>();
             Dictionary <MaterialData, int> source   = j == 0 ? curIndustrise.materialsInpute : curIndustrise.materialsOutpute;
             MaterialData[] materialList             = FIleSys.GetAllInstances <MaterialData>();
             foreach (KeyValuePair <MaterialData, int> curMaterial in source)
             {
                 material.Add(Array.IndexOf(materialList, curMaterial.Key), curMaterial.Value);
             }
             industriseDic.Add(j == 0 ? "inpute" : "outpute", material);
         }
         industriseJson[i] = GetJson(industriseDic);
     }
     FIleSys.SaveFile(Path + "/industrise.bin", industriseJson);
 }
    public static void MakeAuto(Vector2Int origine)
    {
        //Vector2Int origine = new Vector2Int(200, 200);
        for (int i = -30; i <= 0; i++)
        {
            MapManager.map.AddConstruction(origine + new Vector2Int(i, 1), new Road());
        }
        for (int i = 0; i <= 30; i++)
        {
            MapManager.map.AddConstruction(origine + new Vector2Int(0, i), new Road());
        }
        for (int i = -15; i <= 15; i += 15)
        {
            Industrise indus = MapManager.map.CreatIndustrise(origine + new Vector2Int(-35, i));
            indus.industriseData          = FIleSys.GetAllInstances <IndustriseData>()[0];
            indus.materialProductionRatio = 200;
            indus.SetInputeOutpure();
        }
        for (int i = -15; i <= 15; i += 15)
        {
            Industrise indus = MapManager.map.CreatIndustrise(origine + new Vector2Int(i, 35));
            indus.industriseData          = FIleSys.GetAllInstances <IndustriseData>()[1];
            indus.materialProductionRatio = 200;
            indus.SetInputeOutpure();
        }

        MapManager.map.AddConstruction(origine + new Vector2Int(-31, 1), new LoadingBay());
        MapManager.map.AddConstruction(origine + new Vector2Int(0, 31), new LoadingBay());

        MapManager.map.AddConstruction(origine, new Depot());
        Depot depot = MapManager.map.GetParcel <Depot>(origine);

        Debug.Log(depot);
        Debug.Log(FIleSys.GetAllInstances <VehicleData>()[1]);
        Group group = new Group()
        {
            name = "Auto Generate Groupe"
        };
        List <VehicleContoler> vehicles = new List <VehicleContoler>();

        for (int i = 0; i < 3; i++)
        {
            vehicles.Add(depot.BuyVehicle(FIleSys.GetAllInstances <VehicleData>()[1]));
            vehicles[i].MyGroup = Group.groups[0];
        }
        group.forceRoute = true;
        group.route      = new Route()
        {
            points = new List <Vector2Int>()
            {
                origine + new Vector2Int(-31, 1),
                origine + new Vector2Int(0, 31),
                origine,
            }
        };
        Group.groups[0].StartEveryVehicle();
    }