예제 #1
0
    public void readAttackMapJson()
    {
        string loc = Application.dataPath + "/Files/" + fileName;

        if (!File.Exists(loc))
        {
            return;
        }

        StreamReader attackMapFile   = new StreamReader(loc);
        string       attackMapString = attackMapFile.ReadToEnd();

        attackMapFile.Close();
        Dictionary <int, PrimitiveJsonNode> primJsonNodes = JsonConvert.DeserializeObject <Dictionary <int, PrimitiveJsonNode> >(attackMapString);
        List <JsonNode>            finishedJsonNodes      = new List <JsonNode>();
        Dictionary <int, JsonNode> IDdJsonNodes           = new Dictionary <int, JsonNode>();

        foreach (KeyValuePair <int, PrimitiveJsonNode> primNode in primJsonNodes)
        {
            PrimitiveJsonNode   pNode = primNode.Value;
            JsonNode            node  = new JsonNode();
            Classification.Mode mode  = (Classification.Mode)Enum.Parse(typeof(Classification.Mode), pNode.classification);
            node.classification = Classification.GetClassificationByMode(mode);
            IDdJsonNodes.Add(primNode.Key, node);
        }

        //Once they're all converted, do it again to add the children, starting at root (ID: 0)
        PrimitiveJsonNode pRoot          = primJsonNodes[0];
        JsonNode          translatedRoot = IDdJsonNodes[0];

        AddChildren(translatedRoot, pRoot, IDdJsonNodes, primJsonNodes);
        finishedJsonNodes.Add(translatedRoot);

        Console.Write("HERE");
    }