Exemple #1
0
    public static void LoadNetworks(string user_app_path)
    {
        string     filePath = System.IO.Path.Combine(user_app_path, "networks.sdf");
        GameObject network  = GameObject.Find("Network");
        string     line     = "";

        try
        {
            StreamReader reader = new StreamReader(filePath, Encoding.ASCII);

            using (reader)
            {
                string tag;
                //Debug.Log("LoadNetworks read from " + filePath);
                string value = null;
                do
                {
                    value = ccUtils.SDTNext(reader, out tag);
                    if (value == null)
                    {
                        continue;
                    }
                    //Debug.Log("LoadNetwork got " + value + " for tag " + tag);
                    if (tag != "Network")
                    {
                        Debug.Log("LoadNetwork found unexpected tag " + tag);
                        Debug.Break();
                        return;
                    }
                    GameObject new_network = Instantiate(network, new Vector3(1.0F, 0, 0), Quaternion.identity);
                    //new_network.SetActive(false);
                    NetworkBehavior script = (NetworkBehavior)new_network.GetComponent(typeof(NetworkBehavior));
                    script.LoadOneNetwork(value);
                }while (value != null);
                //Debug.Break();
            }
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message + "\n");
        }
    }