Example #1
0
        protected virtual CCColor3B ParsePropTypeColor3(CCNode node, CCNode parent, CCBReader reader, string propertyName)
        {
            byte red   = reader.ReadByte();
            byte green = reader.ReadByte();
            byte blue  = reader.ReadByte();

            var color = new CCColor3B(red, green, blue);

            if (reader.AnimatedProperties.Contains(propertyName))
            {
                CCColor3BWapper value = new CCColor3BWapper(color);
                reader.AnimationManager.SetBaseValue(value, node, propertyName);
            }
            return(color);
        }
Example #2
0
        protected virtual byte ParsePropTypeByte(CCNode node, CCNode parent, CCBReader reader, string propertyName)
        {
            byte ret = reader.ReadByte();

            if (reader.AnimatedProperties.Contains(propertyName))
            {
                reader.AnimationManager.SetBaseValue(new CCBValue(ret), node, propertyName);
            }

            return(ret);
        }
Example #3
0
        protected virtual CCColor3B ParsePropTypeColor3(CCNode node, CCNode parent, CCBReader reader, string propertyName)
        {
            byte red = reader.ReadByte();
            byte green = reader.ReadByte();
            byte blue = reader.ReadByte();

            var color = new CCColor3B(red, green, blue);
            if (reader.AnimatedProperties.Contains(propertyName))
            {
                CCColor3BWapper value = new CCColor3BWapper(color);
                reader.AnimationManager.SetBaseValue(value, node, propertyName);
            }
            return color;
        }
Example #4
0
        protected virtual byte ParsePropTypeByte(CCNode node, CCNode parent, CCBReader reader, string propertyName)
        {
            byte ret = reader.ReadByte();

            if (reader.AnimatedProperties.Contains(propertyName))
            {
                reader.AnimationManager.SetBaseValue(new CCBValue(ret), node, propertyName);
            }

            return ret;
        }
