// 分析靜態物件
    public static bool ParseStaticObject( XmlNode _UnitNode , 
										ref string _UnitName ,
										ref string _PrefabName ,
										ref Vector3 _InitPosition ,
										ref Quaternion _InitQuaternion )
    {
        if( "StaticObject" == _UnitNode.Name )
        {
            if( null != _UnitNode.Attributes[ "name" ] )
                _UnitName = _UnitNode.Attributes[ "name" ].Value ;
            if( null != _UnitNode.Attributes[ "PrefabName" ] )
                _PrefabName = _UnitNode.Attributes[ "PrefabName" ].Value ;

            if( true == _UnitNode.HasChildNodes )
            {
                for( int j = 0 ; j < _UnitNode.ChildNodes.Count ; ++j )
                {
                    PosAnchor posAnchor = new PosAnchor() ;
                    if( true == ParsePosition( _UnitNode.ChildNodes[ j ] ,
                                              	ref posAnchor ) )
                    {
                        _InitPosition = posAnchor.GetPosition() ;
                        // Debug.Log( "_InitPosition=" + _InitPosition ) ;
                    }
                    else if( true == ParseQuaternion( _UnitNode.ChildNodes[ j ] ,
                                                       ref _InitQuaternion ) )
                    {

                    }
                }
            }
            return true ;
        }
        return false ;
    }
    public override bool ParseXML( XmlNode _Node )
    {
        #if DEBUG
        Debug.Log( "MoveObjectPositionConditionEvent::ParseXML()" ) ;
        #endif
        PosAnchor posAnchor = new PosAnchor() ;
        for( int i = 0 ; i < _Node.ChildNodes.Count ; ++i )
        {
            if( true == base.ParseXML( _Node.ChildNodes[ i ] ) )
            {

            }
            else if( true == XMLParseLevelUtility.ParsePosition( _Node.ChildNodes[ i ] ,
                                                                 ref posAnchor ) )
            {
                m_MoveToPosition = posAnchor.GetPosition() ;
            }
        }

        if( null == _Node.Attributes["ObjectName"] )
        {
            return false ;
        }

        m_TargetObject.Setup( _Node.Attributes["ObjectName"].Value , null );

        return true ;
    }
	// 分析靜態物件
	private static void ParseStaticObjectAtt( XmlNode _UnitNode , 
	                                     ref string _UnitName ,
	                                     ref string _PrefabName ,
	                                     ref Vector3 _InitPosition ,
	                                     ref Quaternion _InitQuaternion )	
	{
		if( null != _UnitNode.Attributes[ "Name" ] )
			_UnitName = _UnitNode.Attributes[ "Name" ].Value ;
		if( null != _UnitNode.Attributes[ "PrefabName" ] )
			_PrefabName = _UnitNode.Attributes[ "PrefabName" ].Value ;
		
		if( true == _UnitNode.HasChildNodes )
		{
			for( int j = 0 ; j < _UnitNode.ChildNodes.Count ; ++j )
			{
				PosAnchor posAnchor = new PosAnchor() ;
				if( true == ParsePosition( _UnitNode.ChildNodes[ j ] , 
				                          ref posAnchor ) )
				{
					_InitPosition = posAnchor.GetPosition() ;
				}
				else if( true == ParseQuaternion( _UnitNode.ChildNodes[ j ] , 
				                                 ref _InitQuaternion ) )
				{
					
				}				
			}
		}
	}
	public void LoadLevel( string _LevelFilepath )
	{
		Dictionary<string,UnitDataSetting> unitDataSettingTable = GlobalSingleton.GetUnitDataSettingTable() ;
		Dictionary<string,UnitDataStruct> unitDataStructTable = GlobalSingleton.GetUnitDataStructTable() ;

		Debug.Log( "LoadLevel(), _LevelFilepath=" + _LevelFilepath ) ;
		if( 0 == _LevelFilepath.Length )
		{
			// warning
			Debug.LogWarning( "_LevelFilepath=" + _LevelFilepath ) ;
			return ;
		}

		TextAsset ta = Resources.Load<TextAsset>( _LevelFilepath );
		if( null == ta )
		{
			Debug.LogError( "LoadLevel() null == ta" ) ;
			return ;
		}
#if USE_XML
		XmlDocument doc = new XmlDocument() ;
		doc.LoadXml( ta.text ) ;
		XmlNode root = doc.FirstChild ;

		if( null == root )
		{
			Debug.LogError( "LoadLevel() : null == root" ) ;
			return ;
		}
		
		// string levelname = root.Attributes[ "name" ].Value ;
		if( false == root.HasChildNodes )
		{
			Debug.Log( "LoadLevel() : false == root.HasChildNodes" ) ;
			return ;			
		}
#endif // USE_XML

#if USE_XML
		for( int i = 0 ; i < root.ChildNodes.Count ; ++i )
		{
			XmlNode unitNode = root.ChildNodes[ i ] ;
#endif // USE_XML
			string unitName = "";
			string prefabTemplateName = "";
			string unitDataTemplateName = "";

			Vector3 position = Vector3.zero ;
			PosAnchor posAnchor = new PosAnchor() ;
			Quaternion orientation = new Quaternion() ;
			string textureName = "";
			Dictionary<string,StandardParameter> standardParamMap = new Dictionary<string, StandardParameter>();
			string defensePropertyStr = "" ;

			// Debug.Log( "LoadLevel() : unitNode.Name=" + unitNode.Name ) ;
			
			if( -1 != unitNode.Name.IndexOf( "comment" ) )
			{
				// comment
			}


			else if( true == ParseUtility.ParseUnit( unitNode,
			                                        ref unitName ,
				                                                ref prefabTemplateName , 
			                                        ref unitDataTemplateName ,
			                                        ref posAnchor , 
				                                                ref orientation ,
			                                        ref standardParamMap ) )
			{
				GameObject obj = PrefabInstantiate.CreateByInit( prefabTemplateName , 
				                                                unitName , 
				                                                posAnchor.GetPosition() , 
				                                                orientation ) ;

				UnitData unitData = null ;
				if( 0 != unitDataTemplateName.Length &&
				   true == unitDataSettingTable.ContainsKey( unitDataTemplateName ) )
				{
					// Debug.Log( "unitDataTemplateName=" + unitDataTemplateName ) ;
					unitData = obj.AddComponent<UnitData>() ;

					UnitDataStruct unitDataStruct = new UnitDataStruct() ;
					unitDataStructTable.Add( obj.name , unitDataStruct ) ;// 掛上 global singleton

					unitDataStruct.Import( unitDataSettingTable[ unitDataTemplateName ] ) ;// data setting 共用

					unitData.m_UnitDataStruct = unitDataStruct ;
				}

				if( null != unitData )
				{
					unitData.m_UnitDataStruct.ImportStandardParameter( standardParamMap ) ;
				}

//				Debug.Log( "ParseUtility.ParseUnit , unitData.m_UnitDataStruct.standardParameters.Count=" + unitData.m_UnitDataStruct.standardParameters.Count ) ;
//				foreach( string key in unitData.m_UnitDataStruct.standardParameters.Keys )
//				{
//					Debug.Log( "key=" + key ) ;
//				}

			}
			else if( true == ParseUtility.ParseStaticObject( unitNode,
			                                                 ref unitName ,
			                                                 ref prefabTemplateName , 
			                                                 ref position , 
			                                                 ref orientation  ) )
			{
				/*GameObject obj =*/ PrefabInstantiate.CreateByInit( prefabTemplateName , 
				                                                unitName , 
				                                                position , 
				                                                orientation ) ;
			}
			else if( true == ParseUtility.ParseMapZoneObject( unitNode,
		                                                     ref unitName ,
		                                                     ref prefabTemplateName , 
		                                                     ref position , 
		                                                     ref orientation , 
			                                                 ref textureName ) )
			{
				GameObject obj = PrefabInstantiate.CreateByInit( prefabTemplateName , 
				                                                unitName , 
				                                                position , 
				                                                orientation ) ;

				if( 0 != textureName.Length )
				{
					obj.GetComponent<Renderer>().material = new Material( obj.GetComponent<Renderer>().material ) ;
					Texture tex = ResourceLoad.LoadTexture( textureName ) ;
					if( null == tex )
					{

					}
					else
					{
						obj.GetComponent<Renderer>().material.mainTexture = tex ;
					}
				}
			}
			else if( true == ParseUtility.ParseExistUnit( unitNode,
			                                        ref unitName ,
			                                        ref unitDataTemplateName ) )
			{
				GameObject obj = GameObject.Find( unitName ) ;
				UnitData unitData = null ;
				if( null != obj &&
				   0 != unitDataTemplateName.Length &&
				   true == unitDataSettingTable.ContainsKey( unitDataTemplateName ) )
				{
					// Debug.Log( "unitDataTemplateName=" + unitDataTemplateName ) ;
					unitData = obj.AddComponent<UnitData>() ;
					
					UnitDataStruct unitDataStruct = new UnitDataStruct() ;
					unitDataStructTable.Add( obj.name , unitDataStruct ) ;// 掛上 global singleton
					
					unitDataStruct.Import( unitDataSettingTable[ unitDataTemplateName ] ) ;// data setting 共用
					
					unitData.m_UnitDataStruct = unitDataStruct ;
				}

				
				Debug.Log( "ParseUtility.ParseExistUnit , unitData.m_UnitDataStruct.standardParameters.Count=" + unitData.m_UnitDataStruct.standardParameters.Count ) ;
			}
			else if( true == ParseUtility.ParseUnitDataStruct( unitNode,
			                                             ref unitName ,
			                                             ref unitDataTemplateName ,
			                                             ref defensePropertyStr ) )
			{
				if( 0 != unitDataTemplateName.Length &&
				   true == unitDataSettingTable.ContainsKey( unitDataTemplateName ) )
				{
					Debug.Log( "LoadLevel(), UnitDataStruct=" + unitDataTemplateName ) ;
					UnitDataStruct unitDataStruct = new UnitDataStruct() ;
					unitDataStruct.Import( unitDataSettingTable[ unitDataTemplateName ] ) ;// data setting 共用
					
					Debug.Log( "LoadLevel(), UnitDataStruct defensePropertyStr=" + defensePropertyStr ) ;
					unitDataStruct.DefenseProperty.Parse( defensePropertyStr ) ;
					
					if( false == unitDataStructTable.ContainsKey( unitName ) )
					{
						unitDataStructTable.Add( unitName , unitDataStruct ) ;// 掛上 global singleton
					}
					else
					{
						unitDataStructTable[ unitName ] = unitDataStruct ;// 掛上 global singleton
					}
				}
			}
#if USE_XML
		}
#endif // USE_XML			

	}