예제 #1
0
 /// <summary>
 /// 关闭当前弹窗方法
 /// </summary>
 public async ValueTask Close()
 {
     if (ToastBox != null)
     {
         await ToastBox.Close();
     }
 }
예제 #2
0
파일: Spaceport.cs 프로젝트: gsx95/colonize
    private void SpawnNew()
    {
        var posY = citizenPrefab.transform.position.y;
        var newC = Instantiate(citizenPrefab, exit.transform.position, Quaternion.identity);

        newC.transform.position = new Vector3(newC.transform.position.x, posY, newC.transform.position.z);
        var name = names[spawnedCitizen];

        newC.GetComponent <Citizen>().SetName(name);
        spawnedCitizen++;
        Census.AddCitizen(newC.GetComponent <Citizen>());
        ToastBox.ShowMsg(newC.GetComponent <Citizen>().Name() + " arrived.");
    }
예제 #3
0
파일: Citizen.cs 프로젝트: gsx95/colonize
 private void Die(string reason)
 {
     if (currentBuilding)
     {
         currentBuilding.CheckOut(this);
     }
     if (home != null)
     {
         home.GetComponent <Housing>().RemoveResident(this);
     }
     if (firstWork != null)
     {
         firstWork.GetComponent <Factory>().RemoveEmployee(this);
     }
     Census.RemoveCitizen(this);
     ToastBox.ShowMsg(citizenName + " died because of " + reason);
     Destroy(gameObject);
 }
예제 #4
0
 void Awake()
 {
     Instance = this;
 }
예제 #5
0
 public void Show(string message)
 {
     try
     {
         Popup    p  = new Popup();
         ToastBox tb = new ToastBox()
         {
             Message = message
         };
         p.Child  = tb;
         p.IsOpen = true;
         p.HorizontalAlignment = HorizontalAlignment.Center;
         p.VerticalAlignment   = VerticalAlignment.Bottom;
         p.Margin = new Thickness();
         tb.OpenAnimation.Begin();
         DispatcherTimer timer = new DispatcherTimer();
         tb.OpenAnimation.Completed += new EventHandler <object>((sender, eventargs) =>
         {
             try
             {
                 timer.Interval = TimeSpan.FromSeconds(3);
                 timer.Tick    += new EventHandler <object>((sd, ea) =>
                 {
                     try
                     {
                         if (timer != null && timer.IsEnabled)
                         {
                             timer.Stop();
                             tb.CloseAnimation.Begin();
                             tb.CloseAnimation.Completed += new EventHandler <object>((s, e) =>
                             {
                                 try
                                 {
                                     p.IsOpen = false;
                                     if (Completed != null)
                                     {
                                         Completed.Invoke(this, new EventArgs());
                                     }
                                 }
                                 catch { }
                             });
                         }
                     }
                     catch { }
                 });
                 timer.Start();
             }
             catch { }
         });
         //tb.Tap += new EventHandler<GestureEventArgs>((sender, eventargs) =>
         //{
         //    try
         //    {
         //        if (Click != null)
         //            Click.Invoke(this, new EventArgs());
         //    }
         //    catch { }
         //});
         tb.ManipulationCompleted += new ManipulationCompletedEventHandler((sender, eventargs) =>
         {
             try
             {
                 if (eventargs.Cumulative.Translation.X > 200 || eventargs.Velocities.Linear.X > 1000)
                 {
                     if (timer != null && timer.IsEnabled)
                     {
                         timer.Stop();
                         tb.CloseAnimation.Begin();
                         tb.CloseAnimation.Completed += new EventHandler <object>((sd, ea) =>
                         {
                             try
                             {
                                 p.IsOpen = false;
                                 if (Completed != null)
                                 {
                                     Completed.Invoke(this, new EventArgs());
                                 }
                             }
                             catch { }
                         });
                     }
                 }
             }
             catch { }
         });
     }
     catch { }
 }