Beispiel #1
0
    _OnEvent(SsKeyAttr attr)
    {
        // take value at just key frame.
        SsAttrValue[] values = _res.GetAttrValues(attr);
        if (values.Length == 0)
        {
            return;
        }

        // ignore within previous frame
        if ((int)_mgr._animeFrame == (int)_mgr._prevFrame)
        {
            return;
        }

        // trace each frame from previous frame to current frame.
        int destFrame = (int)_mgr._animeFrame;
        int frame     = (int)_mgr._prevFrame;

        for (int i = 0; i < _mgr._playFrameLength; ++i)
        {
            frame = _mgr._StepFrameFromPrev(frame);

            SsAttrValue v;
            if (frame < values.Length)
            {
                // get value at this frame
                v = values[frame];
            }
            else
            {
                // refer to the single value consolidated from multiple keyframes
                v = values[0];
            }

            // is this a generated value from interpolation?
            if (!v.HasValue)
            {
                // is time just at key?
                SsKeyFrameInterface key = _res.GetKey(attr, v.RefKeyIndex);
                if (key.Time == frame)
                {
                    // OK
                    switch (attr)
                    {
                    case SsKeyAttr.User:
                        SsUserDataKeyFrame userKey = (SsUserDataKeyFrame)key;
                        OnUserDataKey(this, userKey.Value);
                        break;

                    case SsKeyAttr.Sound:
                        SsSoundKeyFrame soundKey = (SsSoundKeyFrame)key;
                        OnSoundKey(this, soundKey.Value);
                        break;

                    default:
                        Debug.LogWarning("Not implemented event: " + attr);
                        break;
                    }
                }
            }
            if (frame == destFrame)
            {
                break;
            }
        }
    }