Example #1
0
	public IEnumerator LoadingModel( AsBaseEntity _entity, int _idx)
	{
		m_ModelLoadingState = eModelLoadingState.Started;
		_entity.isKeepDummyObj = false;
		
		if( null != m_Entity.ModelObject)
		{
			Destroy( m_Entity.ModelObject);
			
			if( null != m_PartsRoot)
				m_PartsRoot.Clear();
		}
		
		if( Entity.ContainProperty( eComponentProperty.SHOP_OPENING) == true)
		{
			if( Entity.AnimEnableViaShop == false)
				m_ModelType = eModelType.Shop;
			else
				m_ModelType = eModelType.Normal;
		}
		
		if( eEntityType.USER == _entity.EntityType)
		{
			if( null != AssetbundleManager.Instance && true == AssetbundleManager.Instance.useAssetbundle)
			{
				Debug.Log( "InitialUserCharacter( 1): " + AssetbundleManager.Instance);
				yield return StartCoroutine( InitialUserCharacter_Assetbundle());
			}
			else
			{
				Debug.Log( "InitialUserCharacter( 2): " + AssetbundleManager.Instance);
				
				InitialUserCharacter();
			}
			
#if AUTOMOVE_EFFECT
			if( Entity.isNeedAutoMoveEffect)
				AsEffectManager.Instance.PlayEffect( "FX/Effect/COMMON/Fx_Common_AutoMove", Entity.transform, false, 0f, 1.0f);
			if( Entity.isNeedAutoMoveEffect && null != AsSoundManager.Instance)
				AsSoundManager.Instance.PlaySound( "Sound/PC/Common/Se_Common_AutoMove", Entity.transform.position, false);
#endif
		}
		else if( eEntityType.NPC == _entity.EntityType)
		{
			m_dicDummy.Clear();
			
			string modelingPath = null;
			string[] strSplit = null;
			bool dataFound = true;
			
			if( Entity.ContainProperty( eComponentProperty.NPC_ID) == true)
			{
				int id = Entity.GetProperty<int>( eComponentProperty.NPC_ID);
				Tbl_Npc_Record npcrecord = AsTableManager.Instance.GetTbl_Npc_Record( id);
				
				modelingPath = npcrecord.ModelingPath;
				strSplit = npcrecord.ModelingPath.Split( '/');
			}
			else if( Entity.ContainProperty( eComponentProperty.PET_ID) == true)
			{
				int id = Entity.GetProperty<int>( eComponentProperty.PET_ID);
				Tbl_Pet_Record petRecord = AsTableManager.Instance.GetPetRecord( id);

				modelingPath = petRecord.Model;
				strSplit = petRecord.Model.Split( '/');
			}
			else
			{
				Debug.LogError( "AsModel::InitialNpcCharacter: no data table record. CHECK NPC ID");
				dataFound = false;
			}
			
			if( dataFound == true)
			{	
				if( null != AssetbundleManager.Instance && true == AssetbundleManager.Instance.useAssetbundle)
				{
					string strNameLower = strSplit[strSplit.Length-1].ToLower();
					string strAssetbundlePath = AssetbundleManager.Instance.GetAssetbundleDownloadPath( strNameLower);
					int nVersion = AssetbundleManager.Instance.GetCachedVersion( strNameLower);
					
					WWW www = WWW.LoadFromCacheOrDownload( strAssetbundlePath, nVersion);
					yield return www;
					
					AssetBundle bundle = www.assetBundle;
					AssetBundleRequest request = bundle.LoadAsync( strNameLower, typeof( GameObject));
					yield return request;
					
					GameObject obj = request.asset as GameObject;
					if( null == obj)
					{
						Debug.LogError( "AsModel::InitialNpcCharacter: There is no [" + modelingPath + "] modeling resource.");
						obj = GameObject.CreatePrimitive( PrimitiveType.Sphere);
					}
					
					GameObject model = Instantiate( obj) as GameObject;
					
					bundle.Unload( false);
	
					yield return StartCoroutine( CreateMaterial( model, strNameLower));
					
					Entity.SetModelObject( model);
					InitMonsterDummy( Entity.ModelObject.transform);
					Entity.ModelObject.name = "Model";
					Entity.ModelObject.transform.parent = transform;
//					Entity.ModelObject.transform.localPosition = Vector3.zero;
					Entity.ModelObject.transform.localRotation = Quaternion.identity;
				}
				else
				{
					GameObject obj = ResourceLoad.LoadGameObject( modelingPath);
					if( null == obj)
					{
						Debug.LogError( "AsModel::InitialNpcCharacter: There is no [" + modelingPath + "] modeling resource.");
						obj = GameObject.CreatePrimitive( PrimitiveType.Sphere);
					}

					GameObject model = Instantiate( obj) as GameObject;

					Entity.SetModelObject( model);
					InitMonsterDummy( Entity.ModelObject.transform);
					Entity.ModelObject.name = "Model";
					Entity.ModelObject.transform.parent = transform;
//					Entity.ModelObject.transform.localPosition = Vector3.zero;
					Entity.ModelObject.transform.localRotation = Quaternion.identity;
				}
			}
			else
			{
				Debug.LogError( "AsModel::InitialNpcCharacter: no data table record. CHECK NPC ID");
			}
		}
		
		_entity.SetDummyTransform( m_dicDummy);
 
		Entity.ModelObject.transform.localPosition = Vector3.zero;
		m_Entity.ModelObject.transform.localScale = Vector3.one;
		
		if( _entity.isSegregate == false)
			_CreateNamePanel( _entity);
		
		if( eFsmType.COLLECTION != _entity.FsmType )
			MakeShadow();
		
		_CreatePvpPointEffect( _entity);
		
		m_ModelLoadingState = eModelLoadingState.Finished;
		
		InitHide();
		
 		m_Entity.HandleMessage( new Msg_ModelLoaded());
		if( m_Entity.FsmType == eFsmType.PLAYER)
			Debug.Log( "AsModel::OnModelChange: Msg_ModelLoaded is send. [" + m_Entity.FsmType + "] model type = " + m_ModelType);

		DeleteDummyObj();
	}
