예제 #1
0
 public static CCBValue Create(byte[] pointer)
 {
     var ret = new CCBValue();
     ret.pointer = pointer;
     ret.mType = ValueType.kPointerValue;
     return ret;
 }
예제 #2
0
 public static CCBValue Create(byte bValue)
 {
     var ret = new CCBValue();
     ret.nValue = bValue;
     ret.mType = ValueType.kUnsignedCharValue;
     return ret;
 }
예제 #3
0
 public static CCBValue Create(float fValue)
 {
     var ret = new CCBValue();
     ret.fValue = fValue;
     ret.mType = ValueType.kFloatValue;
     return ret;
 }
예제 #4
0
 public static CCBValue Create(bool bValue)
 {
     var ret = new CCBValue();
     ret.nValue = bValue ? 1 : 0;
     ret.mType = ValueType.kBoolValue;
     return ret;
 }
예제 #5
0
 public static CCBValue Create(int nValue)
 {
     var ret = new CCBValue();
     ret.nValue = nValue;
     ret.mType = ValueType.kIntValue;
     return ret;
 }
예제 #6
0
        private CCBKeyframe ReadKeyframe(kCCBPropType type)
        {
            var keyframe = new CCBKeyframe();

            keyframe.Time = ReadFloat();

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

            if (easingType == kCCBKeyframeEasing.kCCBKeyframeEasingCubicIn
                || easingType == kCCBKeyframeEasing.kCCBKeyframeEasingCubicOut
                || easingType == kCCBKeyframeEasing.kCCBKeyframeEasingCubicInOut
                || easingType == kCCBKeyframeEasing.kCCBKeyframeEasingElasticIn
                || easingType == kCCBKeyframeEasing.kCCBKeyframeEasingElasticOut
                || easingType == kCCBKeyframeEasing.kCCBKeyframeEasingElasticInOut)
            {
                easingOpt = ReadFloat();
            }
            keyframe.EasingType = easingType;
            keyframe.EasingOpt = easingOpt;

            if (type == kCCBPropType.kCCBPropTypeCheck)
            {
                value = new CCBValue(ReadBool());
            }
            else if (type == kCCBPropType.kCCBPropTypeByte)
            {
                value = new CCBValue(ReadByte());
            }
            else if (type == kCCBPropType.kCCBPropTypeColor3)
            {
                byte r = ReadByte();
                byte g = ReadByte();
                byte b = ReadByte();

                var c = new CCColor3B(r, g, b);
                value = ccColor3BWapper.Create(c);
            }
            else if (type == kCCBPropType.kCCBPropTypeDegrees)
            {
                value = new CCBValue(ReadFloat());
            }
            else if (type == kCCBPropType.kCCBPropTypeScaleLock || type == kCCBPropType.kCCBPropTypePosition)
            {
                float a = ReadFloat();
                float b = ReadFloat();

                value = new List<CCBValue>
                    {
                        new CCBValue(a),
                        new CCBValue(b)
                    };
            }
            else if (type == kCCBPropType.kCCBPropTypeSpriteFrame)
            {
                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 = CCSpriteFrame.Create(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;
        }
예제 #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;
        }
예제 #8
0
        protected virtual bool ParsePropTypeCheck(CCNode node, CCNode parent, CCBReader reader, string propertyName)
        {
            bool ret = reader.ReadBool();

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

            return ret;
        }