Ejemplo n.º 1
0
    IEnumerator UploadAnimationSetCr(AnimationSet set, System.Action <bool> callBack)
    {
        // Prepare the die
        var prepareDie = new DieMessageTransferAnimSet();

        prepareDie.paletteSize    = set.getPaletteSize();
        prepareDie.keyFrameCount  = set.getKeyframeCount();
        prepareDie.rgbTrackCount  = set.getRGBTrackCount();
        prepareDie.trackCount     = set.getTrackCount();
        prepareDie.animationCount = set.getAnimationCount();
        Debug.Log("Animation Data to be sent:");
        Debug.Log("palette: " + prepareDie.paletteSize * Marshal.SizeOf <byte>());
        Debug.Log("keyframes: " + prepareDie.keyFrameCount + " * " + Marshal.SizeOf <Animations.RGBKeyframe>());
        Debug.Log("rgb tracks: " + prepareDie.rgbTrackCount + " * " + Marshal.SizeOf <Animations.RGBTrack>());
        Debug.Log("tracks: " + prepareDie.trackCount + " * " + Marshal.SizeOf <Animations.AnimationTrack>());
        Debug.Log("animations: " + prepareDie.animationCount + " * " + Marshal.SizeOf <Animations.Animation>());
        bool timeout = false;

        yield return(StartCoroutine(SendMessageWithAckOrTimeoutCr(prepareDie, DieMessageType.TransferAnimSetAck, 3.0f, null, () => timeout = true)));

        if (!timeout)
        {
            Debug.Log("die is ready, sending animations");
            Debug.Log("byte array should be: " + set.ComputeAnimationDataSize());
            var setData = set.ToByteArray();
            yield return(StartCoroutine(UploadBulkDataCr(setData)));

            // We're done!
            Debug.Log("Done!");
            callBack?.Invoke(true);
        }
        else
        {
            Debug.Log("TimedOut");
            callBack?.Invoke(false);
        }
    }