예제 #1
0
        private void SequenceCompleted()
        {
            string runningSequenceName = _runningSequence.Name;
            int    nextSeqId           = _runningSequence.ChainedSequenceId;

            _runningSequence = null;

            if (_lastCompletedSequenceName != runningSequenceName)
            {
                _lastCompletedSequenceName = runningSequenceName;
            }

            if (_delegate != null)
            {
                _delegate(_runningSequence.Name);
            }

            if (_animationCompleteCallbackFunc != null)
            {
                _animationCompleteCallbackFunc();
            }


            if (nextSeqId != -1)
            {
                RunAnimations(nextSeqId, 0);
            }
        }
예제 #2
0
        private bool ReadSequences()
        {
            List <CCBSequence> sequences = _actionManager.Sequences;

            int numSeqs = ReadInt(false);

            for (int i = 0; i < numSeqs; i++)
            {
                var seq = new CCBSequence();

                seq.Duration          = ReadFloat();
                seq.Name              = ReadCachedString();
                seq.SequenceId        = ReadInt(false);
                seq.ChainedSequenceId = ReadInt(true);

                if (!ReadCallbackKeyframesForSeq(seq))
                {
                    return(false);
                }
                if (!ReadSoundKeyframesForSeq(seq))
                {
                    return(false);
                }

                sequences.Add(seq);
            }

            _actionManager.AutoPlaySequenceId = ReadInt(true);
            return(true);
        }
예제 #3
0
        private void SequenceCompleted()
        {
            if (mDelegate != null)
            {
                mDelegate(mRunningSequence.Name);
            }

            int nextSeqId = mRunningSequence.ChainedSequenceId;

            mRunningSequence = null;

            if (nextSeqId != -1)
            {
                RunAnimations(nextSeqId, 0);
            }
        }
예제 #4
0
        private bool ReadSequences()
        {
            List <CCBSequence> sequences = mActionManager.Sequences;

            int numSeqs = ReadInt(false);

            for (int i = 0; i < numSeqs; i++)
            {
                var seq = new CCBSequence();

                seq.Duration          = ReadFloat();
                seq.Name              = ReadCachedString();
                seq.SequenceId        = ReadInt(false);
                seq.ChainedSequenceId = ReadInt(true);

                sequences.Add(seq);
            }

            mActionManager.AutoPlaySequenceId = ReadInt(true);
            return(true);
        }
예제 #5
0
        public bool ReadCallbackKeyframesForSeq(CCBSequence seq)
        {
            int numKeyframes = ReadInt(false);

            if (numKeyframes == 0)
            {
                return(true);
            }

            CCBSequenceProperty channel = new CCBSequenceProperty();

            for (int i = 0; i < numKeyframes; ++i)
            {
                float  time         = ReadFloat();
                string callbackName = ReadCachedString();

                int callbackType = ReadInt(false);

                List <CCBValue> value = new List <CCBValue>();
                value.Add(new CCBValue(callbackName));
                value.Add(new CCBValue(callbackType.ToString()));

                CCBKeyframe keyframe = new CCBKeyframe();

                keyframe.Time  = time;
                keyframe.Value = value;

                if (_jsControlled)
                {
                    //string callbackIdentifier;
                    _actionManager.GetKeyframeCallbacks().Add(String.Format("{0}:{1}", callbackType, callbackName));
                }

                channel.Keyframes.Add(keyframe);
            }

            seq.CallBackChannel = channel;

            return(true);
        }
예제 #6
0
        public bool ReadSoundKeyframesForSeq(CCBSequence seq)
        {
            int numKeyframes = ReadInt(false);

            if (numKeyframes == 0)
            {
                return(true);
            }

            CCBSequenceProperty channel = new CCBSequenceProperty();

            for (int i = 0; i < numKeyframes; ++i)
            {
                float  time      = ReadFloat();
                string soundFile = ReadCachedString();
                float  pitch     = ReadFloat();
                float  pan       = ReadFloat();
                float  gain      = ReadFloat();

                List <CCBValue> value = new List <CCBValue>();

                value.Add(new CCBValue(soundFile));
                value.Add(new CCBValue(pitch.ToString()));
                value.Add(new CCBValue(pan.ToString()));
                value.Add(new CCBValue(gain.ToString()));

                CCBKeyframe keyframe = new CCBKeyframe();
                keyframe.Time  = time;
                keyframe.Value = value;
                channel.Keyframes.Add(keyframe);
            }

            seq.SoundChannel = channel;

            return(true);
        }
