本文整理汇总了C#中BaseObject.GetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# BaseObject.GetAttribute方法的具体用法?C# BaseObject.GetAttribute怎么用?C# BaseObject.GetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseObject
的用法示例。
在下文中一共展示了BaseObject.GetAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessAndEncode
string ProcessAndEncode(string operand, BaseObject entity){
// return a string that represents the final value of this thing
// try valid int, float and bool first, mainly to catch 30.0 as a float, not an object.attribute
// a valid float, int, or boolean constant? - return "f1.5" "i1" "btrue"
float fVal;
int iVal;
bool bVal;
if (int.TryParse(operand,out iVal)){
return iVal.ToString();
}
if (float.TryParse(operand,out fVal)){
return fVal.ToString();
}
if (bool.TryParse(operand,out bVal)){
return bVal.ToString();
}
// see if it's a special case:
// are we referencing another entity ? "." - find it and process for that entity
if (operand.Contains(".")){
string[] parts = operand.Split('.');
if (cachedGO == null)
cachedGO = GameObject.Find(parts[0]);
BaseObject bob = null;
if (cachedGO != null){
if ( (bob=cachedGO.GetComponent<BaseObject>()) != null){
return ProcessAndEncode (parts[1],bob);
}
}
Debug.Log ("Error Evaluating "+parts[1]+" for "+parts[0]+": not found");
return "error";
}
// @nodename - return slocked or sunlocked
if (operand[0] == '@'){
if (SceneNode.IsLocked(operand.Substring(1)))
return "slocked";
else
return "sunlocked"; // TODO find the node and get this...
}
// %decisionVariable - get from entity
if (operand[0] == '%'){
return entity.GetAttribute(operand);
}
// "stringconstant" - return "sstringconstant"
if (operand[0] == '\"'){
return operand.Substring (1,operand.Length-2);
}
// otherwise, assume it's an attribute and get the entity's attribute value
return entity.GetAttribute(operand);
}