当前位置: 首页>>代码示例>>C#>>正文


C# BaseObject.GetAttribute方法代码示例

本文整理汇总了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);
	}
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:51,代码来源:BinaryExpressionNode.cs


注:本文中的BaseObject.GetAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。