Example #1
0
    public void LoadFromFile()
    {
        Debug.Log("LoadFromFile");
        // Generate random anims
        for (int i = 0; i < _animSet.animations.Length; ++i)
        {
            var data = new Animations.RGBAnimation();
            data.duration = (short)Mathf.RoundToInt(1000 * Random.Range(1, 11));
            data.tracks   = new Animations.RGBAnimationTrack[Random.Range(1, 11)];
            for (int j = 0; j < data.tracks.Length; ++j)
            {
                Animations.RGBAnimationTrack track = new Animations.RGBAnimationTrack();
                track.startTime = (short)Random.Range(0, data.duration - 100);
                track.duration  = (short)Random.Range(100, data.duration - track.startTime);
                track.ledIndex  = (byte)Random.Range(0, 21);
                track.keyframes = new Animations.RGBKeyframe[Random.Range(1, 6)];
                for (int k = 0; k < track.keyframes.Length; ++k)
                {
                    track.keyframes[k].time  = (byte)Random.Range(0, 256);
                    track.keyframes[k].red   = (byte)Random.Range(0, 256);
                    track.keyframes[k].blue  = (byte)Random.Range(0, 256);
                    track.keyframes[k].green = (byte)Random.Range(0, 256);
                }
                data.tracks[j] = track;
            }
            _animSet.animations[i] = data;
        }

        // ----> Update _animSet with data from dice

        ShowFace(0);
        _animSetTogglesRoot.GetComponentsInChildren <Toggle>().First().isOn = true;
    }
Example #2
0
    // Use this for initialization
    void Start()
    {
        Animations.AnimationSet set = new Animations.AnimationSet();
        set.animations = new Animations.RGBAnimation[5];
        for (int a = 0; a < set.animations.Length; ++a)
        {
            Animations.RGBAnimation anim = new Animations.RGBAnimation();
            anim.tracks   = new Animations.RGBAnimationTrack[a + 1];
            anim.duration = 2500;
            for (int i = 0; i < anim.tracks.Length; ++i)
            {
                var keyframes = new Animations.RGBKeyframe[Animations.Constants.MAX_KEYFRAMES];
                for (int j = 0; j < 3; ++j)
                {
                    keyframes[j].time  = (byte)j;
                    keyframes[j].red   = (byte)j;
                    keyframes[j].green = (byte)j;
                    keyframes[j].blue  = (byte)j;
                }

                var track = new Animations.RGBAnimationTrack();
                track.keyframes = keyframes;
                track.count     = 3;
                track.duration  = (short)(2000 - 10 * i);
                track.startTime = (short)(123 + i);
                track.ledIndex  = (byte)(i);
                anim.tracks[i]  = track;
            }

            set.animations[a] = anim;

            var bytes = Animations.RGBAnimation.ToByteArray(anim);
            Debug.Log(bytes.ToString());
        }
    }
 public void Deserialize(Animations.RGBAnimationTrack track, float unitSize)
 {
     ShowConfirmRemove(false);
     SetLedSprite(LedSelector.Instance.GetLedSprite(ColorAnimator.IndexToLedSprite(track.ledIndex)));
     LeftBound  = track.startTime / 1000f * unitSize;
     RightBound = LeftBound + track.duration / 1000f * unitSize;
     ColorSlider.Deserialize(track.keyframes);
 }