Example #5
0
        public virtual void ParseProperties(CCNode node, CCNode parent, CCBReader reader)
        {
            int numRegularProps = reader.ReadInt(false);
            int numExturaProps = reader.ReadInt(false);
            int propertyCount = numRegularProps + numExturaProps;

            for (int i = 0; i < propertyCount; i++)
            {
                bool isExtraProp = (i >= numRegularProps);
                int type = reader.ReadInt(false);
                string propertyName = reader.ReadCachedString();

                // Check if the property can be set for this platform
                bool setProp = false;

                var platform = (PlatformType) reader.ReadByte();
                if (platform == PlatformType.All)
                {
                    setProp = true;
                }
#if __CC_PLATFORM_IOS
        if(platform == kCCBPlatform.kCCBPlatformIOS) 
        {
            setProp = true;
        }
#elif __CC_PLATFORM_MAC
        if(platform == kCCBPlatform.kCCBPlatformMac) 
        {
            setProp = true;
        }
#endif

                // Forward properties for sub ccb files
                if (node is CCBFile)
                {
                    var ccbNode = (CCBFile) node;
                    if (ccbNode.FileNode != null && isExtraProp)
                    {
                        node = ccbNode.FileNode;

                        // Skip properties that doesn't have a value to override
                        var extraPropsNames = (List<string>) node.UserObject;
                        bool bFound = false;
                        foreach (var pObj in extraPropsNames)
                        {
                            if (pObj == propertyName)
                            {
                                bFound = true;
                                break;
                            }
                        }
                        setProp &= bFound;
                    }
                }
                else if (isExtraProp && node == reader.AnimationManager.RootNode)
                {
                    var extraPropsNames = (List<string>) node.UserObject;
                    if (extraPropsNames == null)
                    {
                        extraPropsNames = new List<string>();
                        node.UserObject = extraPropsNames;
                    }

                    extraPropsNames.Add(propertyName);
                }

                switch ((CCBPropertyType) type)
                {
                    case CCBPropertyType.Position:
                        {
                            CCPoint position = ParsePropTypePosition(node, parent, reader, propertyName);
                            if (setProp)
                            {
                                OnHandlePropTypePosition(node, parent, propertyName, position, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Point:
                        {
                            CCPoint point = ParsePropTypePoint(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypePoint(node, parent, propertyName, point, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.PointLock:
                        {
                            CCPoint pointLock = ParsePropTypePointLock(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypePointLock(node, parent, propertyName, pointLock, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Size:
                        {
                            CCSize size = ParsePropTypeSize(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeSize(node, parent, propertyName, size, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.ScaleLock:
                        {
                            float[] scaleLock = ParsePropTypeScaleLock(node, parent, reader, propertyName);
                            if (setProp)
                            {
                                OnHandlePropTypeScaleLock(node, parent, propertyName, scaleLock, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Float:
                        {
                            float f = ParsePropTypeFloat(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeFloat(node, parent, propertyName, f, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.FloatXY:
                        {
                            var xy = ParsePropTypeFloatXY(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeFloatXY(node, parent, propertyName, xy, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Degrees:
                        {
                            float degrees = ParsePropTypeDegrees(node, parent, reader, propertyName);
                            if (setProp)
                            {
                                OnHandlePropTypeDegrees(node, parent, propertyName, degrees, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.FloatScale:
                        {
                            float floatScale = ParsePropTypeFloatScale(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeFloatScale(node, parent, propertyName, floatScale, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Integer:
                        {
                            int integer = ParsePropTypeInteger(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeInteger(node, parent, propertyName, integer, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.IntegerLabeled:
                        {
                            int integerLabeled = ParsePropTypeIntegerLabeled(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeIntegerLabeled(node, parent, propertyName, integerLabeled, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.FloatVar:
                        {
                            float[] floatVar = ParsePropTypeFloatVar(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeFloatVar(node, parent, propertyName, floatVar, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Check:
                        {
                            bool check = ParsePropTypeCheck(node, parent, reader, propertyName);
                            if (setProp)
                            {
                                OnHandlePropTypeCheck(node, parent, propertyName, check, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.SpriteFrame:
                        {
                            CCSpriteFrame ccSpriteFrame = ParsePropTypeSpriteFrame(node, parent, reader, propertyName);
                            if (setProp)
                            {
                                OnHandlePropTypeSpriteFrame(node, parent, propertyName, ccSpriteFrame, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Animation:
                        {
                            CCAnimation ccAnimation = ParsePropTypeAnimation(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeAnimation(node, parent, propertyName, ccAnimation, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Texture:
                        {
                            CCTexture2D ccTexture2D = ParsePropTypeTexture(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeTexture(node, parent, propertyName, ccTexture2D, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Byte:
                        {
                            byte b = ParsePropTypeByte(node, parent, reader, propertyName);
                            if (setProp)
                            {
                                OnHandlePropTypeByte(node, parent, propertyName, b, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Color3:
                        {
                            CCColor3B color3B = ParsePropTypeColor3(node, parent, reader, propertyName);
                            if (setProp)
                            {
                                OnHandlePropTypeColor3(node, parent, propertyName, color3B, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Color4FVar:
                        {
                            CCColor4F[] color4FVar = ParsePropTypeColor4FVar(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeColor4FVar(node, parent, propertyName, color4FVar, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Flip:
                        {
                            bool[] flip = ParsePropTypeFlip(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeFlip(node, parent, propertyName, flip, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Blendmode:
                        {
                            CCBlendFunc blendFunc = ParsePropTypeBlendFunc(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeBlendFunc(node, parent, propertyName, blendFunc, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.FntFile:
                        {
                            string fntFile = ParsePropTypeFntFile(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeFntFile(node, parent, propertyName, fntFile, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.FontTTF:
                        {
                            string fontTTF = ParsePropTypeFontTTF(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeFontTTF(node, parent, propertyName, fontTTF, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.String:
                        {
                            string s = ParsePropTypeString(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeString(node, parent, propertyName, s, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Text:
                        {
                            string text = ParsePropTypeText(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeText(node, parent, propertyName, text, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.Block:
                        {
                            BlockData blockData = ParsePropTypeBlock(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeBlock(node, parent, propertyName, blockData, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.BlockCCControl:
                        {
                            BlockCCControlData blockCCControlData = ParsePropTypeBlockCcControl(node, parent, reader);
                            if (setProp && blockCCControlData != null)
                            {
                                OnHandlePropTypeBlockCcControl(node, parent, propertyName, blockCCControlData, reader);
                            }
                            break;
                        }
                    case CCBPropertyType.CCBFile:
                        {
                            CCNode ccbFileNode = ParsePropTypeCcbFile(node, parent, reader);
                            if (setProp)
                            {
                                OnHandlePropTypeCCBFile(node, parent, propertyName, ccbFileNode, reader);
                            }
                            break;
                        }
                    default:
                        //ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(type);
                        break;
                }
            }
        }
Example #6
0
        public virtual void ParseProperties(CCNode node, CCNode parent, CCBReader reader)
        {
            int numRegularProps = reader.ReadInt(false);
            int numExturaProps  = reader.ReadInt(false);
            int propertyCount   = numRegularProps + numExturaProps;

            for (int i = 0; i < propertyCount; i++)
            {
                bool   isExtraProp  = (i >= numRegularProps);
                int    type         = reader.ReadInt(false);
                string propertyName = reader.ReadCachedString();

                // Check if the property can be set for this platform
                bool setProp = false;

                var platform = (CCBPlatform)reader.ReadByte();
                if (platform == CCBPlatform.All)
                {
                    setProp = true;
                }
#if __CC_PLATFORM_IOS
                if (platform == kCCBPlatform.kCCBPlatformIOS)
                {
                    setProp = true;
                }
#elif __CC_PLATFORM_MAC
                if (platform == kCCBPlatform.kCCBPlatformMac)
                {
                    setProp = true;
                }
#endif

                // Forward properties for sub ccb files
                if (node is CCBFile)
                {
                    var ccbNode = (CCBFile)node;
                    if (ccbNode.FileNode != null && isExtraProp)
                    {
                        node = ccbNode.FileNode;

                        // Skip properties that doesn't have a value to override
                        var extraPropsNames = (List <string>)node.UserObject;
                        setProp &= extraPropsNames.Contains(propertyName);
                    }
                }
                else if (isExtraProp && node == reader.AnimationManager.RootNode)
                {
                    var extraPropsNames = (List <string>)node.UserObject;
                    if (extraPropsNames == null)
                    {
                        extraPropsNames = new List <string>();
                        node.UserObject = extraPropsNames;
                    }

                    extraPropsNames.Add(propertyName);
                }

                switch ((CCBPropType)type)
                {
                case CCBPropType.Position:
                {
                    CCPoint position = ParsePropTypePosition(node, parent, reader, propertyName);
                    if (setProp)
                    {
                        OnHandlePropTypePosition(node, parent, propertyName, position, reader);
                    }
                    break;
                }

                case CCBPropType.Point:
                {
                    CCPoint point = ParsePropTypePoint(node, parent, reader);
                    if (setProp)
                    {
                        OnHandlePropTypePoint(node, parent, propertyName, point, reader);
                    }
                    break;
                }

                case CCBPropType.PointLock:
                {
                    CCPoint pointLock = ParsePropTypePointLock(node, parent, reader);
                    if (setProp)
                    {
                        OnHandlePropTypePointLock(node, parent, propertyName, pointLock, reader);
                    }
                    break;
                }

                case CCBPropType.Size:
                {
                    CCSize size = ParsePropTypeSize(node, parent, reader);
                    if (setProp)
                    {
                        OnHandlePropTypeSize(node, parent, propertyName, size, reader);
                    }
                    break;
                }

                case CCBPropType.ScaleLock:
                {
                    float[] scaleLock = ParsePropTypeScaleLock(node, parent, reader, propertyName);
                    if (setProp)
                    {
                        OnHandlePropTypeScaleLock(node, parent, propertyName, scaleLock, reader);
                    }
                    break;
                }

                case CCBPropType.Float:
                {
                    float f = ParsePropTypeFloat(node, parent, reader);
                    if (setProp)
                    {
                        OnHandlePropTypeFloat(node, parent, propertyName, f, reader);
                    }
                    break;
                }

                case CCBPropType.Degrees:
                {
                    float degrees = ParsePropTypeDegrees(node, parent, reader, propertyName);
                    if (setProp)
                    {
                        OnHandlePropTypeDegrees(node, parent, propertyName, degrees, reader);
                    }
                    break;
                }

                case CCBPropType.FloatScale:
                {
                    float floatScale = ParsePropTypeFloatScale(node, parent, reader);
                    if (setProp)
                    {
                        OnHandlePropTypeFloatScale(node, parent, propertyName, floatScale, reader);
                    }
                    break;
                }

                case CCBPropType.Integer:
                {
                    int integer = ParsePropTypeInteger(node, parent, reader);
                    if (setProp)
                    {
                        OnHandlePropTypeInteger(node, parent, propertyName, integer, reader);
                    }
                    break;
                }

                case CCBPropType.IntegerLabeled:
                {
                    int integerLabeled = ParsePropTypeIntegerLabeled(node, parent, reader);
                    if (setProp)
                    {
                        OnHandlePropTypeIntegerLabeled(node, parent, propertyName, integerLabeled, reader);
                    }
                    break;
                }

                case CCBPropType.FloatVar:
                {
                    float[] floatVar = ParsePropTypeFloatVar(node, parent, reader);
                    if (setProp)
                    {
                        OnHandlePropTypeFloatVar(node, parent, propertyName, floatVar, reader);
                    }
                    break;
                }

                case CCBPropType.Check:
                {
                    bool check = ParsePropTypeCheck(node, parent, reader, propertyName);
                    if (setProp)
                    {
                        OnHandlePropTypeCheck(node, parent, propertyName, check, reader);
                    }
                    break;
                }

                case CCBPropType.SpriteFrame:
                {
                    CCSpriteFrame ccSpriteFrame = ParsePropTypeSpriteFrame(node, parent, reader, propertyName);
                    if (setProp)
                    {
                        OnHandlePropTypeSpriteFrame(node, parent, propertyName, ccSpriteFrame, reader);
                    }
                    break;
                }

                case CCBPropType.Animation:
                {
                    CCAnimation ccAnimation = ParsePropTypeAnimation(node, parent, reader);
                    if (setProp)
                    {
                        OnHandlePropTypeAnimation(node, parent, propertyName, ccAnimation, reader);
                    }
                    break;
                }

                case CCBPropType.Texture:
                {
                    CCTexture2D ccTexture2D = ParsePropTypeTexture(node, parent, reader);
                    if (setProp)
                    {
                        OnHandlePropTypeTexture(node, parent, propertyName, ccTexture2D, reader);
                    }
                    break;
                }

                case CCBPropType.Byte:
                {
                    byte b = ParsePropTypeByte(node, parent, reader, propertyName);
                    if (setProp)
                    {
                        OnHandlePropTypeByte(node, parent, propertyName, b, reader);
                    }
                    break;
                }

                case CCBPropType.Color3:
                {
                    CCColor3B color3B = ParsePropTypeColor3(node, parent, reader, propertyName);
                    if (setProp)
                    {
                        OnHandlePropTypeColor3(node, parent, propertyName, color3B, reader);
                    }
                    break;
                }

                case CCBPropType.Color4FVar:
                {
                    CCColor4F[] color4FVar = ParsePropTypeColor4FVar(node, parent, reader);
                    if (setProp)
                    {
                        OnHandlePropTypeColor4FVar(node, parent, propertyName, color4FVar, reader);
                    }
                    break;
                }

                case CCBPropType.Flip:
                {
                    bool[] flip = ParsePropTypeFlip(node, parent, reader);
                    if (setProp)
                    {
                        OnHandlePropTypeFlip(node, parent, propertyName, flip, reader);
                    }
                    break;
                }

                case CCBPropType.Blendmode:
                {
                    CCBlendFunc blendFunc = ParsePropTypeBlendFunc(node, parent, reader);
                    if (setProp)
                    {
                        OnHandlePropTypeBlendFunc(node, parent, propertyName, blendFunc, reader);
                    }
                    break;
                }

                case CCBPropType.FntFile:
                {
                    string fntFile = ParsePropTypeFntFile(node, parent, reader);
                    if (setProp)
                    {
                        OnHandlePropTypeFntFile(node, parent, propertyName, fntFile, reader);
                    }
                    break;
                }

                case CCBPropType.FontTTF:
                {
                    string fontTTF = ParsePropTypeFontTTF(node, parent, reader);
                    if (setProp)
                    {
                        OnHandlePropTypeFontTTF(node, parent, propertyName, fontTTF, reader);
                    }
                    break;
                }

                case CCBPropType.String:
                {
                    string s = ParsePropTypeString(node, parent, reader);
                    if (setProp)
                    {
                        OnHandlePropTypeString(node, parent, propertyName, s, reader);
                    }
                    break;
                }

                case CCBPropType.Text:
                {
                    string text = ParsePropTypeText(node, parent, reader);
                    if (setProp)
                    {
                        OnHandlePropTypeText(node, parent, propertyName, text, reader);
                    }
                    break;
                }

                case CCBPropType.Block:
                {
                    BlockData blockData = ParsePropTypeBlock(node, parent, reader);
                    if (setProp)
                    {
                        OnHandlePropTypeBlock(node, parent, propertyName, blockData, reader);
                    }
                    break;
                }

                case CCBPropType.BlockCCControl:
                {
                    BlockCCControlData blockCCControlData = ParsePropTypeBlockCcControl(node, parent, reader);
                    if (setProp && blockCCControlData != null)
                    {
                        OnHandlePropTypeBlockCcControl(node, parent, propertyName, blockCCControlData, reader);
                    }
                    break;
                }

                case CCBPropType.CCBFile:
                {
                    CCNode ccbFileNode = ParsePropTypeCcbFile(node, parent, reader);
                    if (setProp)
                    {
                        OnHandlePropTypeCCBFile(node, parent, propertyName, ccbFileNode, reader);
                    }
                    break;
                }

                default:
                    //ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(type);
                    break;
                }
            }
        }