コード例 #1
0
	private DropItemAction CreateDropObject( AS_body2_SC_DROPITEM_APPEAR data, Item item)
	{
		if( null == item)
			return null;
		
		GameObject goDropItem = item.GetDropItem();
		
		if( null == goDropItem)
		{
			Debug.LogError( " DropItemManagement::Create [null == goDropItem]");
			return null;
		}
		
		GameObject goObject = GameObject.Instantiate( goDropItem, data.sCurPosition, Quaternion.identity) as GameObject;
		if( null == goObject)
		{
			Debug.LogError( "DropItemManagerMent::CreateDropObject()[ null == goObject ] item id : " + item.ItemID);
			return null;
		}
		
		DropItemAction action = goObject.GetComponentInChildren<DropItemAction>() as DropItemAction;
		if( null == action)
		{
			Debug.LogError( "DropItemManagement::Create no have DropItemAction script");
			GameObject.Destroy( goObject);
			return null;
		}
		
		action.rootNode = goObject;
		
		if( null == m_ParentObject)
			m_ParentObject = new GameObject( "DropItem");
		
		Vector3 vec3Pos = data.sCurPosition;
		vec3Pos.y = TerrainMgr.GetTerrainHeight( vec3Pos);
		
		goObject.transform.parent = m_ParentObject.transform;
		goObject.transform.localPosition = vec3Pos;
		goObject.transform.localRotation = Quaternion.identity;
		goObject.transform.localScale = Vector3.one;
		
		ResourceLoad.SetLayerHierArchy( goObject.transform, LayerMask.NameToLayer( "Item"));
		
		return action;
	}