Esempio n. 1
0
        private void SetFirstFrame(CCNode node, CCBSequenceProperty pSeqProp, float fTweenDuration)
        {
            List <CCBKeyframe> keyframes = pSeqProp.Keyframes;

            if (keyframes.Count == 0)
            {
                // Use base value (no animation)
                object baseValue = GetBaseValue(node, pSeqProp.Name);
                Debug.Assert(baseValue != null, "No baseValue found for property");
                SetAnimatedProperty(pSeqProp.Name, node, baseValue, fTweenDuration);
            }
            else
            {
                // Use first keyframe
                CCBKeyframe keyframe = keyframes[0];
                SetAnimatedProperty(pSeqProp.Name, node, keyframe.Value, fTweenDuration);
            }
        }
Esempio n. 2
0
        private void RunAction(CCNode node, CCBSequenceProperty pSeqProp, float fTweenDuration)
        {
            List <CCBKeyframe> keyframes = pSeqProp.Keyframes;
            int numKeyframes             = keyframes.Count;

            if (numKeyframes > 1)
            {
                // Make an animation!
                var actions = new List <CCFiniteTimeAction>();

                CCBKeyframe keyframeFirst = keyframes[0];
                float       timeFirst     = keyframeFirst.Time + fTweenDuration;

                if (timeFirst > 0)
                {
                    actions.Add(new CCDelayTime(timeFirst));
                }

                for (int i = 0; i < numKeyframes - 1; ++i)
                {
                    CCBKeyframe kf0 = keyframes[i];
                    CCBKeyframe kf1 = keyframes[i + 1];

                    CCActionInterval action = GetAction(kf0, kf1, pSeqProp.Name, node);
                    if (action != null)
                    {
                        // Apply easing
                        action = GetEaseAction(action, kf0.EasingType, kf0.EasingOpt);

                        actions.Add(action);
                    }
                }

                if (actions.Count > 1)
                {
                    CCFiniteTimeAction seq = new CCSequence(actions.ToArray());
                    node.RunAction(seq);
                }
                else
                {
                    node.RunAction(actions[0]);
                }
            }
        }
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 Object ActionForSoundChannel(CCBSequenceProperty channel)
        {
            float lastKeyframeTime = 0;

            var actions      = new List <CCFiniteTimeAction>();
            var keyframes    = channel.Keyframes;
            int numKeyframes = keyframes.Count;

            for (int i = 0; i < numKeyframes; ++i)
            {
                CCBKeyframe keyframe = keyframes[i];
                float       timeSinceLastKeyframe = keyframe.Time - lastKeyframeTime;
                lastKeyframeTime = keyframe.Time;
                if (timeSinceLastKeyframe > 0)
                {
                    actions.Add(new CCDelayTime(timeSinceLastKeyframe));
                }

                var    keyVal    = (List <CCBValue>)keyframe.Value;
                string soundFile = keyVal[0].GetStringValue();

                float pitch, pan, gain;

                pitch = float.Parse(keyVal[1].GetStringValue());

                pan = float.Parse(keyVal[2].GetStringValue());

                gain = float.Parse(keyVal[3].GetStringValue());

                actions.Add(CCBSoundEffect.ActionWithSoundFile(soundFile, pitch, pan, gain));
            }

            if (actions.Count < 1)
            {
                return(null);
            }

            return(new CCSequence(actions.ToArray()));
        }
