Beispiel #1
0
 public void Deserialize(ref DataStreamReader reader)
 {
     SlotNumber  = reader.ReadUIntNetworkByteOrder();
     SlotContent = (PowerupSlotContent)reader.ReadUIntNetworkByteOrder();
     switch (SlotContent)
     {
     case PowerupSlotContent.Laser:
         LaserPowerupSlotData *slotData = (LaserPowerupSlotData *)UnsafeUtility.Malloc(sizeof(LaserPowerupSlotElement), sizeof(LaserPowerupSlotElement), Unity.Collections.Allocator.Persistent);
         slotData->RemainingShots = reader.ReadUIntNetworkByteOrder();
         SlotData = slotData;
         break;
     }
 }
Beispiel #2
0
    public void Serialize(ref DataStreamWriter writer)
    {
        writer.WriteUIntNetworkByteOrder(SlotNumber);
        writer.WriteUIntNetworkByteOrder((uint)SlotContent);
        switch (SlotContent)
        {
        case PowerupSlotContent.Laser:
            LaserPowerupSlotData *slotData = (LaserPowerupSlotData *)SlotData;
            writer.WriteUIntNetworkByteOrder(slotData->RemainingShots);
            break;
        }

        if (SlotData != null)
        {
            UnsafeUtility.Free(SlotData, Unity.Collections.Allocator.Persistent);
        }
    }