예제 #7
0
        private bool ReadSequences()
        {
            List<CCBSequence> sequences = _actionManager.Sequences;

            int numSeqs = ReadInt(false);

            for (int i = 0; i < numSeqs; i++)
            {
                var seq = new CCBSequence();

                seq.Duration = ReadFloat();
                seq.Name = ReadCachedString();
                seq.SequenceId = ReadInt(false);
                seq.ChainedSequenceId = ReadInt(true);

                if (!ReadCallbackKeyframesForSeq(seq)) return false;
                if (!ReadSoundKeyframesForSeq(seq)) return false;

                sequences.Add(seq);
            }

            _actionManager.AutoPlaySequenceId = ReadInt(true);
            return true;
        }
예제 #8
0
        public bool ReadSoundKeyframesForSeq(CCBSequence seq)
        {
            int numKeyframes = ReadInt(false);
            if (numKeyframes == 0) return true;

            CCBSequenceProperty channel = new CCBSequenceProperty();

            for (int i = 0; i < numKeyframes; ++i)
            {

                float time = ReadFloat();
                string soundFile = ReadCachedString();
                float pitch = ReadFloat();
                float pan = ReadFloat();
                float gain = ReadFloat();

                List<CCBValue> value = new List<CCBValue>();

                value.Add(new CCBValue(soundFile));
                value.Add(new CCBValue(pitch.ToString()));
                value.Add(new CCBValue(pan.ToString()));
                value.Add(new CCBValue(gain.ToString()));

                CCBKeyframe keyframe = new CCBKeyframe();
                keyframe.Time = time;
                keyframe.Value = value;
                channel.Keyframes.Add(keyframe);
            }

            seq.SoundChannel = channel;

            return true;
        }
예제 #9
0
        public bool ReadCallbackKeyframesForSeq(CCBSequence seq)
        {
            int numKeyframes = ReadInt(false);
            if (numKeyframes == 0) return true;

            CCBSequenceProperty channel = new CCBSequenceProperty();
            
            for (int i = 0; i < numKeyframes; ++i)
            {

                float time = ReadFloat();
                string callbackName = ReadCachedString();

                int callbackType = ReadInt(false);

                List<CCBValue> value = new List<CCBValue>();
                value.Add(new CCBValue(callbackName));
                value.Add(new CCBValue(callbackType.ToString()));

                CCBKeyframe keyframe = new CCBKeyframe();

                keyframe.Time = time;
                keyframe.Value = value;

                if (_jsControlled)
                {
                    //string callbackIdentifier;
                    _actionManager.GetKeyframeCallbacks().Add(String.Format("{0}:{1}", callbackType, callbackName));
                }

                channel.Keyframes.Add(keyframe);
            }

            seq.CallBackChannel = channel;

            return true;
        }
예제 #10
0
        public void RunAnimations(int nSeqId, float fTweenDuration)
        {
            Debug.Assert(nSeqId != -1, "Sequence id couldn't be found");

            mRootNode.StopAllActions();

            foreach (var pElement in mNodeSequences)
            {
                CCNode node = pElement.Key;
                node.StopAllActions();

                // Refer to CCBReader::readKeyframe() for the real type of value
                Dictionary <int, Dictionary <string, CCBSequenceProperty> > seqs = pElement.Value;

                var seqNodePropNames = new List <string>();

                Dictionary <string, CCBSequenceProperty> seqNodeProps;
                if (seqs.TryGetValue(nSeqId, out seqNodeProps))
                {
                    // Reset nodes that have sequence node properties, and run actions on them
                    foreach (var pElement1 in seqNodeProps)
                    {
                        string propName             = pElement1.Key;
                        CCBSequenceProperty seqProp = pElement1.Value;
                        seqNodePropNames.Add(propName);

                        SetFirstFrame(node, seqProp, fTweenDuration);
                        RunAction(node, seqProp, fTweenDuration);
                    }
                }

                // Reset the nodes that may have been changed by other timelines
                Dictionary <string, object> nodeBaseValues;
                if (mBaseValues.TryGetValue(node, out nodeBaseValues))
                {
                    foreach (var pElement2 in nodeBaseValues)
                    {
                        if (!seqNodePropNames.Contains(pElement2.Key))
                        {
                            object value = pElement2.Value;

                            if (value != null)
                            {
                                SetAnimatedProperty(pElement2.Key, node, value, fTweenDuration);
                            }
                        }
                    }
                }
            }

            // Make callback at end of sequence
            CCBSequence seq            = GetSequence(nSeqId);
            CCAction    completeAction = new CCSequence(
                new CCDelayTime(seq.Duration + fTweenDuration),
                new CCCallFunc(SequenceCompleted)
                );

            mRootNode.RunAction(completeAction);

            // Set the running scene
            mRunningSequence = GetSequence(nSeqId);
        }
