Ejemplo n.º 1
0
    private void RecievePacket(RecievedPacket packet)
    {
        if (packet.type == PacketType.charSelect)
        {
            // Send out complete list of selectors
            if (packet.value == PacketValue.completeList)
            {
                selectorList.GetListFromBytes(packet, UpdateSelector);

                // Add selector
            }
            else if (packet.value == PacketValue.addUpdate)
            {
                UpdateSelector(selectorList.UnpackObj(packet.data), packet.GetTimeDifference());
                MultiplayerManager.peerManager.SendDataToAllPeers(selectorList.GetBytesFromList(), PacketType.charSelect, PacketValue.completeList, true);

                // Selector moves or changes
            }
            else if (packet.value == PacketValue.changeUpdate)
            {
                UpdateSelector(selectorList.UnpackObj(packet.data), packet.GetTimeDifference());
            }

            // Load the game
        }
        else if (packet.type == PacketType.startGame)
        {
            MultiplayerManager.manager.LoadGame(selectorList, packet.GetTimeDifference());
        }
    }
Ejemplo n.º 2
0
 private void RecieveConnection(RecievedPacket packet)
 {
     if (packet.type == PacketType.objectMove)
     {
         objects.GetListFromBytes(packet, SyncObject);
     }
 }
Ejemplo n.º 3
0
 private void PacketHandler(RecievedPacket packet)
 {
     if (packet.type == PacketType.interactable)
     {
         if (packet.value == PacketValue.changeUpdate)
         {
             InvokeInteraction(packet);
         }
     }
 }
Ejemplo n.º 4
0
 private void PacketHandler(RecievedPacket packet)
 {
     if (packet.type == PacketType.projectile)
     {
         if (packet.value == PacketValue.addUpdate)
         {
             RecieveNewProjectile(packet.data, packet.GetTimeDifference());
         }
         else if (packet.value == PacketValue.removeUpdate)
         {
             RecieveRemoveProjectile(packet);
         }
     }
 }
Ejemplo n.º 5
0
 private void PacketHandler(RecievedPacket packet)
 {
     if (packet.type == PacketType.enemy)
     {
         if (packet.value == PacketValue.addUpdate)
         {
             SpawnEnemy();
         }
         else if (packet.value == PacketValue.changeUpdate)
         {
             enemies.UnpackAndSyncObj(packet);
         }
         else if (packet.value == PacketValue.removeUpdate)
         {
             DeleteEnemy(packet.data);
         }
     }
 }
Ejemplo n.º 6
0
    private void RecieveConnection(RecievedPacket packet)
    {
        if (packet.type == PacketType.playerMove)
        {
            players.UnpackAndSyncObj(packet);
        }
        else if (packet.type == PacketType.playerAttack && packet.value != PacketValue.confirmation)
        {
            BasePlayer player = players.GetObjWithId(packet.peerId);

            switch ((BasePlayer.PlayerAttack)packet.data[0])
            {
            case BasePlayer.PlayerAttack.Primary:
                player.RecieveAttack(packet.data, packet.GetTimeDifference());
                break;
            }
        }
    }
Ejemplo n.º 7
0
 private void InvokeInteraction(RecievedPacket packet)
 {
     interactables.UnpackAndSyncObj(packet).InvokeEvents();
 }
Ejemplo n.º 8
0
 private void RecieveRemoveProjectile(RecievedPacket packet)
 {
     DestroyProjectile(projectiles.UnpackAndSyncObj(packet));
 }
Ejemplo n.º 9
0
        public void parseRecievedPacket(OnDataRecievedListener listener, byte[] data)
        {
            try
            {
                if (Encoding.Default.GetString(data).Contains("Ready to Send SMS"))
                {
                    listener.onConnectionStarted();
                    return;
                }

                if (Encoding.Default.GetString(data).Contains(AbstractPacket.GSM_Sending_Error_text))
                {
                    listener.onGSMSendingError();
                    return;
                }


                RecievedPacket recPacket = new RecievedPacket(data);
                if (recPacket.AbsPacket != null)
                {
                    switch (recPacket.type)
                    {
                    case AbstractPacket.StructType.Registeration:
                        if (recPacket.AbsPacket.Cmd == AbstractPacket.WRITE_CMD)
                        {
                            listener.onWriteNumberRegister((RegisterationPacket)recPacket.AbsPacket);
                        }
                        else
                        {
                            listener.onReadNumberRegister((RegisterationPacket)recPacket.AbsPacket);
                        }
                        break;

                    case AbstractPacket.StructType.Activation:
                        if (recPacket.AbsPacket.Cmd == AbstractPacket.WRITE_CMD)
                        {
                            listener.onWriteActivate();
                        }
                        else
                        {
                            listener.onReadActivate((ActivationPacket)recPacket.AbsPacket);
                        }
                        break;

                    case AbstractPacket.StructType.Send:
                        listener.onSend();
                        break;

                    case AbstractPacket.StructType.AutoId:
                        listener.onAutoId((RegisterationPacket)recPacket.AbsPacket);
                        break;

                    case AbstractPacket.StructType.Delivery:
                        listener.onDelivery((DeliveryPacket)recPacket.AbsPacket);
                        break;

                    case AbstractPacket.StructType.AutoDelivery:
                        listener.onAutoDelivery((DeliveryPacket)recPacket.AbsPacket);
                        break;

                    case AbstractPacket.StructType.USSDWrite:
                        listener.onUSSDWrite();
                        break;

                    case AbstractPacket.StructType.USSDExecute:
                        listener.onUSSDExecute();
                        break;

                    case AbstractPacket.StructType.USSDRead:
                        listener.onUSSDRead((USSDPacket)recPacket.AbsPacket);
                        break;

                    case AbstractPacket.StructType.SMSText:
                        if (recPacket.AbsPacket.Cmd == AbstractPacket.WRITE_CMD)
                        {
                            listener.onMessageTextWrite();
                        }
                        else
                        {
                            listener.onMessageTextRead((SMSTextPacket)recPacket.AbsPacket);
                        }
                        break;

                    case AbstractPacket.StructType.Inbox:

                        listener.onReadInbox((InboxPacket)recPacket.AbsPacket);
                        break;

                    case AbstractPacket.StructType.AutoInbox:
                        listener.onAutoInbox((InboxPacket)recPacket.AbsPacket);
                        break;
                    }
                }

                return;
            }
            catch (Exception e)
            {
                Console.WriteLine(string.Format("Parse Packet Error => {0}", e.Message));
            }
        }