Esempio n. 5
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. 6
0
        private CCBKeyframe ReadKeyframe(CCBPropertyType type)
        {
            var keyframe = new CCBKeyframe();

            keyframe.Time = ReadFloat();

            var easingType = (CCBEasingType) ReadInt(false);
            float easingOpt = 0;
            object value = null;

            if (easingType == CCBEasingType.CubicIn
                || easingType == CCBEasingType.CubicOut
                || easingType == CCBEasingType.CubicInOut
                || easingType == CCBEasingType.ElasticIn
                || easingType == CCBEasingType.ElasticOut
                || easingType == CCBEasingType.ElasticInOut)
            {
                easingOpt = ReadFloat();
            }
            keyframe.EasingType = easingType;
            keyframe.EasingOpt = easingOpt;

            if (type == CCBPropertyType.Check)
            {
                value = new CCBValue(ReadBool());
            }
            else if (type == CCBPropertyType.Byte)
            {
                value = new CCBValue(ReadByte());
            }
            else if (type == CCBPropertyType.Color3)
            {
                byte r = ReadByte();
                byte g = ReadByte();
                byte b = ReadByte();

                var c = new CCColor3B(r, g, b);
                value = new CCColor3BWapper(c);
            }
            else if (type == CCBPropertyType.Degrees)
            {
                value = new CCBValue(ReadFloat());
            }
            else if (type == CCBPropertyType.ScaleLock || type == CCBPropertyType.Position || type == CCBPropertyType.FloatXY)
            {
                float a = ReadFloat();
                float b = ReadFloat();

                value = new List<CCBValue>
                    {
                        new CCBValue(a),
                        new CCBValue(b)
                    };
            }
            else if (type == CCBPropertyType.SpriteFrame)
            {
                string spriteSheet = ReadCachedString();
                string spriteFile = ReadCachedString();

                CCSpriteFrame spriteFrame;

                if (String.IsNullOrEmpty(spriteSheet))
                {
                    spriteFile = _CCBRootPath + spriteFile;

                    CCTexture2D texture = CCTextureCache.SharedTextureCache.AddImage(CCFileUtils.RemoveExtension(spriteFile));
                    var bounds = new CCRect(0, 0, texture.ContentSize.Width, texture.ContentSize.Height);
                    spriteFrame = new CCSpriteFrame(texture, bounds);
                }
                else
                {
                    spriteSheet = _CCBRootPath + spriteSheet;
                    CCSpriteFrameCache frameCache = CCSpriteFrameCache.SharedSpriteFrameCache;

                    // Load the sprite sheet only if it is not loaded            
                    if (!_loadedSpriteSheets.Contains(spriteSheet))
                    {
                        frameCache.AddSpriteFramesWithFile(spriteSheet);
                        _loadedSpriteSheets.Add(spriteSheet);
                    }

                    spriteFrame = frameCache.SpriteFrameByName(spriteFile);
                }
                value = spriteFrame;
            }

            keyframe.Value = value;

            return keyframe;
        }
Esempio n. 7
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. 8
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. 9
0
        private void SetAnimatedProperty(string pPropName, CCNode node, object pValue, float fTweenDuraion)
        {
            if (fTweenDuraion > 0)
            {
                // Create a fake keyframe to generate the action from
                var kf1 = new CCBKeyframe();
                kf1.Value      = pValue;
                kf1.Time       = fTweenDuraion;
                kf1.EasingType = CCBKeyframeEasing.Linear;

                // Animate
                CCActionInterval tweenAction = GetAction(null, kf1, pPropName, node);
                node.RunAction(tweenAction);
            }
            else
            {
                // Just set the value

                if (pPropName == "position")
                {
                    // Get position type
                    var array = (List <CCBValue>)GetBaseValue(node, pPropName);
                    var type  = (CCBPositionType)array[2].GetIntValue();

                    // Get relative position
                    var   value = (List <CCBValue>)pValue;
                    float x     = value[0].GetFloatValue();
                    float y     = value[1].GetFloatValue();

                    node.Position = CCBHelper.GetAbsolutePosition(new CCPoint(x, y), type, GetContainerSize(node.Parent), pPropName);
                }
                else if (pPropName == "scale")
                {
                    // Get scale type
                    var array = (List <CCBValue>)GetBaseValue(node, pPropName);
                    var type  = (CCBScaleType)array[2].GetIntValue();

                    // Get relative scale
                    var   value = (List <CCBValue>)pValue;
                    float x     = value[0].GetFloatValue();
                    float y     = value[1].GetFloatValue();

                    CCBHelper.SetRelativeScale(node, x, y, type, pPropName);
                }
                else
                {
                    // [node setValue:value forKey:name];

                    // TODO only handle rotation, opacity, displayFrame, color
                    if (pPropName == "rotation")
                    {
                        float rotate = ((CCBValue)pValue).GetFloatValue();
                        node.Rotation = rotate;
                    }
                    else if (pPropName == "opacity")
                    {
                        byte opacity = ((CCBValue)pValue).GetByteValue();
                        ((ICCRGBAProtocol)node).Opacity = opacity;
                    }
                    else if (pPropName == "displayFrame")
                    {
                        ((CCSprite)node).DisplayFrame = (CCSpriteFrame)pValue;
                    }
                    else if (pPropName == "color")
                    {
                        var color = (CCColor3BWapper)pValue;
                        ((CCSprite)node).Color = color.getColor();
                    }
                    else
                    {
                        CCLog.Log("unsupported property name is {0}", pPropName);
                        Debug.Assert(false, "unsupported property now");
                    }
                }
            }
        }
