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);
            }
        }
Esempio n. 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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
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;
        }
Esempio n. 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;
        }
Esempio n. 7
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;
        }
        public void RunAnimationsForSequenceIdTweenDuration(int nSeqId, float fTweenDuration)
        {
            Debug.Assert(nSeqId != -1, "Sequence id couldn't be found");

            _rootNode.StopAllActions();

            foreach (var pElement in _nodeSequences)
            {
                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 (_baseValues.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)
                );

            _rootNode.RunAction(completeAction);

            // Set the running scene

            if (seq.CallBackChannel != null)
            {
                CCAction action = (CCAction)ActionForCallbackChannel(seq.CallBackChannel);
                if (action != null)
                {
                    _rootNode.RunAction(action);
                }
            }

            if (seq.SoundChannel != null)
            {
                CCAction action = (CCAction)ActionForSoundChannel(seq.SoundChannel);
                if (action != null)
                {
                    _rootNode.RunAction(action);
                }
            }

            _runningSequence = GetSequence(nSeqId);
        }
Esempio n. 9
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);
			}
		}
Esempio n. 10
0
		public void RunAnimationsForSequenceIdTweenDuration(int nSeqId, float fTweenDuration)
		{
			Debug.Assert(nSeqId != -1, "Sequence id couldn't be found");

			_rootNode.StopAllActions();

			foreach (var pElement in _nodeSequences)
			{
				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 (_baseValues.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)
											   );

			_rootNode.RunAction(completeAction);

			// Set the running scene

			if (seq.CallBackChannel != null)
			{
				CCAction action = (CCAction)ActionForCallbackChannel(seq.CallBackChannel);
				if (action != null)
				{
					_rootNode.RunAction(action);
				}
			}

			if (seq.SoundChannel != null)
			{
				CCAction action = (CCAction)ActionForSoundChannel(seq.SoundChannel);
				if (action != null)
				{
					_rootNode.RunAction(action);
				}
			}

			_runningSequence = GetSequence(nSeqId);
		}