public void ReceiveBCast(Robot source, MockPacket packet) { // We've seen this before, don't process it again if (!_canReceivePackets || receivedPackets.Contains(packet.guid)) { return; } receivedPackets.Add(packet.guid); if (packet.type == PacketType.AllStop) { Stop(); } else if (packet.type == PacketType.HeadColour) { SetHeadColour((packet as HeadColourPacket).HeadColor); } else if (packet.type == PacketType.RequestSpace) { _motionController.Reverse((packet as RequestSpacePacket).AmountOfSpace); } if (!packet.HasExpired()) { _radioController.BCast(source, packet); } }
public void Setup() { _mockPacket = new MockPacket(); _packetHeader = typeof(MockPacket).AssemblyQualifiedName; _serializatedMockPacket = "Dummy"; _mockConverter = Substitute.For <IPacketConverter <MockPacket> >(); _mockConverter.Serialize(_mockPacket).Returns(_serializatedMockPacket); _mockConverter.Deserialize(_serializatedMockPacket).Returns(_mockPacket); _serializer = new PacketSerializer(); }
public void SendBCast(MockPacket packet) { _radioController.BCast(this, packet); StartCoroutine(BlockPacketReceipt(2)); }