Esempio n. 10
0
        private CCActionInterval GetAction(CCBKeyframe pKeyframe0, CCBKeyframe pKeyframe1, string pPropName, CCNode node)
        {
            float duration = pKeyframe1.Time - (pKeyframe0 != null ? pKeyframe0.Time : 0);

            switch (pPropName)
            {
            case "rotation":
            {
                var value = (CCBValue)pKeyframe1.Value;
                return(new CCBRotateTo(duration, value.GetFloatValue()));
            }

            case "opacity":
            {
                var value = (CCBValue)pKeyframe1.Value;
                return(new CCFadeTo(duration, value.GetByteValue()));
            }

            case "color":
            {
                var       color = (CCColor3BWapper)pKeyframe1.Value;
                CCColor3B c     = color.getColor();

                return(new CCTintTo(duration, c.R, c.G, c.B));
            }

            case "visible":
            {
                var value = (CCBValue)pKeyframe1.Value;
                if (value.GetBoolValue())
                {
                    return(new CCSequence(new CCDelayTime(duration), new CCShow()));
                }
                return(new CCSequence(new CCDelayTime(duration), new CCHide()));
            }

            case "displayFrame":
                return(new CCSequence(new CCDelayTime(duration), new CCBSetSpriteFrame((CCSpriteFrame)pKeyframe1.Value)));

            case "position":
            {
                // Get position type
                var array = (List <CCBValue>)GetBaseValue(node, pPropName);
                var type  = (CCBPositionType)array[2].GetIntValue();

                // Get relative position
                var   value = (List <CCBValue>)pKeyframe1.Value;
                float x     = value[0].GetFloatValue();
                float y     = value[1].GetFloatValue();

                CCSize containerSize = GetContainerSize(node.Parent);

                CCPoint absPos = CCBHelper.GetAbsolutePosition(new CCPoint(x, y), type, containerSize, pPropName);

                return(new CCMoveTo(duration, absPos));
            }

            case "scale":
            {
                // Get position type
                var array = (List <CCBValue>)GetBaseValue(node, pPropName);
                var type  = (CCBScaleType)array[2].GetIntValue();

                // Get relative scale
                var   value = (List <CCBValue>)pKeyframe1.Value;
                float x     = value[0].GetFloatValue();
                float y     = value[1].GetFloatValue();

                if (type == CCBScaleType.MultiplyResolution)
                {
                    float resolutionScale = CCBReader.ResolutionScale;
                    x *= resolutionScale;
                    y *= resolutionScale;
                }

                return(new CCScaleTo(duration, x, y));
            }

            default:
                CCLog.Log("CCBReader: Failed to create animation for property: {0}", pPropName);
                break;
            }

            return(null);
        }
