本文整理汇总了C#中PlistDictionary.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# PlistDictionary.ContainsKey方法的具体用法?C# PlistDictionary.ContainsKey怎么用?C# PlistDictionary.ContainsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlistDictionary
的用法示例。
在下文中一共展示了PlistDictionary.ContainsKey方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPlistType
private PlistType GetPlistType(PlistDictionary dict)
{
var isSpriteKit = dict.ContainsKey ("format") ? dict ["format"].AsString == "APPL" : false;
return isSpriteKit ? PlistType.SpriteKit : PlistType.Cocos2D;
}
示例2: AddSpriteFramesWithDictionary
public void AddSpriteFramesWithDictionary(PlistDictionary pobDictionary, CCTexture2D pobTexture, string framePrefix)
{
/*
Supported Zwoptex Formats:
ZWTCoordinatesFormatOptionXMLLegacy = 0, // Flash Version
ZWTCoordinatesFormatOptionXML1_0 = 1, // Desktop Version 0.0 - 0.4b
ZWTCoordinatesFormatOptionXML1_1 = 2, // Desktop Version 1.0.0 - 1.0.1
ZWTCoordinatesFormatOptionXML1_2 = 3, // Desktop Version 1.0.2+
*/
PlistDictionary metadataDict = null;
if (pobDictionary.ContainsKey("metadata"))
{
metadataDict = pobDictionary["metadata"].AsDictionary;
}
PlistDictionary framesDict = null;
if (pobDictionary.ContainsKey("frames"))
{
framesDict = pobDictionary["frames"].AsDictionary;
}
int format = 0;
// get the format
if (metadataDict != null)
{
format = metadataDict["format"].AsInt;
}
// check the format
if (format < 0 || format > 3)
{
throw (new NotSupportedException("PList format " + format + " is not supported."));
}
foreach (var pair in framesDict)
{
PlistDictionary frameDict = pair.Value.AsDictionary;
CCSpriteFrame spriteFrame = null;
if (format == 0)
{
float x=0f, y=0f, w=0f, h=0f;
x = frameDict["x"].AsFloat;
y = frameDict["y"].AsFloat;
w = frameDict["width"].AsFloat;
h = frameDict["height"].AsFloat;
float ox = 0f, oy = 0f;
ox = frameDict["offsetX"].AsFloat;
oy = frameDict["offsetY"].AsFloat;
int ow = 0, oh = 0;
ow = frameDict["originalWidth"].AsInt;
oh = frameDict["originalHeight"].AsInt;
// check ow/oh
if (ow == 0 || oh == 0)
{
CCLog.Log(
"cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenerate the .plist or check the 'format' metatag");
}
// abs ow/oh
ow = Math.Abs(ow);
oh = Math.Abs(oh);
// create frame
spriteFrame = new CCSpriteFrame(pobTexture,
new CCRect(x, y, w, h),
false,
new CCPoint(ox, oy),
new CCSize(ow, oh)
);
}
else if (format == 1 || format == 2)
{
CCRect frame = CCRect.Parse(frameDict["frame"].AsString);
bool rotated = false;
// rotation
if (format == 2)
{
if (frameDict.ContainsKey("rotated"))
{
rotated = frameDict["rotated"].AsBool;
}
}
CCPoint offset = CCPoint.Parse(frameDict["offset"].AsString);
CCSize sourceSize = CCSize.Parse (frameDict["sourceSize"].AsString);
// create frame
spriteFrame = new CCSpriteFrame(pobTexture,
frame,
rotated,
offset,
sourceSize
);
}
else if (format == 3)
{
// get values
//.........这里部分代码省略.........
示例3: SetIfNotPresent
static void SetIfNotPresent (PlistDictionary dict, string key, PlistObjectBase value)
{
if (!dict.ContainsKey (key))
dict[key] = value;
}
示例4: LoadCocos2DDictionary
private void LoadCocos2DDictionary(PlistDictionary dict, CCTexture2D texture)
{
PlistDictionary metadataDict = null;
if (dict.ContainsKey("metadata"))
{
metadataDict = dict["metadata"].AsDictionary;
}
PlistDictionary framesDict = null;
if (dict.ContainsKey("frames"))
{
framesDict = dict["frames"].AsDictionary;
}
// get the format
int format = 0;
if (metadataDict != null)
{
format = metadataDict["format"].AsInt;
}
// check the format
if (format < 0 || format > 3)
{
throw (new NotSupportedException("PList format " + format + " is not supported."));
}
foreach (var pair in framesDict)
{
PlistDictionary frameDict = pair.Value.AsDictionary;
CCSpriteFrame spriteFrame = null;
if (format == 0)
{
float x = 0f, y = 0f, w = 0f, h = 0f;
x = frameDict["x"].AsFloat;
y = frameDict["y"].AsFloat;
w = frameDict["width"].AsFloat;
h = frameDict["height"].AsFloat;
float ox = 0f, oy = 0f;
ox = frameDict["offsetX"].AsFloat;
oy = frameDict["offsetY"].AsFloat;
int ow = 0, oh = 0;
ow = frameDict["originalWidth"].AsInt;
oh = frameDict["originalHeight"].AsInt;
// check ow/oh
if (ow == 0 || oh == 0)
{
CCLog.Log(
"cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenerate the .plist or check the 'format' metatag");
}
// abs ow/oh
ow = Math.Abs(ow);
oh = Math.Abs(oh);
// create frame
spriteFrame = new CCSpriteFrame(
texture,
new CCRect(x, y, w, h),
false,
new CCPoint(ox, oy),
new CCSize(ow, oh)
);
}
else if (format == 1 || format == 2)
{
var frame = CCRect.Parse(frameDict["frame"].AsString);
bool rotated = false;
// rotation
if (format == 2)
{
if (frameDict.ContainsKey("rotated"))
{
rotated = frameDict["rotated"].AsBool;
}
}
var offset = CCPoint.Parse(frameDict["offset"].AsString);
var sourceSize = CCSize.Parse(frameDict["sourceSize"].AsString);
// create frame
spriteFrame = new CCSpriteFrame(texture, frame, rotated, offset, sourceSize);
}
else if (format == 3)
{
var spriteSize = CCSize.Parse(frameDict["spriteSize"].AsString);
var spriteOffset = CCPoint.Parse(frameDict["spriteOffset"].AsString);
var spriteSourceSize = CCSize.Parse(frameDict["spriteSourceSize"].AsString);
var textureRect = CCRect.Parse(frameDict["textureRect"].AsString);
bool textureRotated = false;
if (frameDict.ContainsKey("textureRotated"))
{
textureRotated = frameDict["textureRotated"].AsBool;
}
//.........这里部分代码省略.........
示例5: LoadAppleDictionary
private void LoadAppleDictionary(PlistDictionary dict, CCTexture2D texture)
{
var version = dict.ContainsKey ("version") ? dict ["version"].AsInt : 0;
if (version != 1)
throw (new NotSupportedException("Binary PList version " + version + " is not supported."));
var images = dict.ContainsKey ("images") ? dict ["images"].AsArray : null;
foreach (var imageEntry in images)
{
// we only support one image for now
var imageDict = imageEntry.AsDictionary;
var path = imageDict ["path"].AsString;
path = Path.Combine(plistFilePath, CCFileUtils.RemoveExtension(path));
if (!CCTextureCache.SharedTextureCache.Contains (path))
texture = CCTextureCache.SharedTextureCache.AddImage (path);
else
texture = CCTextureCache.SharedTextureCache[path];
// size not used right now
//var size = CCSize.Parse(imageDict ["size"].AsString);
var subImages = imageDict ["subimages"].AsArray;
foreach (var subImage in subImages) {
CCSpriteFrame spriteFrame = null;
var subImageDict = subImage.AsDictionary;
var name = subImageDict ["name"].AsString;
var alias = subImageDict ["alias"].AsString;
var isFullyOpaque = true;
if (subImageDict.ContainsKey ("isFullyOpaque"))
isFullyOpaque = subImageDict ["isFullyOpaque"].AsBool;
var textureRect = CCRect.Parse (subImageDict ["textureRect"].AsString);
var spriteOffset = CCPoint.Parse (subImageDict ["spriteOffset"].AsString);
// We are going to override the sprite offset for now to be 0,0
// It seems the offset is calculated off of the original size but if
// we pass this offset it throws our center position calculations off.
spriteOffset = CCPoint.Zero;
var textureRotated = false;
if (subImageDict.ContainsKey ("textureRotated")) {
textureRotated = subImageDict ["textureRotated"].AsBool;
}
var spriteSourceSize = CCSize.Parse (subImageDict ["spriteSourceSize"].AsString);
var frameRect = textureRect;
if (textureRotated)
frameRect = new CCRect (textureRect.Origin.X, textureRect.Origin.Y, textureRect.Size.Height, textureRect.Size.Width);
#if DEBUG
CCLog.Log ("texture {0} rect {1} rotated {2} offset {3}, sourcesize {4}", name, textureRect, textureRotated, spriteOffset, spriteSourceSize);
#endif
// create frame
spriteFrame = new CCSpriteFrame (
texture,
frameRect,
textureRotated,
spriteOffset,
spriteSourceSize
);
_spriteFrames [name] = spriteFrame;
}
}
}
示例6: SetNibProperty
static bool SetNibProperty (PlistDictionary dict, IPhoneProject proj, FilePath mainNibProp, string propName)
{
if (!dict.ContainsKey (propName)) {
if (mainNibProp.IsNullOrEmpty) {
return false;
} else {
string mainNib = mainNibProp.ToRelative (proj.BaseDirectory);
if (mainNib.EndsWith (".nib") || mainNib.EndsWith (".xib"))
mainNib = mainNib.Substring (0, mainNib.Length - 4).Replace ('\\', '/');
dict[propName] = mainNib;
}
}
return true;
}