FormGame.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using DeepMMO.Client.Win32.Forms;
  2. using System;
  3. using System.Diagnostics;
  4. using System.Windows.Forms;
  5. namespace DeepMMO.Client.Win32
  6. {
  7. public partial class FormGame : Form
  8. {
  9. protected RPGClient client { get; private set; }
  10. private Stopwatch interval = Stopwatch.StartNew();
  11. private long last_time_ms;
  12. public FormGame()
  13. {
  14. InitializeComponent();
  15. }
  16. public virtual void Init(RPGClient client)
  17. {
  18. this.client = client;
  19. this.gamePanel.Init(client);
  20. this.client.GameClient.OnDisconnected += GameClient_OnDisconnected;
  21. this.gamePanel.do_login();
  22. }
  23. private void GameClient_OnDisconnected(DeepCore.FuckPomeloClient.CloseReason arg1, string arg2)
  24. {
  25. MessageBox.Show(this, $"游戏服已断开: {arg1} : {arg2}", this.Text);
  26. }
  27. protected override void OnClosed(EventArgs e)
  28. {
  29. base.OnClosed(e);
  30. }
  31. protected virtual void timerUpdate_Tick(object sender, EventArgs e)
  32. {
  33. var ct = interval.ElapsedMilliseconds;
  34. int ms = (int)(ct - last_time_ms);
  35. last_time_ms = ct;
  36. this.client.Update(ms);
  37. this.gamePanel.UpdateBattle(ms);
  38. this.Text = string.Format("角色:{0} ({1})", client.RoleName, client.GameClient.IsConnected ? "已连接" : "未连接");
  39. }
  40. protected virtual void timerTest_Tick(object sender, EventArgs e)
  41. {
  42. }
  43. }
  44. }