Esempio n. 11
0
        private CCNode ReadNodeGraph(CCNode parent)
        {
            /* Read class name. */
            string className = ReadCachedString();

            // Read assignment type and name
            var memberVarAssignmentType = (CCBTargetType)ReadInt(false);

            string memberVarAssignmentName = String.Empty;

            if (memberVarAssignmentType != CCBTargetType.None)
            {
                memberVarAssignmentName = ReadCachedString();
            }

            CCNodeLoader ccNodeLoader = mCCNodeLoaderLibrary.GetCCNodeLoader(className);

            if (ccNodeLoader == null)
            {
                CCLog.Log("no corresponding node loader for {0}", className);
                return(null);
            }

            CCNode node = ccNodeLoader.LoadCCNode(parent, this);

            // Set root node
            if (mActionManager.RootNode == null)
            {
                mActionManager.RootNode = node;
            }

            // Read animated properties
            var seqs = new Dictionary <int, Dictionary <string, CCBSequenceProperty> >();

            mAnimatedProps.Clear();

            int numSequence = ReadInt(false);

            for (int i = 0; i < numSequence; ++i)
            {
                int seqId        = ReadInt(false);
                var seqNodeProps = new Dictionary <string, CCBSequenceProperty>();

                int numProps = ReadInt(false);

                for (int j = 0; j < numProps; ++j)
                {
                    var seqProp = new CCBSequenceProperty();

                    seqProp.Name = ReadCachedString();
                    seqProp.Type = (CCBPropType)ReadInt(false);
                    mAnimatedProps.Add(seqProp.Name);

                    int numKeyframes = ReadInt(false);

                    for (int k = 0; k < numKeyframes; ++k)
                    {
                        CCBKeyframe keyframe = ReadKeyframe(seqProp.Type);

                        seqProp.Keyframes.Add(keyframe);
                    }

                    seqNodeProps.Add(seqProp.Name, seqProp);
                }

                seqs.Add(seqId, seqNodeProps);
            }

            if (seqs.Count > 0)
            {
                mActionManager.AddNode(node, seqs);
            }

            // Read properties
            ccNodeLoader.ParseProperties(node, parent, this);

            // Handle sub ccb files (remove middle node)
            if (node is CCBFile)
            {
                var ccbFileNode = (CCBFile)node;

                CCNode embeddedNode = ccbFileNode.FileNode;
                embeddedNode.Position = ccbFileNode.Position;
                embeddedNode.Rotation = ccbFileNode.Rotation;
                embeddedNode.Scale    = ccbFileNode.Scale;
                embeddedNode.Tag      = ccbFileNode.Tag;
                embeddedNode.Visible  = true;
                embeddedNode.IgnoreAnchorPointForPosition = ccbFileNode.IgnoreAnchorPointForPosition;

                ccbFileNode.FileNode = null;

                node = embeddedNode;
            }

#if CCB_ENABLE_JAVASCRIPT
            /*
             * if (memberVarAssignmentType && memberVarAssignmentName && ![memberVarAssignmentName isEqualToString:@""])
             * {
             * [[JSCocoa sharedController] setObject:node withName:memberVarAssignmentName];
             * }*/
#else
            if (memberVarAssignmentType != CCBTargetType.None)
            {
                object target = null;
                if (memberVarAssignmentType == CCBTargetType.DocumentRoot)
                {
                    target = mActionManager.RootNode;
                }
                else if (memberVarAssignmentType == CCBTargetType.Owner)
                {
                    target = mOwner;
                }

                if (target != null)
                {
                    bool assigned = false;

                    var targetAsCCBMemberVariableAssigner = (ICCBMemberVariableAssigner)target;

                    if (targetAsCCBMemberVariableAssigner != null)
                    {
                        assigned = targetAsCCBMemberVariableAssigner.OnAssignCCBMemberVariable(target, memberVarAssignmentName, node);
                    }

                    if (!assigned && mCCBMemberVariableAssigner != null)
                    {
                        mCCBMemberVariableAssigner.OnAssignCCBMemberVariable(target, memberVarAssignmentName, node);
                    }
                }
            }
#endif
            // CCB_ENABLE_JAVASCRIPT

            mAnimatedProps.Clear();

            /* Read and add children. */
            int numChildren = ReadInt(false);
            for (int i = 0; i < numChildren; i++)
            {
                CCNode child = ReadNodeGraph(node);
                node.AddChild(child);
            }

            // Call onNodeLoaded
            var nodeAsCCNodeLoaderListener = node as ICCNodeLoaderListener;
            if (nodeAsCCNodeLoaderListener != null)
            {
                nodeAsCCNodeLoaderListener.OnNodeLoaded(node, ccNodeLoader);
            }
            else if (mCCNodeLoaderListener != null)
            {
                mCCNodeLoaderListener.OnNodeLoaded(node, ccNodeLoader);
            }

            return(node);
        }
