예제 #1
0
    public void Init(int level, string id, GameObject edge)
    {
        myLevel = level;
        ID      = id;
        Edge    = edge;

        billboard         = gameObject.GetComponent <Billboard>();
        billboard.enabled = false;

        if (CovidNetworkManager.Node_MetaInfo_Dictionary.ContainsKey(ID))
        {
            metaInfo = CovidNetworkManager.Node_MetaInfo_Dictionary[ID];
        }
        else
        {
            metaInfo = new NodeMetaInfo();
        }
        //Assigning Countryname as label
        if (metaInfo != null)
        {
            Date = metaInfo.Collection_Data;

            if (Date != "" && Date != null)
            {
                MyCollectionDate = DateTime.Parse(Date);
            }

            if (metaInfo.Country == null || metaInfo.Country == "")
            {
                Country.text = "Unknown";
            }
            else
            {
                Country.text = metaInfo.Country;
                //Assigning Colors based on Countries
                Debug.Log("CountryInfo : " + metaInfo.Country);
                if (CovidNetworkManager.CountryAndCounts.ContainsKey(metaInfo.Country))
                {
                    NetworkCountries countryInfo = CovidNetworkManager.CountryAndCounts[metaInfo.Country];
                    Material         mat         = countryInfo.mat;
                    Renderer         rand        = NodeRep.GetComponent <Renderer>();
                    mat.mainTexture = rand.material.mainTexture;
                    rand.material   = mat;

                    //myColor = countryInfo.Color;
                    if (Edge != null)
                    {
                        LineRenderer lr = Edge.GetComponent <LineRenderer>();
                        lr.SetColors(countryInfo.Color, countryInfo.Color);
                        initWidth = lr.startWidth;
                        myColor   = lr.startColor;
                        Edge.GetComponent <GraphLineTextureAnimation>().enabled = false;
                    }
                }
            }
        }
        Country.gameObject.SetActive(false);
    }
예제 #2
0
    // Start is called before the first frame update
    void Start()
    {
        root_CovidNode           = JsonMapper.ToObject <CovidNode>(data_covidJson.text);
        node_Position_Dictionary = JsonMapper.ToObject <Dictionary <string, Vector3> >(data_nodePos.text);
        Debug.Log("Total Nodes : " + node_Position_Dictionary.Count);

        obj_metaInfo = JsonMapper.ToObject <NodeMetaInfo[]>(text_metaInfo.text);
        for (int i = 0; i < obj_metaInfo.Length; i++)
        {
            if (!Node_MetaInfo_Dictionary.ContainsKey(obj_metaInfo[i].Strain))
            {
                Node_MetaInfo_Dictionary.Add(obj_metaInfo[i].Strain, obj_metaInfo[i]);
            }

            if (CountryAndCounts.ContainsKey(obj_metaInfo[i].Country))
            {
                CountryAndCounts[obj_metaInfo[i].Country].NumberOfAffected += 1;
            }
            else
            {
                Color32 color = new Color32(
                    (byte)Random.Range(0, 255f),
                    (byte)Random.Range(0, 255f),
                    (byte)Random.Range(0, 255f),
                    (byte)255f
                    );

                NetworkCountries countryInfo = new NetworkCountries(obj_metaInfo[i].Country, color, 1);
                CountryAndCounts.Add(obj_metaInfo[i].Country, countryInfo);
            }
        }

        Debug.Log("Total countries : " + CountryAndCounts.Count);

        foreach (var entry in CountryAndCounts)
        {
            Debug.Log(entry.Key + " " + entry.Value.NumberOfAffected);
        }

        //Generating RootNode
        Vector3 pos = Vector3.zero;

        if (node_Position_Dictionary.ContainsKey(root_CovidNode.name))
        {
            pos         = node_Position_Dictionary[root_CovidNode.name];
            Go_RootNode = Instantiate(prefab_Node);    //, Vector3.zero, Quaternion.identity) as GameObject;
            Go_RootNode.transform.SetParent(transform);
            Go_RootNode.transform.localPosition = pos; // Vector3.zero;
            Go_RootNode.GetComponent <NodeInstance>().Init(0, root_CovidNode.name, null);
            StartCoroutine(LoadNetwork());
        }
        else
        {
            Debug.LogError("RootNode name not found in dictionary !");
        }
    }