PanelBattle.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. using DeepCore.GameData.Zone;
  2. using DeepCore.GameData.Zone.ZoneEditor;
  3. using DeepCore.Protocol;
  4. using DeepEditor.Plugin3D.BattleClient;
  5. using DeepMMO.Client.Battle;
  6. using System;
  7. using System.Drawing;
  8. using System.Windows.Forms;
  9. namespace DeepMMO.Client.Win32.Battle
  10. {
  11. public class PanelBattle : PanelBattleView3D
  12. {
  13. public readonly GamePanelContainer container;
  14. public readonly RPGBattleClient battle;
  15. private static float s_TurboX = 1f;
  16. private static DeepCore.Vector.Vector2 s_CameraScal;
  17. private static Pen s_RangePen = new Pen(Color.FromArgb(128, 255, 255, 255));
  18. public PanelBattle(GamePanelContainer container, RPGBattleClient bot)
  19. {
  20. this.container = container;
  21. this.battle = bot;
  22. base.Start(new BotBattleFactory(battle));
  23. base.pictureBox1.MouseWheel += PictureBox1_MouseWheel;
  24. base.OnNetworkViewClicked += PanelBattle_OnNetworkViewClicked;
  25. this.OnTurboChanged += PanelBattle_OnTurboChanged;
  26. this.OnTimerBeginUpdate += PanelBattle_OnTimerBeginUpdate;
  27. }
  28. private void PanelBattle_OnTimerBeginUpdate(int intervalMS)
  29. {
  30. if (s_TurboX != base.TurboX)
  31. {
  32. base.TurboX = s_TurboX;
  33. }
  34. }
  35. private void PanelBattle_OnTurboChanged(float turbo)
  36. {
  37. s_TurboX = turbo;
  38. }
  39. private void PanelBattle_OnNetworkViewClicked()
  40. {
  41. container.SessionView.Show();
  42. }
  43. public override string ToString()
  44. {
  45. return this.battle.ToString();
  46. }
  47. public override void updateBattle(int intervalMS)
  48. {
  49. base.updateBattle(intervalMS);
  50. }
  51. protected override void timer1_Tick(object sender, EventArgs e)
  52. {
  53. if (base.DisplayWorld != null && s_CameraScal != null)
  54. {
  55. if (base.DisplayWorld.getCameraScaleX() != s_CameraScal.x || base.DisplayWorld.getCameraScaleY() != s_CameraScal.y)
  56. {
  57. base.DisplayWorld.setCameraScale(s_CameraScal.x, s_CameraScal.y);
  58. }
  59. }
  60. }
  61. private void PictureBox1_MouseWheel(object sender, MouseEventArgs e)
  62. {
  63. if (base.DisplayWorld != null)
  64. {
  65. s_CameraScal = new DeepCore.Vector.Vector2(base.DisplayWorld.getCameraScaleX(), base.DisplayWorld.getCameraScaleY());
  66. }
  67. }
  68. protected override void Layer_ActorAdded(ZoneLayer layer, ZoneActor actor)
  69. {
  70. this.btn_Guard.Checked = battle.Layer.Actor.IsGuard;
  71. }
  72. protected override void Layer_MessageReceived(ZoneLayer layer, IMessage e)
  73. {
  74. if (e is ServerExceptionB2C)
  75. {
  76. ServerExceptionB2C err = e as ServerExceptionB2C;
  77. //MessageBox.Show(over.Message + "\n" + over.StackTrace, e.GetType().Name);
  78. Console.WriteLine("ServerExceptionB2C : " + err.Message + "\r\n" + err.StackTrace);
  79. return;
  80. }
  81. base.Layer_MessageReceived(layer, e);
  82. }
  83. public class BotBattleFactory : IAbstractBattleFactory
  84. {
  85. public readonly RPGBattleClient battle;
  86. public BotBattleFactory(RPGBattleClient bot) { this.battle = bot; }
  87. public EditorTemplates DataRoot { get { return RPGClientBattleManager.DataRoot; } }
  88. public AbstractBattle GenBattle() { return battle; }
  89. public DisplayLayerWorld GenDisplay(PictureBox control) { return new BotBattleDisplay(); }
  90. }
  91. public class BotBattleDisplay : DisplayLayerWorld
  92. {
  93. public BotBattleDisplay()
  94. {
  95. base.ShowHP = true;
  96. base.ShowLog = false;
  97. base.ShowName = true;
  98. base.ShowFlagName = true;
  99. base.ShowAOI = true;
  100. base.ShowTerrainMesh = true;
  101. }
  102. // protected override void clientUpdate(int intervalMS)
  103. // {
  104. // }
  105. public override void Dispose()
  106. {
  107. }
  108. }
  109. private void InitializeComponent()
  110. {
  111. ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
  112. this.SuspendLayout();
  113. //
  114. // PanelBattle
  115. //
  116. this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
  117. this.Name = "PanelBattle";
  118. ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
  119. this.ResumeLayout(false);
  120. this.PerformLayout();
  121. }
  122. }
  123. }