示例#1
0
 private void RecieveConnection(RecievedPacket packet)
 {
     if (packet.type == PacketType.objectMove)
     {
         objects.GetListFromBytes(packet, SyncObject);
     }
 }
示例#2
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());
        }
    }