public override void OnBuffRemove() { base.OnBuffRemove(); GameplayProxy gameplayProxy = GameFacade.Instance.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy; SpacecraftEntity mainPlayer = gameplayProxy.GetMainPlayer(); if (mainPlayer != null) { if (gameplayProxy.CanAttackToTarget(mainPlayer, m_Buff.BuffProperty.GetOwner())) { // 隐身的时候只剩下特效. 如果是敌方隐身, 连特效都看不见了 // 隐身时隐藏船的本体的功能是在VFXReplaceMeshWithSpacecraft里面做的 if (gameplayProxy.CanAttackToTarget(mainPlayer, m_Buff.BuffProperty.GetOwner())) { List <EffectController> vfxList = m_Buff.BuffProperty.GetAllVFXs(); foreach (EffectController iVfx in vfxList) { iVfx.SetCreateForMainPlayer(false); iVfx.PlayFX(); } } m_Buff.BuffProperty.GetPresentation().SetVisibilityOfVFX(true); // 现在创建隐身特效时直接把SkinRoot下面的所有东西都隐藏了. int spacecraftLayer = LayerUtil.GetLayerByHeroType(m_Buff.BuffProperty.GetHeroType(), m_Buff.BuffProperty.IsMain()); LayerUtil.SetGameObjectToLayer(m_Buff.BuffProperty.GetSkinRootTransform().gameObject, spacecraftLayer, true); } } m_Buff.BuffProperty.SetInvisible(false); }
/// <summary> /// 飞船模型载入完毕 /// </summary> /// <param name="asyncOperation"></param> private void OnLoadModel(GameObject asyncOperation, string path) { m_Model = asyncOperation; if (m_Model == null) { throw new System.Exception("m_Model is null"); } if (!asyncOperation.IsPooled()) { asyncOperation.CreatePool(1, path); } m_Model = asyncOperation.Spawn(m_Property.GetSkinRootTransform()); if (m_Model.transform.parent == null) { m_Model.Recycle(); return; } m_Model.transform.localPosition = Vector3.zero; m_Model.transform.localRotation = Quaternion.identity; m_Model.transform.localScale = Vector3.one; m_Property.SetSkinTransform(m_Model.transform); SendEvent(ComponentEventName.AvatarLoadFinish, new AvatarLoadFinishEvent() { SpacecraftPresentation = m_Model.GetComponentInChildren <SpacecraftPresentation>(), Animator = m_Model.GetComponentInChildren <Animator>(), Animators = m_Model.GetComponentsInChildren <Animator>() }); if (m_Property.GetHeroType() == KHeroType.htDetector) { SendEvent(ComponentEventName.OnGetMeshRenderer, new GetMeshRendererEvent() { MeshRenderer = m_Model.GetComponentInChildren <MeshRenderer>(), /// TODO. Transform = m_Model.transform.Find("Effect_A") }); } int spacecraftLayer = LayerUtil.GetLayerByHeroType(m_Property.GetHeroType(), m_Property.IsMain()); LayerUtil.SetGameObjectToLayer(m_Model, spacecraftLayer, true); if (m_Property.GetSyncTarget() != null) { LayerUtil.SetGameObjectToLayer(m_Property.GetSyncTarget().gameObject, spacecraftLayer, true); } m_Presentation = m_Model.GetComponent <SpacecraftPresentation>(); if (m_Presentation == null) { Debug.LogWarning(string.Format("这个错误不可忽略! 飞船 {0} 没有挂点和表现信息, 找美术加上.", m_Model.name)); } else { m_Property.SetPresentation(m_Presentation); // 复制一份CapsuleCollider给同步模块使用. 这个复制出来的CapsuleCollider不会被LODSwitchItem影响, 所以不会被Disable // 只有玩家才会与场景碰撞. 怪物和NPC都不与场景碰撞. 程旭与王梓晨商议决定 if (m_Property.GetHeroType() == KHeroType.htPlayer) { CapsuleCollider capsuleCollider = m_Presentation.GetCapsuleCollider(); if (capsuleCollider == null) { Debug.LogError(string.Format("这个错误不可忽略! 飞船 {0} 没有胶囊碰撞体, 找美术加上.", m_Model.name)); } GameObject colliderCopy = GameObject.Instantiate(capsuleCollider.gameObject, m_Property.GetSyncTarget()); colliderCopy.transform.position = capsuleCollider.transform.position; colliderCopy.transform.rotation = capsuleCollider.transform.rotation; colliderCopy.name = string.Format("{0}_ForMotionSync", capsuleCollider.name); LayerUtil.SetGameObjectToLayer(colliderCopy, GameConstant.LayerTypeID.ServerSynchronization, false); } else { if (m_Property.GetHeroType() == KHeroType.htMine) { List <Collider> capsuleColliders = m_Presentation.GetAllCapsuleColliders(); if (capsuleColliders != null) { foreach (var item in capsuleColliders) { item.gameObject.layer = GameConstant.LayerTypeID.SkillCrossSpacecraftBlock; } } } //if (EffectUtility.IsEffectNameValid(m_Presentation.BirthFXAddress)) //{ // EffectController BirthFX = EffectManager.GetInstance().CreateEffect(m_Presentation.BirthFXAddress, EffectManager.GetEffectGroupNameInSpace(false), OnLoadBrithFXComplete,this); // BirthFX.transform.SetParent(m_Property.GetSkinRootTransform(), false); // BirthFX.SetCreateForMainPlayer(false); // m_Presentation.SetVisibilityOfEntireSpacecraft(false); //} m_ModelLoadCompleteInThisFrame = true; m_TimeOfModelLoadComplete = Time.time; } //if (m_Died && m_Presentation.DeathFXAddressList != null && m_Presentation.DeathFXAddressList.Count != 0) //{ // EffectController deathFX = EffectManager.GetInstance().CreateEffect(m_Presentation.DeathFXAddressList[m_DeathFXIndex], EffectManager.GetEffectGroupNameInSpace(false)); // deathFX.transform.SetParent(m_Property.GetSkinRootTransform(), false); // deathFX.SetCreateForMainPlayer(false); //} } UpdateVisibility(); UpdateEnableOfAllCollider(); UpdateColliderLOD(true); if (m_Property.IsDead()) { m_Property.SetSkinVisiable(false); } /// 是探测器 if (m_Property.GetOwner().m_EntityFatherOwnerID != 0 && m_Property.GetHeroType() == KHeroType.htDisturbor && !m_Property.IsDead()) { AddLineEffect(); } /// 封印 if (m_Property.IsSeal()) { AddHideEffect(); } /// Npc出生音乐 if (m_Property.GetHeroType() != KHeroType.htPlayer) { Npc npcVO = m_Property.GetNPCTemplateVO(); if (npcVO.SoundAlive > 0) { SendEvent(ComponentEventName.PlaySound, new PlaySound() { SoundID = (int)npcVO.SoundAlive }); } } }