예제 #11
0
        private bool ReadSequences()
        {
            List<CCBSequence> sequences = mActionManager.Sequences;

            int numSeqs = ReadInt(false);

            for (int i = 0; i < numSeqs; i++)
            {
                var seq = new CCBSequence();

                seq.Duration = ReadFloat();
                seq.Name = ReadCachedString();
                seq.SequenceId = ReadInt(false);
                seq.ChainedSequenceId = ReadInt(true);

                sequences.Add(seq);
            }

            mActionManager.AutoPlaySequenceId = ReadInt(true);
            return true;
        }
예제 #12
0
        private void SequenceCompleted()
        {
            if (mDelegate != null)
            {
                mDelegate(mRunningSequence.Name);
            }

            int nextSeqId = mRunningSequence.ChainedSequenceId;
            mRunningSequence = null;

            if (nextSeqId != -1)
            {
                RunAnimations(nextSeqId, 0);
            }
        }
예제 #13
0
        public void RunAnimations(int nSeqId, float fTweenDuration)
        {
            Debug.Assert(nSeqId != -1, "Sequence id couldn't be found");

            mRootNode.StopAllActions();

            foreach (var pElement in mNodeSequences)
            {
                CCNode node = pElement.Key;
                node.StopAllActions();

                // Refer to CCBReader::readKeyframe() for the real type of value
                Dictionary<int, Dictionary<string, CCBSequenceProperty>> seqs = pElement.Value;

                var seqNodePropNames = new List<string>();

                Dictionary<string, CCBSequenceProperty> seqNodeProps;
                if (seqs.TryGetValue(nSeqId, out seqNodeProps))
                {
                    // Reset nodes that have sequence node properties, and run actions on them
                    foreach (var pElement1 in seqNodeProps)
                    {
                        string propName = pElement1.Key;
                        CCBSequenceProperty seqProp = pElement1.Value;
                        seqNodePropNames.Add(propName);

                        SetFirstFrame(node, seqProp, fTweenDuration);
                        RunAction(node, seqProp, fTweenDuration);
                    }
                }

                // Reset the nodes that may have been changed by other timelines
                Dictionary<string, object> nodeBaseValues;
                if (mBaseValues.TryGetValue(node, out nodeBaseValues))
                {
                    foreach (var pElement2 in nodeBaseValues)
                    {
                        if (!seqNodePropNames.Contains(pElement2.Key))
                        {
                            object value = pElement2.Value;

                            if (value != null)
                            {
                                SetAnimatedProperty(pElement2.Key, node, value, fTweenDuration);
                            }
                        }
                    }
                }
            }

            // Make callback at end of sequence
            CCBSequence seq = GetSequence(nSeqId);
            CCAction completeAction = new CCSequence (
                new CCDelayTime (seq.Duration + fTweenDuration),
                new CCCallFunc(SequenceCompleted)
                );

            mRootNode.RunAction(completeAction);

            // Set the running scene
            mRunningSequence = GetSequence(nSeqId);
        }
예제 #14
0
        private void SequenceCompleted()
        {

            string runningSequenceName = _runningSequence.Name;
            int nextSeqId = _runningSequence.ChainedSequenceId;
            _runningSequence = null;

            if (_lastCompletedSequenceName != runningSequenceName)
            {
                _lastCompletedSequenceName = runningSequenceName;
            }

            if (_delegate != null)
            {
                _delegate(_runningSequence.Name);
            }

            if (_animationCompleteCallbackFunc != null)
            {
                _animationCompleteCallbackFunc();
            }


            if (nextSeqId != -1)
            {
                RunAnimations(nextSeqId, 0);
            }
        }