Exemple #1
0
        protected virtual CCPoint ParsePropTypePointLock(CCNode node, CCNode parent, CCBReader reader)
        {
            float x = reader.ReadFloat();
            float y = reader.ReadFloat();

            return(new CCPoint(x, y));
        }
Exemple #2
0
        protected virtual float[] ParsePropTypeScaleLock(CCNode node, CCNode parent, CCBReader reader, string propertyName)
        {
            float x = reader.ReadFloat();
            float y = reader.ReadFloat();

            var type = (CCBScaleType)reader.ReadInt(false);

            CCBHelper.SetRelativeScale(node, x, y, type, propertyName);

            if (reader.AnimatedProperties.Contains(propertyName))
            {
                var baseValue = new List <CCBValue>
                {
                    new CCBValue(x),
                    new CCBValue(y),
                    new CCBValue((int)type)
                };
                reader.AnimationManager.SetBaseValue(baseValue, node, propertyName);
            }

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

            var scaleLock = new float[2];

            scaleLock[0] = x;
            scaleLock[1] = y;

            return(scaleLock);
        }
Exemple #3
0
        protected virtual CCPoint ParsePropTypePosition(CCNode node, CCNode parent, CCBReader reader, string propertyName)
        {
            float x = reader.ReadFloat();
            float y = reader.ReadFloat();

            var type = (CCBPositionType)reader.ReadInt(false);

            CCSize containerSize = reader.AnimationManager.GetContainerSize(parent);

            CCPoint pt = CCBHelper.GetAbsolutePosition(new CCPoint(x, y), type, containerSize, propertyName);

            node.Position = CCBHelper.GetAbsolutePosition(pt, type, containerSize, propertyName);

            if (reader.AnimatedProperties.Contains(propertyName))
            {
                var baseValue = new List <CCBValue>
                {
                    new CCBValue(x),
                    new CCBValue(y),
                    new CCBValue((int)type)
                };
                reader.AnimationManager.SetBaseValue(baseValue, node, propertyName);
            }

            return(pt);
        }
Exemple #4
0
        protected virtual CCSize ParsePropTypeSize(CCNode node, CCNode parent, CCBReader reader)
        {
            float width  = reader.ReadFloat();
            float height = reader.ReadFloat();

            int type = reader.ReadInt(false);

            CCSize containerSize = reader.AnimationManager.GetContainerSize(parent);

            switch ((CCBSizeType)type)
            {
            case CCBSizeType.Absolute:
            {
                /* Nothing. */
                break;
            }

            case CCBSizeType.RelativeContainer:
            {
                width  = containerSize.Width - width;
                height = containerSize.Height - height;
                break;
            }

            case CCBSizeType.Percent:
            {
                width  = (int)(containerSize.Width * width / 100.0f);
                height = (int)(containerSize.Height * height / 100.0f);
                break;
            }

            case CCBSizeType.HorizontalPercent:
            {
                width = (int)(containerSize.Width * width / 100.0f);
                break;
            }

            case CCBSizeType.VerticalPercent:
            {
                height = (int)(containerSize.Height * height / 100.0f);
                break;
            }

            case CCBSizeType.MultiplyResolution:
            {
                float resolutionScale = CCBReader.ResolutionScale;

                width  *= resolutionScale;
                height *= resolutionScale;
                break;
            }

            default:
                break;
            }

            return(new CCSize(width, height));
        }
Exemple #5
0
        protected virtual float[] ParsePropTypeFloatVar(CCNode node, CCNode parent, CCBReader reader)
        {
            float f    = reader.ReadFloat();
            float fVar = reader.ReadFloat();

            var arr = new float[2];

            arr[0] = f;
            arr[1] = fVar;

            return(arr);
        }
Exemple #6
0
        protected virtual CCColor4F[] ParsePropTypeColor4FVar(CCNode node, CCNode parent, CCBReader reader)
        {
            float red      = reader.ReadFloat();
            float green    = reader.ReadFloat();
            float blue     = reader.ReadFloat();
            float alpha    = reader.ReadFloat();
            float redVar   = reader.ReadFloat();
            float greenVar = reader.ReadFloat();
            float blueVar  = reader.ReadFloat();
            float alphaVar = reader.ReadFloat();

            var colors = new CCColor4F[2];

            colors[0].R = red;
            colors[0].G = green;
            colors[0].B = blue;
            colors[0].A = alpha;

            colors[1].R = redVar;
            colors[1].G = greenVar;
            colors[1].B = blueVar;
            colors[1].A = alphaVar;

            return(colors);
        }
Exemple #7
0
        protected virtual float ParsePropTypeDegrees(CCNode node, CCNode parent, CCBReader reader, string propertyName)
        {
            float ret = reader.ReadFloat();

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

            return(ret);
        }
Exemple #8
0
        protected virtual float ParsePropTypeFloatScale(CCNode node, CCNode parent, CCBReader reader)
        {
            float f = reader.ReadFloat();

            int type = reader.ReadInt(false);

            if ((CCBScaleType)type == CCBScaleType.MultiplyResolution)
            {
                f *= CCBReader.ResolutionScale;
            }

            return(f);
        }
Exemple #9
0
        protected virtual float ParsePropTypeFloatScale(CCNode node, CCNode parent, CCBReader reader)
        {
            float f = reader.ReadFloat();

            int type = reader.ReadInt(false);

            if ((CCBScaleType) type == CCBScaleType.MultiplyResolution)
            {
                f *= CCBReader.ResolutionScale;
            }

            return f;
        }
