Ejemplo n.º 1
0
 public void DisplayMessage(BaseAccident data)
 {
     if (data.GetType() == typeof(Accident))
     {
         Lucky.LuckyUtils.Log("destroy");
         Accident accident = data as Accident;
         Lucky.LuckyUtils.Log(accident.type + "delete acciednt " + accident.location);
         if (accident.type == AccidentType.airport)
         {
             if (AirPlanewarndic.ContainsKey(accident.location))
             {
                 Destroy(AirPlanewarndic[accident.location].gameObject);
                 AirPlanewarndic.Remove(accident.location);
             }
         }
         else
         {
             if (Trainwarndic.ContainsKey(accident.location))
             {
                 Destroy(Trainwarndic[accident.location].gameObject);
                 Trainwarndic.Remove(accident.location);
             }
         }
     }
 }
Ejemplo n.º 2
0
 public IEnumerator Callback(BaseAccident value)
 {
     if (exectuteCallback != null)
     {
         Type type = value.GetType();
         yield return(exectuteCallback(value));
     }
     else
     {
         yield return(null);
     }
 }
Ejemplo n.º 3
0
    private void SetDate(BaseAccident data)
    {
        callback = null;
        if (data.GetType() == typeof(Accident))
        {
            string   city     = "";
            Accident accident = data as Accident;
            if (accident.type == AccidentType.airport)
            {
                city = CityUtil.Instance.GetCityName(accident.location);
                RectTransform cityrt = MapTrafficView.instance.FindPlace(city);
                Vector3       pos    = cityrt.anchoredPosition3D + new Vector3(cityrt.rect.width / 2, 0, 0);
                Lucky.LuckyUtils.Log("city warning" + city);
                rt.anchoredPosition3D = pos;
            }
            else
            {
                RectTransform railwayrt = MapTrafficView.instance.FindRailway(accident.location);
                Vector3       pos       = railwayrt.anchoredPosition3D;
                rt.anchoredPosition3D = pos;
            }
            rt.localScale = new Vector3(1.5f, 1.5f, 0);

            //news = city + "灾害持续时间: "+accident.duration+"分钟";
            news = accident.text.description;
            Lucky.LuckyUtils.Log("add listener");
            callback = delegate()
            {
                InfoView.Show(new InfoMessage(news, "寒潮已经到达!"));
            };
        }
        else if (data.GetType() == typeof(AccidentWarning))
        {
            string          city    = "";
            AccidentWarning warning = data as AccidentWarning;
            if (warning.type == AccidentType.airport)
            {
                Lucky.LuckyUtils.Log("location number " + warning.location);
                city = CityUtil.Instance.GetCityName(warning.location);
                RectTransform cityrt = MapTrafficView.instance.FindPlace(city);
                Vector3       pos    = cityrt.anchoredPosition3D + new Vector3(cityrt.rect.width / 2, 0, 0);
                rt.anchoredPosition3D = pos;
                news = "寒潮即将到达" + city + ",请注意出行安全\n\n"
                       + "<size=45>寒潮预计到达时间: " + warning.Accidentstarttime.ToString("HH:mm") + "</size>\n\n"
                       + "<size=45>寒潮预计持续时间: " + warning.min + "分钟 ~ " + warning.max + "分钟</size>";
            }
            else
            {
                RectTransform railwayrt = MapTrafficView.instance.FindRailway(warning.location);
                Vector3       pos       = railwayrt.anchoredPosition3D;
                rt.anchoredPosition3D = pos;
                CityMapping edge = CityUtil.Instance.GetEdgeCity(warning.location);
                news = "寒潮即将到达" + edge.start_node + "-" + edge.end_node + ",请注意出行安全\n\n"
                       + "<size=45>寒潮预计到达时间: " + warning.Accidentstarttime.ToString("HH:mm") + "</size>\n\n"
                       + "<size=45>寒潮预计持续时间: " + warning.min + "分钟 ~ " + warning.max + "分钟</size>";
            }

            rt.localScale = new Vector3(1.5f, 1.5f, 0);

            //news = ""+ city +"寒潮即将到达此处,请注意出行安全\n\n"
            // + "<size=45>寒潮预计到达时间: " + warning.Accidentstarttime.ToString("HH:mm") + "</size>\n\n"
            // + "<size=45>寒潮预计持续时间: " + warning.min + "分钟 ~ " + warning.max + "分钟</size>";
            callback = delegate()
            {
                InfoView.Show(new InfoMessage(news, "【寒潮天气预警】"));
            };
        }
    }
