Beispiel #1
0
    public void Init(string country, List <CovidExtraInfo> extraInfo, Vector2 loc, Transform earth, int totalConfirmed)
    {
        Country                 = country;
        Label.text              = Country;
        ExtraInfo               = extraInfo;
        TotalConfirmed          = totalConfirmed;
        posOnSphere             = AppUtils.LatLonToPositionOnSphere(loc.x, loc.y, earth.localScale.x * 2);
        transform.localPosition = posOnSphere;
        Vector3 dir      = new Vector3(0, 1, 0);
        Vector3 crossDir = Vector3.Cross(dir, posOnSphere);
        float   angle    = Vector3.Angle(dir, posOnSphere);

        transform.Rotate(crossDir, angle, Space.Self);
        float scaleY = Mathf.Clamp(TotalConfirmed / 1000, 2, 15);

        Bar.transform.localScale = new Vector3(Bar.transform.localScale.x, scaleY, Bar.transform.localScale.z);

        Label.transform.localPosition = new Vector3(0, scaleY / 100 + 0.02f, 0);

        BoxCollider col1 = Bar.GetComponent <BoxCollider>();
        BoxCollider col2 = gameObject.AddComponent <BoxCollider>();

        scaleY    = scaleY / 100;
        col2.size = new Vector3(col1.size.x, scaleY, col1.size.z);

        col2.center = new Vector3(col2.center.x, scaleY / 2, col2.center.z);
        //col2.isTrigger = true;


        col1.enabled       = false;
        ClickedOnBarEvent += ShowOrHideGraph;
        //Getting Age and Numbers

        for (int i = 0; i < ExtraInfo.Count; i++)
        {
            float age;
            if (float.TryParse(ExtraInfo[i].Age, out age))
            {
                for (int j = 0; j < 90; j += 10)
                {
                    if (age >= j && age <= j + 9)
                    {
                        string key = (j + "_to_" + (j + 9)).ToString();
                        if (AgeDictionary.ContainsKey(key))
                        {
                            AgeDictionary[key] += 1;
                        }
                        else
                        {
                            AgeDictionary[key] = 1;
                        }
                    }
                }
            }

            if (ExtraInfo[i].Sex == "male")
            {
                if (SexDictionary.ContainsKey("male"))
                {
                    SexDictionary["male"] += 1;
                }
                else
                {
                    SexDictionary.Add("male", 1);
                }
            }
            else if (ExtraInfo[i].Sex == "female")
            {
                if (SexDictionary.ContainsKey("female"))
                {
                    SexDictionary["female"] += 1;
                }
                else
                {
                    SexDictionary.Add("female", 1);
                }
            }
            else
            {
                if (SexDictionary.ContainsKey("unknown"))
                {
                    SexDictionary["unknown"] += 1;
                }
                else
                {
                    SexDictionary.Add("unknown", 1);
                }
            }
        }

        StartCoroutine(PlotGraphWithDelay(0.5f));
        //Getting Confirmed cases DayByDay
    }
Beispiel #2
0
 void OnApplicationQuit()
 {
     ClickedOnBarEvent -= ShowOrHideGraph;
 }