コード例 #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 { }
 }