Exemple #10
0
        protected virtual float ParsePropTypeDegrees(CCNode node, CCNode parent, CCBReader reader, string propertyName)
        {
            float ret = reader.ReadFloat();
            if (reader.AnimatedProperties.Contains(propertyName))
            {
                CCBValue value = new CCBValue(ret);
                reader.AnimationManager.SetBaseValue(value, node, propertyName);
            }

            return ret;
        }
Exemple #11
0
 protected virtual float ParsePropTypeFloat(CCNode node, CCNode parent, CCBReader reader)
 {
     return reader.ReadFloat();
 }
Exemple #12
0
        protected virtual float[] ParsePropTypeScaleLock(CCNode node, CCNode parent, CCBReader reader, string propertyName)
        {
            float x = reader.ReadFloat();
            float y = reader.ReadFloat();

            var type = (CCBScaleType) reader.ReadInt(false);

            CCBHelper.SetRelativeScale(node, x, y, type, propertyName);

            if (reader.AnimatedProperties.Contains(propertyName))
            {
                var baseValue = new List<CCBValue>
                    {
                        new CCBValue(x),
                        new CCBValue(y),
                        new CCBValue((int) type)
                    };
                reader.AnimationManager.SetBaseValue(baseValue, node, propertyName);
            }

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

            var scaleLock = new float[2];
            scaleLock[0] = x;
            scaleLock[1] = y;

            return scaleLock;
        }
Exemple #13
0
        protected virtual CCSize ParsePropTypeSize(CCNode node, CCNode parent, CCBReader reader)
        {
            float width = reader.ReadFloat();
            float height = reader.ReadFloat();

            int type = reader.ReadInt(false);

            CCSize containerSize = reader.AnimationManager.GetContainerSize(parent);

            switch ((SizeType) type)
            {
                case SizeType.Absolute:
                    {
                        /* Nothing. */
                        break;
                    }
                case SizeType.RelativeContainer:
                    {
                        width = containerSize.Width - width;
                        height = containerSize.Height - height;
                        break;
                    }
                case SizeType.Percent:
                    {
                        width = (int) (containerSize.Width * width / 100.0f);
                        height = (int) (containerSize.Height * height / 100.0f);
                        break;
                    }
                case SizeType.HorizontalPercent:
                    {
                        width = (int) (containerSize.Width * width / 100.0f);
                        break;
                    }
                case SizeType.VerticalPercent:
                    {
                        height = (int) (containerSize.Height * height / 100.0f);
                        break;
                    }
                case SizeType.MultiplyResolution:
                    {
                        float resolutionScale = CCBReader.ResolutionScale;

                        width *= resolutionScale;
                        height *= resolutionScale;
                        break;
                    }
                default:
                    {
                        CCLog.Log("Unknown CCB type.");
                    }
                    break;
            }

            return new CCSize(width, height);
        }
Exemple #14
0
        protected virtual CCPoint ParsePropTypePointLock(CCNode node, CCNode parent, CCBReader reader)
        {
            float x = reader.ReadFloat();
            float y = reader.ReadFloat();

            return new CCPoint(x, y);
        }
Exemple #15
0
        protected virtual CCPoint ParsePropTypePosition(CCNode node, CCNode parent, CCBReader reader, string propertyName)
        {
            float x = reader.ReadFloat();
            float y = reader.ReadFloat();

            var type = (CCBPositionType) reader.ReadInt(false);

            CCSize containerSize = reader.AnimationManager.GetContainerSize(parent);

            CCPoint pt = CCBHelper.GetAbsolutePosition(new CCPoint(x, y), type, containerSize, propertyName);
            node.Position = CCBHelper.GetAbsolutePosition(pt, type, containerSize, propertyName);

            if (reader.AnimatedProperties.Contains(propertyName))
            {
                var baseValue = new List<CCBValue>
                    {
                        new CCBValue(x),
                        new CCBValue(y),
                        new CCBValue((int) type)
                    };
                reader.AnimationManager.SetBaseValue(baseValue, node, propertyName);
            }

            return pt;
        }
Exemple #16
0
 protected virtual float ParsePropTypeFloat(CCNode node, CCNode parent, CCBReader reader)
 {
     return(reader.ReadFloat());
 }
Exemple #17
0
        protected virtual float[] ParsePropTypeFloatVar(CCNode node, CCNode parent, CCBReader reader)
        {
            float f = reader.ReadFloat();
            float fVar = reader.ReadFloat();

            var arr = new float[2];
            arr[0] = f;
            arr[1] = fVar;

            return arr;
        }
Exemple #18
0
        protected virtual CCColor4F[] ParsePropTypeColor4FVar(CCNode node, CCNode parent, CCBReader reader)
        {
            float red = reader.ReadFloat();
            float green = reader.ReadFloat();
            float blue = reader.ReadFloat();
            float alpha = reader.ReadFloat();
            float redVar = reader.ReadFloat();
            float greenVar = reader.ReadFloat();
            float blueVar = reader.ReadFloat();
            float alphaVar = reader.ReadFloat();

            var colors = new CCColor4F[2];
            colors[0].R = red;
            colors[0].G = green;
            colors[0].B = blue;
            colors[0].A = alpha;

            colors[1].R = redVar;
            colors[1].G = greenVar;
            colors[1].B = blueVar;
            colors[1].A = alphaVar;

            return colors;
        }
Exemple #19
0
        protected virtual float[] ParsePropTypeFloatXY(CCNode pNode, CCNode pParent, CCBReader ccbReader)
        {
            float x = ccbReader.ReadFloat();
            float y = ccbReader.ReadFloat();

            var floatXY = new float[2];
            floatXY[0] = x;
            floatXY[1] = y;

            return floatXY;
        }