コード例 #1
0
ファイル: MainForm.cs プロジェクト: plewt/mu97bot
 public void MyOnPlayerPosition(LivingPosition aLivingPosition)
 {
     if (( BotPlayer.ID != 0 ) && ( BotPlayer.ID == aLivingPosition.PlayerId ))
     {
         AddLog(LogType.NetworkProtocol, "Got ourself position X : {1}, Y : {2}, Rotation : {3}", aLivingPosition.PlayerId, aLivingPosition.X, aLivingPosition.Y, aLivingPosition.Rotation);
         BotPlayer.Position.X = aLivingPosition.X;
         BotPlayer.Position.Y = aLivingPosition.Y;
     }
     else
     {
         AddLog(LogType.NetworkProtocol, "Got position of living with id {0} X : {1}, Y : {2}, Rotation : {3}", aLivingPosition.PlayerId, aLivingPosition.X, aLivingPosition.Y, aLivingPosition.Rotation);
     }
 }
コード例 #2
0
ファイル: MUProtocolAnalyzer.cs プロジェクト: plewt/mu97bot
 private void AnalyzePacket(byte[] aBuffer, PacketDirection aType)
 {
     switch (aType)
     {
         case PacketDirection.ClientToServer: break; // maybe later
         case PacketDirection.ServerToClient:
             // TODO : Here should be different types of mu protocol packets with parsing and event-based processing
             CommonServerToClientPacket cstcpTemp = new CommonServerToClientPacket(aBuffer);
             switch (cstcpTemp.ClassType)
             {
                 case PacketClass.C1:
                     switch (cstcpTemp.MesTypeC1)
                     {
                         case MessageTypeC1.PublicSpeech:
                             if (OnPublicSpeach != null)
                             {
                                 using ( PublicSpeech pspTemp = new PublicSpeech(aBuffer) )
                                     AsyncHelper.FireAndForget(OnPublicSpeach, pspTemp);
                             }
                             break;
                         case MessageTypeC1.CharacterList:
                             if (OnCharacterList != null)
                             {
                                 using ( CharacterList clTemp = new CharacterList(aBuffer) )
                                     AsyncHelper.FireAndForget(OnCharacterList, clTemp);
                             }
                             break;
                         case MessageTypeC1.DamageReceived:
                             if (OnDamageReceived != null)
                             {
                                 using ( DamageReceived drTemp = new DamageReceived(aBuffer) )
                                     AsyncHelper.FireAndForget(OnDamageReceived, drTemp);
                             }
                             break;
                         case MessageTypeC1.Death:
                             if (OnDeath != null)
                             {
                                 using ( Death dTemp = new Death(aBuffer) )
                                     AsyncHelper.FireAndForget(OnDeath, dTemp);
                             }
                             break;
                         case MessageTypeC1.OpenCreateGuildWindow:
                             if (OnOpenCreateGuildWindow != null)
                                 AsyncHelper.FireAndForget(OnOpenCreateGuildWindow);
                             break;
                         case MessageTypeC1.OpenVaultWindow:
                             if (OnOpenVaultWindow != null)
                                 AsyncHelper.FireAndForget(OnOpenVaultWindow);
                             break;
                         case MessageTypeC1.PlayerPosition:
                             if (OnLivingPosition != null)
                             {
                                 using ( LivingPosition ppTemp = new LivingPosition(aBuffer) )
                                     AsyncHelper.FireAndForget(OnLivingPosition, ppTemp);
                             }
                             break;
                         case MessageTypeC1.PutItem:
                             if (OnPutItem != null)
                             {
                                 using ( PutItem piTemp = new PutItem(aBuffer) )
                                     AsyncHelper.FireAndForget(OnPutItem, piTemp);
                             }
                             break;
                         case MessageTypeC1.ServerText:
                             if (OnServerText != null)
                             {
                                 using ( ServerText stTemp = new ServerText(aBuffer) )
                                     AsyncHelper.FireAndForget(OnServerText, stTemp);
                             }
                             break;
                         case MessageTypeC1.TraiderInfo:
                             if (OnTraiderInfo != null)
                             {
                                 using ( TraiderInfo tiTemp = new TraiderInfo(aBuffer) )
                                     AsyncHelper.FireAndForget(OnTraiderInfo, tiTemp);
                             }
                             break;
                         case MessageTypeC1.StopMoving:
                             if (OnStopMoving != null)
                             {
                                 using ( StopMoving smTemp = new StopMoving(aBuffer) )
                                     AsyncHelper.FireAndForget(OnStopMoving, smTemp);
                             }
                             break;
                         case MessageTypeC1.GameServerAnswer:
                             if (OnGameServerAnswer != null)
                             {
                                 using ( GameServerAnswer gsaTemp = new GameServerAnswer(aBuffer) )
                                     AsyncHelper.FireAndForget(OnGameServerAnswer, gsaTemp);
                             }
                             break;
                         case MessageTypeC1.UpdateHealth:
                             if (OnUpdateHealth != null)
                             {
                                 using ( UpdateHealth uhTemp = new UpdateHealth(aBuffer) )
                                     AsyncHelper.FireAndForget(OnUpdateHealth, uhTemp);
                             }
                             break;
                         case MessageTypeC1.UpdateMana:
                             if (OnUpdateMana != null)
                             {
                                 using ( UpdateMana umTemp = new UpdateMana(aBuffer) )
                                     AsyncHelper.FireAndForget(OnUpdateMana, umTemp);
                             }
                             break;
                     }
                     break;
             }
             if ((cstcpTemp.ClassType != PacketClass.Unknown) && (cstcpTemp.Length < aBuffer.Length))
             {
                 byte[] subArray = new byte[aBuffer.Length - cstcpTemp.Length];
                 Array.Copy(aBuffer, cstcpTemp.Length, subArray, 0, aBuffer.Length - cstcpTemp.Length);
                 AnalyzePacket(subArray, aType);
             }
             break;
     }
 }