Esempio n. 12
0
        private CCBKeyframe ReadKeyframe(CCBPropType type)
        {
            var keyframe = new CCBKeyframe();

            keyframe.Time = ReadFloat();

            var    easingType = (CCBKeyframeEasing)ReadInt(false);
            float  easingOpt  = 0;
            object value      = null;

            if (easingType == CCBKeyframeEasing.CubicIn ||
                easingType == CCBKeyframeEasing.CubicOut ||
                easingType == CCBKeyframeEasing.CubicInOut ||
                easingType == CCBKeyframeEasing.ElasticIn ||
                easingType == CCBKeyframeEasing.ElasticOut ||
                easingType == CCBKeyframeEasing.ElasticInOut)
            {
                easingOpt = ReadFloat();
            }
            keyframe.EasingType = easingType;
            keyframe.EasingOpt  = easingOpt;

            if (type == CCBPropType.Check)
            {
                value = new CCBValue(ReadBool());
            }
            else if (type == CCBPropType.Byte)
            {
                value = new CCBValue(ReadByte());
            }
            else if (type == CCBPropType.Color3)
            {
                byte r = ReadByte();
                byte g = ReadByte();
                byte b = ReadByte();

                var c = new CCColor3B(r, g, b);
                value = new CCColor3BWapper(c);
            }
            else if (type == CCBPropType.Degrees)
            {
                value = new CCBValue(ReadFloat());
            }
            else if (type == CCBPropType.ScaleLock || type == CCBPropType.Position)
            {
                float a = ReadFloat();
                float b = ReadFloat();

                value = new List <CCBValue>
                {
                    new CCBValue(a),
                    new CCBValue(b)
                };
            }
            else if (type == CCBPropType.SpriteFrame)
            {
                string spriteSheet = ReadCachedString();
                string spriteFile  = ReadCachedString();

                CCSpriteFrame spriteFrame;

                if (String.IsNullOrEmpty(spriteSheet))
                {
                    CCTexture2D texture = CCTextureCache.SharedTextureCache.AddImage(CCFileUtils.RemoveExtension(spriteFile));
                    var         bounds  = new CCRect(0, 0, texture.ContentSize.Width, texture.ContentSize.Height);
                    spriteFrame = new CCSpriteFrame(texture, bounds);
                }
                else
                {
                    CCSpriteFrameCache frameCache = CCSpriteFrameCache.SharedSpriteFrameCache;

                    // Load the sprite sheet only if it is not loaded
                    if (!mLoadedSpriteSheets.Contains(spriteSheet))
                    {
                        frameCache.AddSpriteFramesWithFile(spriteSheet);
                        mLoadedSpriteSheets.Add(spriteSheet);
                    }

                    spriteFrame = frameCache.SpriteFrameByName(spriteFile);
                }
                value = spriteFrame;
            }

            keyframe.Value = value;

            return(keyframe);
        }