Example #2
0
	public IEnumerator LoadingModel_Dummy( AsBaseEntity _entity, int _idx)
	{
		m_ModelLoadingState = eModelLoadingState.Started;
		_entity.isKeepDummyObj = true;
		
		yield return null;
		
		if( Entity.ContainProperty( eComponentProperty.SHOP_OPENING) == true)
		{
			if( Entity.AnimEnableViaShop == false)
				m_ModelType = eModelType.Shop;
			else
			{
				m_ModelType = eModelType.Normal;
				if( null != m_Entity.ModelObject)
				{
					Destroy( m_Entity.ModelObject);
					
					if( null != m_PartsRoot)
						m_PartsRoot.Clear();
				}
			}
		}
		else
		{
			if( null != m_Entity.ModelObject)
			{
				Destroy( m_Entity.ModelObject);
				
				if( null != m_PartsRoot)
					m_PartsRoot.Clear();
			}
		}
		
		if( eEntityType.USER == _entity.EntityType)
		{
#if AUTOMOVE_EFFECT
			if( Entity.isNeedAutoMoveEffect)
				AsEffectManager.Instance.PlayEffect( "FX/Effect/COMMON/Fx_Common_AutoMove", Entity.transform, false, 0f, 1.0f);
			if( Entity.isNeedAutoMoveEffect && null != AsSoundManager.Instance)
				AsSoundManager.Instance.PlaySound( "Sound/PC/Common/Se_Common_AutoMove", Entity.transform.position, false);
#endif
		}
		
//		_entity.SetDummyTransform( m_dicDummy);

		m_Entity.SetModelObject( m_DummyObj);
		m_Entity.ModelObject.name = "Model";
		
		if( _entity.isSegregate == false)
			_CreateNamePanel( _entity);
		
		if( eFsmType.COLLECTION != _entity.FsmType )
			MakeShadow();
		
		_CreatePvpPointEffect( _entity);
		
		m_ModelLoadingState = eModelLoadingState.Finished;
		
		InitHide();
		
		m_Entity.HandleMessage( new Msg_ModelLoaded_Dummy());
		
		if( m_Entity.FsmType == eFsmType.PLAYER)
			Debug.Log( "AsModel::OnModelChange: Msg_ModelLoaded is send. [" + m_Entity.FsmType + "] model type = " + m_ModelType);

//		DeleteDummyObj();
	}