コード例 #1
0
    public void ImportPopConfig()
    {
        string line;

        string[] lineInfo;
        string   filename = SpeciesName + ".config";

        string[]     worldSelectedFiles = Directory.GetFiles(Path.Combine(Application.streamingAssetsPath, "Config/Worlds") + "/" + World.worldSelected, "*.config");
        StreamReader reader             = null;

        if (worldSelectedFiles.Contains(filename))
        {
            reader = new StreamReader(Application.streamingAssetsPath + "/Config/Worlds/" + World.worldSelected + filename);
        }
        else
        {
            reader = new StreamReader(Application.streamingAssetsPath + "/Config/Worlds/Default/" + filename);
        }
        using (reader)
        {
            while ((line = reader.ReadLine()) != null)
            {
                lineInfo = line.Split(new[] { "=" }, StringSplitOptions.None);
                string[] leftArray  = lineInfo[0].Split(new[] { "." }, StringSplitOptions.None);
                string[] rightArray = lineInfo[1].Split(new[] { "," }, StringSplitOptions.None);

                if (leftArray[0] == "gene")
                {
                    baseGenome.AddGeneToGenome(leftArray[1], rightArray);
                }
                else if (leftArray[0] == "constant")
                {
                    baseGenome.AddConstantToGenome(leftArray[1], rightArray);
                }
                else if (leftArray[0] == "quality")
                {
                    baseGenome.AddQualToGenome(leftArray[1], rightArray);
                }
                else if (leftArray[0] == "object_type")
                {
                    entityType = rightArray[0];
                    //Debug.Log("Saving object type for " + name + " as " + entityType);
                }
            }
        }
    }