Esempio n. 13
0
        public Object ActionForCallbackChannel(CCBSequenceProperty channel)
        {
            float lastKeyframeTime = 0;

            var actions      = new List <CCFiniteTimeAction>();
            var keyframes    = channel.Keyframes;
            int numKeyframes = keyframes.Count;

            for (int i = 0; i < numKeyframes; ++i)
            {
                CCBKeyframe keyframe = keyframes[i];
                float       timeSinceLastKeyframe = keyframe.Time - lastKeyframeTime;
                lastKeyframeTime = keyframe.Time;
                if (timeSinceLastKeyframe > 0)
                {
                    actions.Add(new CCDelayTime(timeSinceLastKeyframe));
                }

                var           keyVal         = (List <CCBValue>)keyframe.Value;
                string        selectorName   = keyVal[0].GetStringValue();
                CCBTargetType selectorTarget =
                    (CCBTargetType)int.Parse(keyVal[1].GetStringValue());

                if (_jsControlled)
                {
                    string     callbackName = string.Format("{0}:{1}", selectorTarget, selectorName);
                    CCCallFunc callback     = (CCCallFunc)_keyframeCallFuncs[callbackName].Copy();

                    if (callback != null)
                    {
                        actions.Add(callback);
                    }
                }
                else
                {
                    Object target = null;

                    if (selectorTarget == CCBTargetType.DocumentRoot)
                    {
                        target = _rootNode;
                    }
                    else if (selectorTarget == CCBTargetType.Owner)
                    {
                        target = _owner;
                    }

                    if (target != null)
                    {
                        if (selectorName.Length > 0)
                        {
                            Action <CCNode> selCallFunc = null;

                            ICCBSelectorResolver targetAsCCBSelectorResolver = target as ICCBSelectorResolver;

                            if (targetAsCCBSelectorResolver != null)
                            {
                                selCallFunc = targetAsCCBSelectorResolver.OnResolveCCBCCCallFuncSelector(target,
                                                                                                         selectorName);
                            }

                            if (selCallFunc == null)
                            {
                                CCLog.Log("Skipping selector {0} since no CCBSelectorResolver is present.",
                                          selectorName);
                            }
                            else
                            {
                                CCCallFuncN callback = new CCCallFuncN(selCallFunc);
                                actions.Add(callback);
                            }
                        }
                        else
                        {
                            CCLog.Log("Unexpected empty selector.");
                        }
                    }
                }
            }
            if (actions.Capacity < 1)
            {
                return(null);
            }

            return(new CCSequence(actions.ToArray()));
        }
        private void SetAnimatedProperty(string pPropName, CCNode node, object pValue, float fTweenDuraion)
        {
            if (fTweenDuraion > 0)
            {
                // Create a fake keyframe to generate the action from
                var kf1 = new CCBKeyframe();
                kf1.Value = pValue;
                kf1.Time = fTweenDuraion;
                kf1.EasingType = CCBKeyframeEasing.Linear;

                // Animate
                CCActionInterval tweenAction = GetAction(null, kf1, pPropName, node);
                node.RunAction(tweenAction);
            }
            else
            {
                // Just set the value

                if (pPropName == "position")
                {
                    // Get position type
                    var array = (List<CCBValue>) GetBaseValue(node, pPropName);
                    var type = (CCBPositionType) array[2].GetIntValue();

                    // Get relative position
                    var value = (List<CCBValue>) pValue;
                    float x = value[0].GetFloatValue();
                    float y = value[1].GetFloatValue();

                    node.Position = CCBHelper.GetAbsolutePosition(new CCPoint(x, y), type, GetContainerSize(node.Parent), pPropName);
                }
                else if (pPropName == "scale")
                {
                    // Get scale type
                    var array = (List<CCBValue>) GetBaseValue(node, pPropName);
                    var type = (CCBScaleType) array[2].GetIntValue();

                    // Get relative scale
                    var value = (List<CCBValue>) pValue;
                    float x = value[0].GetFloatValue();
                    float y = value[1].GetFloatValue();

                    CCBHelper.SetRelativeScale(node, x, y, type, pPropName);
                }
                else
                {
                    // [node setValue:value forKey:name];

                    // TODO only handle rotation, opacity, displayFrame, color
                    if (pPropName == "rotation")
                    {
                        float rotate = ((CCBValue) pValue).GetFloatValue();
                        node.Rotation = rotate;
                    }
                    else if (pPropName == "opacity")
                    {
                        byte opacity = ((CCBValue) pValue).GetByteValue();
                        ((ICCRGBAProtocol) node).Opacity = opacity;
                    }
                    else if (pPropName == "displayFrame")
                    {
                        ((CCSprite) node).DisplayFrame = (CCSpriteFrame) pValue;
                    }
                    else if (pPropName == "color")
                    {
                        var color = (ccColor3BWapper) pValue;
                        ((CCSprite) node).Color = color.getColor();
                    }
                    else
                    {
                        CCLog.Log("unsupported property name is {0}", pPropName);
                        Debug.Assert(false, "unsupported property now");
                    }
                }
            }
        }
        private CCActionInterval GetAction(CCBKeyframe pKeyframe0, CCBKeyframe pKeyframe1, string pPropName, CCNode node)
        {
            float duration = pKeyframe1.Time - (pKeyframe0 != null ? pKeyframe0.Time : 0);

            switch (pPropName)
            {
                case "rotation":
                    {
                        var value = (CCBValue) pKeyframe1.Value;
                        return new CCBRotateTo(duration, value.GetFloatValue());
                    }
                case "opacity":
                    {
                        var value = (CCBValue) pKeyframe1.Value;
                        return new CCFadeTo (duration, value.GetByteValue());
                    }
                case "color":
                    {
                        var color = (ccColor3BWapper) pKeyframe1.Value;
                        CCColor3B c = color.getColor();

                        return new CCTintTo (duration, c.R, c.G, c.B);
                    }
                case "visible":
                    {
                        var value = (CCBValue) pKeyframe1.Value;
                        if (value.GetBoolValue())
                        {
                            return new CCSequence (new CCDelayTime (duration), new CCShow());
                        }
                        return new CCSequence (new CCDelayTime (duration), new CCHide());
                    }
                case "displayFrame":
                    return new CCSequence (new CCDelayTime (duration), new CCBSetSpriteFrame((CCSpriteFrame) pKeyframe1.Value));
                case "position":
                    {
                        // Get position type
                        var array = (List<CCBValue>) GetBaseValue(node, pPropName);
                        var type = (CCBPositionType) array[2].GetIntValue();

                        // Get relative position
                        var value = (List<CCBValue>) pKeyframe1.Value;
                        float x = value[0].GetFloatValue();
                        float y = value[1].GetFloatValue();

                        CCSize containerSize = GetContainerSize(node.Parent);

                        CCPoint absPos = CCBHelper.GetAbsolutePosition(new CCPoint(x, y), type, containerSize, pPropName);

                        return new CCMoveTo (duration, absPos);
                    }
                case "scale":
                    {
                        // Get position type
                        var array = (List<CCBValue>) GetBaseValue(node, pPropName);
                        var type = (CCBScaleType) array[2].GetIntValue();

                        // Get relative scale
                        var value = (List<CCBValue>) pKeyframe1.Value;
                        float x = value[0].GetFloatValue();
                        float y = value[1].GetFloatValue();

                        if (type == CCBScaleType.MultiplyResolution)
                        {
                            float resolutionScale = CCBReader.ResolutionScale;
                            x *= resolutionScale;
                            y *= resolutionScale;
                        }

                        return new CCScaleTo(duration, x, y);
                    }
                default:
                    CCLog.Log("CCBReader: Failed to create animation for property: {0}", pPropName);
                    break;
            }

            return null;
        }