Beispiel #1
0
    //Save, Load and New methods
    #region
    public static string SaveGame(string prefix, bool export = false, string subFolder = "")
    {
        string timeCode = prefix + BuildDateString() + ".json";
        string path     = SavePath + "/" + subFolder;

        try
        {
            Directory.CreateDirectory(path + "/");
        }
        catch { }

        int i = 2;

        while (ContainsFile(timeCode, path))
        {
            timeCode = prefix + BuildDateString() + "_" + i.ToString() + ".json";
            ++i;
        }

        if (!export)
        {
            path = path + timeCode;
        }
        else
        {
            path = path + prefix + "export.json";
        }

        AssemblyIO.Save(GlobalReferences.FrozenParts, 10, path);

        return(timeCode);
    }
Beispiel #2
0
    public static void ParentAndSimulate(TextMeshPro tm)
    {
        List <Rigidbody> rbs = new List <Rigidbody>();

        AssemblyIO.Save(GlobalReferences.FrozenParts, 1, tempPath);

        foreach (GameObject go in GlobalReferences.FrozenParts.Values)
        {
            int?parentId = go.GetComponent <Part>().Parent;

            Destroy(go.GetComponent <ConstantForce>());


            if (parentId != null && GlobalReferences.FrozenParts.ContainsKey((int)parentId))
            {
                go.transform.parent = GlobalReferences.FrozenParts[(int)parentId].transform;
                Destroy(go.GetComponent <Rigidbody>());
            }
            else
            {
                rbs.Add(go.GetComponent <Rigidbody>());
                SimulationProcessHandler handler = go.AddComponent <SimulationProcessHandler>();
                handlers.Add(handler);
                handler.TM = tm;
                handler.SimulationTerminated += new SimulationProcessHandler.SimulationHandler(AfterSimulation);
            }
        }
        foreach (Rigidbody rb in rbs)
        {
            rb.useGravity  = true;
            rb.constraints = RigidbodyConstraints.None;
        }

        ChangeColliders(false);
    }
Beispiel #3
0
    //Save, Load and New methods
    #region
    public static string SaveGame(string prefix)
    {
        string year   = (System.DateTime.Now.Year - 2000).ToString("D2");
        string month  = System.DateTime.Now.Month.ToString("D2");
        string day    = System.DateTime.Now.Day.ToString("D2");
        string hour   = System.DateTime.Now.TimeOfDay.Hours.ToString("D2");
        string minute = System.DateTime.Now.TimeOfDay.Minutes.ToString("D2");

        string timeCode = prefix + year + month + day + "_" + hour + "-" + minute + ".json";
        string path     = SavePath + "\\";

        int i = 2;

        while (ContainsFile(timeCode, path))
        {
            timeCode = prefix + year + month + day + "_" + hour + "-" + minute + "_" + i.ToString() + ".json";
            ++i;
        }

        path = path + timeCode;

        AssemblyIO.Save(GlobalReferences.FrozenParts, 10, path);

        return(timeCode);
    }
Beispiel #4
0
 public static JsonAssembly SaveExportTemp()
 {
     return(AssemblyIO.Save(GlobalReferences.FrozenParts, 1, expTempPath));
 }