本文整理汇总了C#中Cocos2D.CCBReader.ReadCachedString方法的典型用法代码示例。如果您正苦于以下问题:C# CCBReader.ReadCachedString方法的具体用法?C# CCBReader.ReadCachedString怎么用?C# CCBReader.ReadCachedString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cocos2D.CCBReader
的用法示例。
在下文中一共展示了CCBReader.ReadCachedString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParsePropTypeCcbFile
protected virtual CCNode ParsePropTypeCcbFile(CCNode node, CCNode parent, CCBReader pCCBReader)
{
string ccbFileName = pCCBReader.ReadCachedString();
/* Change path extension to .ccbi. */
string ccbFileWithoutPathExtension = CCBReader.DeletePathExtension(ccbFileName);
ccbFileName = ccbFileWithoutPathExtension + ".ccbi";
// Load sub file
string path = CCFileUtils.FullPathFromRelativePath(ccbFileName);
//long size = 0;
byte[] pBytes = CCFileUtils.GetFileBytes(path);
var reader = new CCBReader(pCCBReader);
reader.AnimationManager.RootContainerSize = parent.ContentSize;
reader._bytes = pBytes;
reader._currentByte = 0;
reader._currentBit = 0;
reader._owner = pCCBReader._owner;
reader.AnimationManager._owner = reader._owner;
CCNode ccbFileNode = reader.ReadFileWithCleanUp(false, pCCBReader.AnimationManagers);
if (ccbFileNode != null && reader.AnimationManager.AutoPlaySequenceId != -1)
{
// Auto play animations
reader.AnimationManager.RunAnimationsForSequenceIdTweenDuration(reader.AnimationManager.AutoPlaySequenceId, 0);
}
if (reader.IsJSControlled() && pCCBReader.IsJSControlled() && null != reader._owner)
{
//set variables and callback to owner
//set callback
var ownerCallbackNames = reader.OwnerCallbackNames;
var ownerCallbackNodes = reader.OwnerCallbackNodes;
if (null != ownerCallbackNames && ownerCallbackNames.Count > 0 &&
null != ownerCallbackNodes && ownerCallbackNodes.Count > 0)
{
Debug.Assert(ownerCallbackNames.Count == ownerCallbackNodes.Count);
int nCount = ownerCallbackNames.Count;
for (int i = 0; i < nCount; i++)
{
pCCBReader.AddOwnerCallbackName(ownerCallbackNames[i]);
pCCBReader.AddOwnerCallbackNode(ownerCallbackNodes[i]);
}
}
//set variables
var ownerOutletNames = reader.OwnerOutletNames;
var ownerOutletNodes = reader.OwnerOutletNodes;
if (null != ownerOutletNames && ownerOutletNames.Count > 0 &&
null != ownerOutletNodes && ownerOutletNodes.Count > 0)
{
Debug.Assert(ownerOutletNames.Count == ownerOutletNodes.Count);
int nCount = ownerOutletNames.Count;
for (int i = 0; i < nCount; i++)
{
pCCBReader.AddOwnerOutletName(ownerOutletNames[i]);
pCCBReader.AddOwnerOutletNode(ownerOutletNodes[i]);
}
}
}
return ccbFileNode;
}
示例2: ParsePropTypeBlock
protected virtual BlockData ParsePropTypeBlock(CCNode node, CCNode parent, CCBReader reader)
{
string selectorName = reader.ReadCachedString();
var selectorTarget = (CCBTargetType) reader.ReadInt(false);
if (selectorTarget != CCBTargetType.None)
{
object target = null;
if (!reader.IsJSControlled())
{
if (selectorTarget == CCBTargetType.DocumentRoot)
{
target = reader.AnimationManager.RootNode;
}
else if (selectorTarget == CCBTargetType.Owner)
{
target = reader.Owner;
/* Scripting specific code because selector function is common for all callbacks.
* So if we had 1 target and 1 selector function, the context (callback function name)
* would get lost. Hence the need for a new target for each callback.
*/
if (reader._hasScriptingOwner)
{
var proxy = (ICCBScriptOwnerProtocol) reader.Owner;
if (proxy != null)
{
target = proxy.CreateNew() as object;
}
}
}
if (target != null)
{
if (selectorName.Length > 0)
{
Action<object> selMenuHandler = null;
var targetAsCCBSelectorResolver = target as ICCBSelectorResolver;
if (targetAsCCBSelectorResolver != null)
{
selMenuHandler = targetAsCCBSelectorResolver.OnResolveCCBCCMenuItemSelector(target,
selectorName);
}
if (selMenuHandler == null)
{
ICCBSelectorResolver ccbSelectorResolver = reader.SelectorResolver;
if (ccbSelectorResolver != null)
{
selMenuHandler = ccbSelectorResolver.OnResolveCCBCCMenuItemSelector(target,
selectorName);
}
}
if (selMenuHandler == null)
{
CCLog.Log("Skipping selector '{0}' since no CCBSelectorResolver is present.",
selectorName);
}
else
{
var blockData = new BlockData();
blockData.mSELMenuHandler = selMenuHandler;
blockData.mTarget = target;
return blockData;
}
}
else
{
CCLog.Log("Unexpected empty selector.");
}
}
else
{
CCLog.Log("Unexpected NULL target for selector.");
}
}
else
{
if (selectorTarget == CCBTargetType.DocumentRoot)
{
reader.AddDocumentCallbackNode(node);
reader.AddDocumentCallbackName(selectorName);
}
else
{
reader.AddOwnerCallbackNode(node);
reader.AddOwnerCallbackName(selectorName);
}
}
}
return null;
}
示例3: ParsePropTypeBlockCcControl
protected virtual BlockCCControlData ParsePropTypeBlockCcControl(CCNode node, CCNode parent, CCBReader reader)
{
string selectorName = reader.ReadCachedString();
var selectorTarget = (CCBTargetType) reader.ReadInt(false);
var controlEvents = (CCControlEvent) reader.ReadInt(false);
if (selectorTarget != CCBTargetType.None)
{
if (!reader.IsJSControlled())
{
object target = null;
if (selectorTarget == CCBTargetType.DocumentRoot)
{
target = reader.AnimationManager.RootNode;
}
else if (selectorTarget == CCBTargetType.Owner)
{
target = reader.Owner;
}
if (target != null)
{
if (selectorName.Length > 0)
{
Action<object, CCControlEvent> selCCControlHandler = null;
var targetAsCCBSelectorResolver = target as ICCBSelectorResolver;
if (targetAsCCBSelectorResolver != null)
{
selCCControlHandler = targetAsCCBSelectorResolver.OnResolveCCBCCControlSelector(target,
selectorName);
}
if (selCCControlHandler == null)
{
ICCBSelectorResolver ccbSelectorResolver = reader.SelectorResolver;
if (ccbSelectorResolver != null)
{
selCCControlHandler = ccbSelectorResolver.OnResolveCCBCCControlSelector(target,
selectorName);
}
}
if (selCCControlHandler == null)
{
CCLog.Log("Skipping selector '{0}' since no CCBSelectorResolver is present.",
selectorName);
}
else
{
var blockCCControlData = new BlockCCControlData();
blockCCControlData.mSELCCControlHandler = selCCControlHandler;
blockCCControlData.mTarget = target;
blockCCControlData.mControlEvents = controlEvents;
return blockCCControlData;
}
}
else
{
CCLog.Log("Unexpected empty selector.");
}
}
else
{
CCLog.Log("Unexpected NULL target for selector.");
}
}
else
{
if (selectorTarget == CCBTargetType.DocumentRoot)
{
reader.AddDocumentCallbackNode(node);
reader.AddDocumentCallbackName(selectorName);
}
else
{
reader.AddOwnerCallbackNode(node);
reader.AddOwnerCallbackName(selectorName);
}
}
}
return null;
}
示例4: ParsePropTypeText
protected virtual string ParsePropTypeText(CCNode node, CCNode parent, CCBReader reader)
{
return reader.ReadCachedString();
}
示例5: ParsePropTypeFontTTF
protected virtual string ParsePropTypeFontTTF(CCNode node, CCNode parent, CCBReader reader)
{
string fontTTF = reader.ReadCachedString();
// CCString * ttfEnding = ".ttf";
// TODO Fix me if it is wrong
/* If the fontTTF comes with the ".ttf" extension, prepend the absolute path.
* System fonts come without the ".ttf" extension and do not need the path prepended. */
/*
if(CCBReader.endsWith(CCBReader.toLowerCase(fontTTF), ttfEnding)){
fontTTF = CCBReader.concat(reader.getCCBRootPath(), fontTTF);
}
*/
return fontTTF;
}
示例6: ParsePropTypeTexture
protected virtual CCTexture2D ParsePropTypeTexture(CCNode node, CCNode parent, CCBReader reader)
{
string spriteFile = reader.ReadCachedString();
if (!String.IsNullOrEmpty(spriteFile))
{
return CCTextureCache.SharedTextureCache.AddImage(CCFileUtils.RemoveExtension(spriteFile));
}
return null;
}
示例7: ParsePropTypeAnimation
protected virtual CCAnimation ParsePropTypeAnimation(CCNode node, CCNode parent, CCBReader reader)
{
string animationFile = reader.ReadCachedString();
string animation = reader.ReadCachedString();
CCAnimation ccAnimation = null;
// Support for stripping relative file paths, since ios doesn't currently
// know what to do with them, since its pulling from bundle.
// Eventually this should be handled by a client side asset manager
// interface which figured out what resources to load.
// TODO Does this problem exist in C++?
animation = CCBReader.LastPathComponent(animation);
animationFile = CCBReader.LastPathComponent(animationFile);
if (!String.IsNullOrEmpty(animation))
{
CCAnimationCache animationCache = CCAnimationCache.SharedAnimationCache;
animationCache.AddAnimationsWithFile(animationFile);
ccAnimation = animationCache.AnimationByName(animation);
}
return ccAnimation;
}
示例8: ParsePropTypeSpriteFrame
protected virtual CCSpriteFrame ParsePropTypeSpriteFrame(CCNode node, CCNode parent, CCBReader reader, string propertyName)
{
string spriteSheet = reader.ReadCachedString();
string spriteFile = reader.ReadCachedString();
CCSpriteFrame spriteFrame = null;
if (spriteFile.Length != 0)
{
if (spriteSheet.Length == 0)
{
spriteFile = reader.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
{
CCSpriteFrameCache frameCache = CCSpriteFrameCache.SharedSpriteFrameCache;
spriteSheet = reader.CCBRootPath + spriteSheet;
// Load the sprite sheet only if it is not loaded
if (!reader.LoadedSpriteSheet.Contains(spriteSheet))
{
frameCache.AddSpriteFramesWithFile(spriteSheet);
reader.LoadedSpriteSheet.Add(spriteSheet);
}
spriteFrame = frameCache.SpriteFrameByName(spriteFile);
}
if (reader.AnimatedProperties.Contains(propertyName))
{
reader.AnimationManager.SetBaseValue(spriteFrame, node, propertyName);
}
}
return spriteFrame;
}
示例9: ParseProperties
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)
{
//.........这里部分代码省略.........
示例10: ParsePropTypeCcbFile
protected virtual CCNode ParsePropTypeCcbFile(CCNode node, CCNode parent, CCBReader reader)
{
string ccbFileName = reader.ReadCachedString();
/* Change path extension to .ccbi. */
string ccbFileWithoutPathExtension = CCBReader.DeletePathExtension(ccbFileName);
ccbFileName = ccbFileWithoutPathExtension + ".ccbi";
// Load sub file
string path = CCFileUtils.FullPathFromRelativePath(ccbFileName);
var ccbReader = new CCBReader(reader);
byte[] pBytes = CCFileUtils.GetFileBytes(path);
ccbReader.InitWithData(pBytes, reader.Owner);
ccbReader.AnimationManager.RootContainerSize = parent.ContentSize;
CCNode ccbFileNode = ccbReader.ReadFileWithCleanUp(false);
if (ccbFileNode != null && ccbReader.AnimationManager.AutoPlaySequenceId != -1)
{
// Auto play animations
ccbReader.AnimationManager.RunAnimations(ccbReader.AnimationManager.AutoPlaySequenceId, 0);
}
return ccbFileNode;
}