Ejemplo n.º 4
0
 public void ShowAccidentMessage(BaseAccident data)
 {
     if (data.GetType() == typeof(Accident))
     {
         Accident accident = data as Accident;
         Debug.Log("show accident " + accident.location);
         if (accident.type == AccidentType.airport)
         {
             if (AirPlanewarndic.ContainsKey(accident.location))
             {
                 AirPlanewarndic[accident.location].AccidentMessage = accident;
             }
             else
             {
                 Debug.Log("add accident " + accident.location);
                 GameObject warningPrefab = PrefabManager.Instance.GetPrefabs(Prefabs.Warning);
                 GameObject warningObj    = Instantiate(warningPrefab);
                 LuckyUtils.MakeIndentity(warningObj.transform);
                 WarningView wv = warningObj.GetComponent <WarningView>();
                 wv.AccidentMessage = accident;
                 AirPlanewarndic.Add(accident.location, wv);
                 warningObj.transform.SetParent(transform);
                 warningObj.SetActive(true);
                 LuckyUtils.MakeIndentity(warningObj.transform);
             }
         }
         else
         {
             if (Trainwarndic.ContainsKey(accident.location))
             {
                 Trainwarndic[accident.location].AccidentMessage = accident;
             }
             else
             {
                 Debug.Log("add accident " + accident.location);
                 GameObject warningPrefab = PrefabManager.Instance.GetPrefabs(Prefabs.Warning);
                 GameObject warningObj    = Instantiate(warningPrefab);
                 LuckyUtils.MakeIndentity(warningObj.transform);
                 WarningView wv = warningObj.GetComponent <WarningView>();
                 wv.AccidentMessage = accident;
                 Trainwarndic.Add(accident.location, wv);
                 warningObj.transform.SetParent(transform);
                 warningObj.SetActive(true);
                 LuckyUtils.MakeIndentity(warningObj.transform);
             }
         }
     }
     else if (data.GetType() == typeof(AccidentWarning))
     {
         AccidentWarning warning = data as AccidentWarning;
         Debug.Log("show accident warning " + warning.location);
         if (warning.type == AccidentType.airport)
         {
             if (AirPlanewarndic.ContainsKey(warning.location))
             {
                 AirPlanewarndic[warning.location].AccidentMessage = warning;
             }
             else
             {
                 Debug.Log("add accident warning " + warning.location);
                 GameObject warningPrefab = PrefabManager.Instance.GetPrefabs(Prefabs.Warning);
                 GameObject warningObj    = Instantiate(warningPrefab);
                 LuckyUtils.MakeIndentity(warningObj.transform);
                 WarningView wv = warningObj.GetComponent <WarningView>();
                 wv.AccidentMessage = warning;
                 AirPlanewarndic.Add(warning.location, wv);
                 warningObj.transform.SetParent(transform);
                 warningObj.SetActive(true);
                 LuckyUtils.MakeIndentity(warningObj.transform);
             }
         }
         else
         {
             if (Trainwarndic.ContainsKey(warning.location))
             {
                 Trainwarndic[warning.location].AccidentMessage = warning;
             }
             else
             {
                 Debug.Log("add accident warning " + warning.location);
                 GameObject warningPrefab = PrefabManager.Instance.GetPrefabs(Prefabs.Warning);
                 GameObject warningObj    = Instantiate(warningPrefab);
                 LuckyUtils.MakeIndentity(warningObj.transform);
                 WarningView wv = warningObj.GetComponent <WarningView>();
                 wv.AccidentMessage = warning;
                 Trainwarndic.Add(warning.location, wv);
                 warningObj.transform.SetParent(transform);
                 warningObj.SetActive(true);
                 LuckyUtils.MakeIndentity(warningObj.transform);
             }
         }
     }
 }