Ejemplo n.º 1
0
    public static void saveSheetToFile(InfoSheet sheet, bool instance = false)
    {
        Dictionary <string, (string, float, float, float, float)> dictText = sheet.textFields;
        string fileText = "";

        fileText += sheet.getName() + "\n";

        foreach (KeyValuePair <string, (string, float, float, float, float)> tuple in dictText)
        {
            if (tuple.Key != "")
            {
                fileText += "text," + tuple.Key + "," + tuple.Value.Item1 + "," + tuple.Value.Item2 + "," + tuple.Value.Item3 + "," + tuple.Value.Item4 + "," + tuple.Value.Item5 + "\n";
            }
        }

        Dictionary <string, (float, float, float, float, float)> dictStatic = sheet.staticNumericalFields;

        foreach (KeyValuePair <string, (float, float, float, float, float)> tuple in dictStatic)
        {
            if (tuple.Key != "")
            {
                fileText += "static," + tuple.Key + "," + tuple.Value.Item1 + "," + tuple.Value.Item2 + "," + tuple.Value.Item3 + "," + tuple.Value.Item4 + "," + tuple.Value.Item5 + "\n";
            }
        }

        Dictionary <string, (float, float, float, float, float, float)> dictDynamic = sheet.dynamicNumericalFields;

        foreach (KeyValuePair <string, (float, float, float, float, float, float)> tuple in dictDynamic)
        {
            if (tuple.Key != "")
            {
                fileText += "dynamic," + tuple.Key + "," + tuple.Value.Item1 + "," + tuple.Value.Item2 + "," + tuple.Value.Item3 + "," + tuple.Value.Item4 + "," + tuple.Value.Item5 + "," + tuple.Value.Item6 + "\n";
            }
        }

        if (instance)
        {
            fileText += sheet.getInstance() + "\n";
        }

        fileText += "End file";
        string filePath;

        if (instance)
        {
            filePath = @"Instances\" + sheet.getName() + "." + sheet.getInstance() + ".st";
        }
        else
        {
            filePath = @"Sheets\" + sheet.getName() + ".st";
        }

        if (File.Exists(filePath))
        {
            File.WriteAllText(filePath, string.Empty);
        }
        File.WriteAllText(filePath, fileText);
        Debug.Log("Saved");
        //Debug.Log(fileText);
    }
Ejemplo n.º 2
0
 public string getName()
 {
     return(entity.getName());
 }