public static bool ParseAnchor( string _AnchorStr , ref PosAnchor _ResultAnchor ) { char [] seperator = {','} ; string[] strVec = _AnchorStr.Split( seperator ) ; if( strVec.Length > 2 ) { float x = 0 ; float y = 0 ; float z = 0 ; ParsePosition( _AnchorStr , ref x , ref y , ref z ) ; _ResultAnchor.Setup( new Vector3( x , y , z ) ) ; return true ; } else { _ResultAnchor.Setup( _AnchorStr ) ; return true ; } }
// 分析位置 包含座標及位置物件 public static bool ParsePosition( XmlNode _PositionNode , ref PosAnchor _PosAnchor ) { if( "Position3D" == _PositionNode.Name ) { if( null != _PositionNode.Attributes[ "objectName" ] ) { string objectName = _PositionNode.Attributes[ "objectName" ].Value ; _PosAnchor.Setup( objectName ) ; } else { // 絕對座標 string strx = _PositionNode.Attributes[ "x" ].Value ; string stry = _PositionNode.Attributes[ "y" ].Value ; string strz = _PositionNode.Attributes[ "z" ].Value ; float x , y , z ; float.TryParse( strx , out x ) ; float.TryParse( stry , out y ) ; float.TryParse( strz , out z ) ; Vector3 setPosition = new Vector3( x , y , z ) ; // the y position of Unit is sure set to 1.0f setPosition.y = 1.0f ; _PosAnchor.Setup( setPosition ) ; } return true ; } return false ; }