protected virtual CCPoint ParsePropTypePosition(CCNode node, CCNode parent, CCBReader reader, string propertyName) { float x = reader.ReadFloat(); float y = reader.ReadFloat(); var type = (kCCBPositionType) 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> { CCBValue.Create(x), CCBValue.Create(y), CCBValue.Create((int) type) }; reader.AnimationManager.SetBaseValue(baseValue, node, propertyName); } return pt; }
protected virtual float[] ParsePropTypeScaleLock(CCNode node, CCNode parent, CCBReader reader, string propertyName) { float x = reader.ReadFloat(); float y = reader.ReadFloat(); var type = (kCCBScaleType) reader.ReadInt(false); CCBHelper.SetRelativeScale(node, x, y, type, propertyName); if (reader.AnimatedProperties.Contains(propertyName)) { var baseValue = new List<CCBValue> { CCBValue.Create(x), CCBValue.Create(y), CCBValue.Create((int) type) }; reader.AnimationManager.SetBaseValue(baseValue, node, propertyName); } if (type == kCCBScaleType.kCCBScaleTypeMultiplyResolution) { x *= CCBReader.ResolutionScale; y *= CCBReader.ResolutionScale; } var scaleLock = new float[2]; scaleLock[0] = x; scaleLock[1] = y; return scaleLock; }
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; }
protected virtual CCPoint ParsePropTypePointLock(CCNode node, CCNode parent, CCBReader reader) { float x = reader.ReadFloat(); float y = reader.ReadFloat(); return new CCPoint(x, y); }
protected virtual float ParsePropTypeFloatScale(CCNode node, CCNode parent, CCBReader reader) { float f = reader.ReadFloat(); int type = reader.ReadInt(false); if ((kCCBScaleType) type == kCCBScaleType.kCCBScaleTypeMultiplyResolution) { f *= CCBReader.ResolutionScale; } return f; }
protected virtual float ParsePropTypeFloat(CCNode node, CCNode parent, CCBReader reader) { return reader.ReadFloat(); }
protected virtual float ParsePropTypeDegrees(CCNode node, CCNode parent, CCBReader reader, string propertyName) { float ret = reader.ReadFloat(); if (reader.AnimatedProperties.Contains(propertyName)) { CCBValue value = CCBValue.Create(ret); reader.AnimationManager.SetBaseValue(value, node, propertyName); } return ret; }
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; }
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 ((kCCBSizeType) type) { case kCCBSizeType.kCCBSizeTypeAbsolute: { /* Nothing. */ break; } case kCCBSizeType.kCCBSizeTypeRelativeContainer: { width = containerSize.Width - width; height = containerSize.Height - height; break; } case kCCBSizeType.kCCBSizeTypePercent: { width = (int) (containerSize.Width * width / 100.0f); height = (int) (containerSize.Height * height / 100.0f); break; } case kCCBSizeType.kCCBSizeTypeHorizontalPercent: { width = (int) (containerSize.Width * width / 100.0f); break; } case kCCBSizeType.kCCBSizeTypeVerticalPercent: { height = (int) (containerSize.Height * height / 100.0f); break; } case kCCBSizeType.kCCBSizeTypeMultiplyResolution: { float resolutionScale = CCBReader.ResolutionScale; width *= resolutionScale; height *= resolutionScale; break; } default: break; } return new CCSize(width, height); }