/// <summary> /// 加载完成后设置特效Object, 并把当前的特效状态更新给特效Object /// 这个函数设置为public是为了给特效浏览器使用 (SkillEffectBrowser). /// 除此之外, 外部不应该调用这个方法 /// </summary> /// <param name="effect"></param> public void _SetEffectAndUpdateEffectStatus(VFXController effect) { m_VFXController = effect; m_VFXController.CachedTransform.SetParent(CachedTransform, false); m_VFXController.SetEffectController(this); ReplayOperationsCached(); if (m_Status == EffectStatus.Playing) { m_StartTime = Time.time; m_VFXController.PlayFX(m_ForMainPlayer); LayerUtil.SetGameObjectToLayer(gameObject, GameConstant.LayerTypeID.TransparentFX, true); } else if (m_Status == EffectStatus.Stop) { ClearTimer(); m_VFXController.StopFX(true); } else if (m_Status == EffectStatus.Recycled) { // OnEffectLoadComplete里已经处理了 // m_VFXController.StopFX(true); // m_VFXController.ReleaseItem(); } m_OnEffectLoaded?.Invoke(this, usedata); }
public override void OnLoopFXLoaded(EffectController vfx) { GameplayProxy gameplayProxy = GameFacade.Instance.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy; SpacecraftEntity mainPlayer = gameplayProxy.GetMainPlayer(); if (mainPlayer != null) { if (gameplayProxy.CanAttackToTarget(mainPlayer, m_Buff.BuffProperty.GetOwner())) { // 隐身的时候只剩下特效. 如果是敌方隐身, 连特效都看不见了 List <EffectController> vfxList = m_Buff.BuffProperty.GetAllVFXs(); foreach (EffectController iVfx in vfxList) { // HACK. 如果不加这个if判断, 就会把隐身启动的特效一起隐藏掉 // 这里如果要完善这个逻辑, 需要做较多的工作. 我就直接偷个懒了. if (!iVfx.GetEffectObject().AutoStop) { iVfx.StopAndRecycleFX(true); } } m_Buff.BuffProperty.GetPresentation().SetVisibilityOfVFX(false); LayerUtil.SetGameObjectToLayer(m_Buff.BuffProperty.GetSkinRootTransform().gameObject, LayerTypeID.UnselectableSpacecraft, true); } } }
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); }
private void OnLoadModel(GameObject model) { // GameObject model = asyncOperation.Result; Assert.IsNotNull(model, "model is null"); LayerUtil.SetGameObjectToLayer(model, model.transform.parent.gameObject.layer, true); m_HumanAvatarProperty.SetSkinTransform(model.transform); model.transform.rotation = m_HumanAvatarProperty.GetBornServerRotation(); Animator animator = model.transform.GetComponentInChildren <Animator>(); if (animator != null) { SendEvent(ComponentEventName.AvatarLoadFinish, new AvatarLoadFinishEvent() { Animator = animator } ); } int humanLayer = m_HumanAvatarProperty.GetHeroType() == KHeroType.htPlayer ? m_HumanAvatarProperty.IsMain() ? GameConstant.LayerTypeID.MainPlayer : GameConstant.LayerTypeID.HumanOtherPlayer : GameConstant.LayerTypeID.HumanNPC; LayerUtil.SetGameObjectToLayer(model, humanLayer, true); SetSoundListenerTarget(); }
/// <summary> /// 强制关闭手表 /// </summary> /// <param name="dealyResetCamera">是否需要延迟关闭相机</param> private void ForceCloseWatch(bool dealyResetCamera) { m_LookAtState = TimeLineState.NONE; m_SelectedIndex = -1; m_WatchKeyHolding = false; ListenHotkeys(true, false); InputManager.Instance.HudInputMap = HotKeyMapID.None; m_WatchPoint = null; m_WatchPanel.gameObject.SetActive(false); SetCinemachineTrack(m_OpenTimeline, null, null, null); SetCinemachineTrack(m_CloseTimeline, null, null, null); m_OpenTimeline.gameObject.SetActive(false); m_CloseTimeline.gameObject.SetActive(false); m_PostEffectScene.gameObject.SetActive(false); m_PostEffectUI.gameObject.SetActive(false); Canvas.worldCamera.gameObject.SetActive(false); Canvas.worldCamera = CameraManager.GetInstance().GetUICameraComponent().GetCamera(); Canvas.worldCamera.cullingMask = 1 << LayerMask.NameToLayer(WATCH_2D_LAYER); Canvas.worldCamera.gameObject.SetActive(true); LayerUtil.SetGameObjectToLayer(Canvas.gameObject, LayerMask.NameToLayer(WATCH_2D_LAYER), true); LayerUtil.SetGameObjectToLayer(m_PostEffectScene, m_PostEffectSceneLayer, false); LayerUtil.SetGameObjectToLayer(m_PostEffectUI, m_PostEffectUILayer, false); UIManager.Instance.ResetPanelFit(this); CinemachineVirtualCamera camera1 = GetOrCreateVirtualCamera(VIRTUAL_CAMERA_NAME_1); CinemachineVirtualCamera camera2 = GetOrCreateVirtualCamera(VIRTUAL_CAMERA_NAME_2); if (dealyResetCamera) { camera2.Follow = camera1.Follow; camera1.enabled = camera2.enabled = false; UIManager.Instance.StartCoroutine(ResetCameraBrainBlend()); } else { camera2.Follow = camera1.Follow = null; camera1.enabled = camera2.enabled = false; } PlayHumanAnimator(false); }
public override void OnLoopFXLoaded(EffectController vfx) { // TODO, GetComponentsInChildren 是一个比较慢的操作, 考虑直接放到VFXController里, 做特效的时候直接拖上 Collider[] colliders = vfx.GetComponentsInChildren <Collider>(true); for (int iCollider = 0; iCollider < colliders.Length; iCollider++) { m_ColliderList.Add(colliders[iCollider]); m_Buff.BuffProperty.AddCollider_Runtime(colliders[iCollider]); LayerUtil.SetGameObjectToLayer(colliders[iCollider].gameObject, m_Buff.BuffProperty.GetRootTransform().gameObject.layer, false); } VFXReactiveEffect[] reactiveEffects = vfx.GetComponentsInChildren <VFXReactiveEffect>(); for (int iEffect = 0; iEffect < reactiveEffects.Length; iEffect++) { m_ReactiveVFXList.Add(reactiveEffects[iEffect]); } }
public override void InitializeByRespond(S2C_SYNC_NEW_HERO respond) { InitBaseProperty(respond); m_CfgEternityProxy = (CfgEternityProxy)GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy); ServerListProxy serverListProxy = GameFacade.Instance.RetrieveProxy(ProxyName.ServerListProxy) as ServerListProxy; m_IsMain = respond.ownerPlayerID == serverListProxy.GetCurrentCharacterVO().UId; if (m_IsMain) { GameplayProxy gameplayProxy = GameFacade.Instance.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy; gameplayProxy.SetMainPlayerUID(respond.id); gameplayProxy.SetCurrentAreaUid(respond.area_id); } if (respond.item_tid != 0) { CfgEternityProxy cfgEternityProxy = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy; m_AssetName = cfgEternityProxy.GetItemModelAssetNameByKey(respond.item_tid); } if (respond.ownerPlayerID != 0) { m_HeroType = KHeroType.htPlayer; if (m_IsMain) { Interaction.InteractionManager.GetInstance().RegisterOwnerPlayer(this); } m_Player = m_CfgEternityProxy.GetPlayerByItemTId((int)GetItemID()); } else { m_NpcTmpVO = (GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy).GetNpcByKey((uint)respond.templateID); m_HeroType = (KHeroType)m_NpcTmpVO.NpcType; m_TeleportId = respond.teleport_id_; if (m_NpcTmpVO.Function.HasValue || m_TeleportId > 0) { Interaction.InteractionManager.GetInstance().RegisterInteractable(this); //NetworkManager.Instance.GetTaskController().SendRequetNpcCanAcceptTaskInfo(respond.templateID); } if (m_NpcTmpVO.InteractionDelay > 0) { m_IsActive = false; UIManager.Instance.StartCoroutine(Excute(m_NpcTmpVO.InteractionDelay, () => { m_IsActive = true; })); } else { m_IsActive = true; } } transform.name += "_" + m_HeroType.ToString(); m_MovementRotationTransform = new GameObject("Rotation").transform; m_MovementRotationTransform.SetParent(transform); m_BornServerPosition = new Vector3(respond.posX, respond.posY, respond.posZ); SetLocalPosition(m_BornServerPosition); m_BornServerRotation = new Quaternion(respond.faceDirX, respond.faceDirY, respond.faceDirZ, respond.faceDirW); SetMovementLocalRotation(m_BornServerRotation); if (m_IsMain) { CameraManager.GetInstance().GetMainCamereComponent().SetFollowAndLookAtCMFreeLookAxisValue(MainCameraComponent.CMType.Character, transform, transform, m_BornServerRotation.eulerAngles.y, 0.5f); CameraManager.GetInstance().GetMainCamereComponent().RequestChangeCM(MainCameraComponent.CMType.Character); transform.name += "(Self)"; #if ENABLE_SYNCHRONOUS_HUMAN_SELF_LOG FightLogToFile.Instance.Write("===== InitializeByRespond =====\n"); FightLogToFile.Instance.Write("time " + Utils.Timer.ClockUtil.Instance().GetMillisecond() + "\n"); FightLogToFile.Instance.WriteToJson("S2C_SYNC_NEW_HERO", respond); FightLogToFile.Instance.Write("\n"); #endif } if (m_HeroType == KHeroType.htPlayer) { //音效组合,Listener 的目标 if (m_Player.HasValue) { WwiseUtil.LoadSoundCombo(m_Player.Value.MusicComboID); } } int humanLayer = m_HeroType == KHeroType.htPlayer ? IsMain() ? GameConstant.LayerTypeID.MainPlayer : GameConstant.LayerTypeID.HumanOtherPlayer : GameConstant.LayerTypeID.HumanNPC; LayerUtil.SetGameObjectToLayer(gameObject, humanLayer, true); m_AttManager = new AttributeManager(); InitAttManager(); }
/// <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 }); } } }
/// <summary> /// 播放动画 /// </summary> /// <param name="director">播放器</param> private void PlayTimeLine(PlayableDirector director) { CinemachineBrain mainCameraBrain = null; CinemachineVirtualCamera camera1 = null; CinemachineVirtualCamera camera2 = null; GameplayProxy gameplayProxy = GameFacade.Instance.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy; Transform hero = IsInSpace() ? null : gameplayProxy.GetMainPlayerSkinTransform(); if (hero != null) { MainCameraComponent mainCamera = CameraManager.GetInstance().GetMainCamereComponent(); mainCameraBrain = mainCamera.GetCamera().GetComponent <CinemachineBrain>(); camera1 = GetOrCreateVirtualCamera(VIRTUAL_CAMERA_NAME_1); camera2 = GetOrCreateVirtualCamera(VIRTUAL_CAMERA_NAME_2); if (director == m_OpenTimeline) { //机位1 ( 打开手表时相机所在机位 ) camera1.Follow = GetOrCreateVirtualCameraProxy("WATCH_BACK_POINT"); camera1.Follow.position = mainCamera.transform.position; camera1.Follow.rotation = mainCamera.transform.rotation; //机位2 ( 注视手表的机位 ) camera2.Follow = FindTransformBy(hero, CAMERA_POINT_NAME); //UI挂点 m_WatchPoint = FindTransformBy(hero, WATCH_UI_NAME); Canvas.worldCamera = CameraManager.GetInstance().GetUI3DCameraComponent().GetCamera(); Canvas.worldCamera.cullingMask = 1 << LayerMask.NameToLayer(WATCH_3D_LAYER); Canvas.worldCamera.gameObject.SetActive(true); Canvas.scaleFactor = 0.001f; Canvas.transform.localScale = Vector3.one * 0.0001f; Canvas.GetComponent <RectTransform>().sizeDelta = UIManager.ReferenceResolution; LayerUtil.SetGameObjectToLayer(Canvas.gameObject, LayerMask.NameToLayer(WATCH_3D_LAYER), true); LayerUtil.SetGameObjectToLayer(m_PostEffectScene, m_PostEffectSceneLayer, false); LayerUtil.SetGameObjectToLayer(m_PostEffectUI, m_PostEffectUILayer, false); camera1.enabled = true; camera2.enabled = true; } } m_WatchPanel.gameObject.SetActive(true); if (director == m_OpenTimeline) { m_CloseTimeline.gameObject.SetActive(false); SetCinemachineTrack(m_OpenTimeline, mainCameraBrain, camera1, camera2); m_OpenTimeline.extrapolationMode = DirectorWrapMode.Hold; m_OpenTimeline.gameObject.SetActive(true); m_OpenTimeline.time = 0.0f; m_OpenTimeline.Play(); m_PostEffectScene.gameObject.SetActive(true); m_PostEffectUI.gameObject.SetActive(true); } else if (director == m_CloseTimeline) { m_OpenTimeline.gameObject.SetActive(false); SetCinemachineTrack(director, mainCameraBrain, camera2, camera1); m_CloseTimeline.extrapolationMode = DirectorWrapMode.None; m_CloseTimeline.gameObject.SetActive(true); m_CloseTimeline.time = 0.0f; m_CloseTimeline.Play(); m_PostEffectScene.gameObject.SetActive(true); m_PostEffectUI.gameObject.SetActive(true); m_SelectedIndex = -1; UpdateCenterInfo(); } //人形动画 PlayHumanAnimator(director == m_OpenTimeline); }
private void OnLoadModel(GameObject pObj) { m_BulletTf.gameObject.name = string.Format("{0}_{1}", m_BulletTf.gameObject.name, m_FlyerData.BaseData.Value.ApperanceAddress); LayerUtil.SetGameObjectToLayer(m_BulletTf.gameObject, GameConstant.LayerTypeID.SkillProjectile, true); pObj.transform.SetParent(m_BulletTf, false); pObj.transform.localPosition = Vector3.zero; pObj.transform.localRotation = Quaternion.identity; //刚体,碰撞盒都挂载 ,子弹transfrom ,子弹预制体只作显示 //刚体 Rigidbody rigidbody = m_BulletTf.GetOrAddComponent <Rigidbody>(); rigidbody.useGravity = false; rigidbody.drag = 0; rigidbody.angularDrag = 0; rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic; rigidbody.freezeRotation = true; rigidbody.velocity = Vector3.zero; m_Property.SetRigidbody(rigidbody); FlyerColliderData colliderData = m_FlyerData.BaseData.Value.Collider.Value; //碰撞盒 switch (colliderData.ColliderType) { case FlyerColliderType.Capsule: //胶囊体 { // 0->Capsule height is along the x - axis. 1->Capsule height is along the y - axis. 2->Capsule height is along the z - axis CapsuleCollider collider = m_BulletTf.GetOrAddComponent <CapsuleCollider>(); collider.direction = 2; collider.radius = colliderData.Radius * SceneController.SKILL_PRECISION; collider.height = colliderData.Height * SceneController.SKILL_PRECISION; collider.isTrigger = true; } break; case FlyerColliderType.Sphere: //球体 { SphereCollider collider = m_BulletTf.GetOrAddComponent <SphereCollider>(); collider.radius = colliderData.Radius * SceneController.SKILL_PRECISION; collider.isTrigger = true; } break; case FlyerColliderType.Box: //盒子 { BoxCollider collider = m_BulletTf.GetOrAddComponent <BoxCollider>(); collider.size = colliderData.Size.Value.ToVector3() * SceneController.SKILL_PRECISION; collider.isTrigger = true; } break; default: break; } Quaternion rot = Quaternion.identity; rot.eulerAngles = m_Property.GetDirection(); m_BulletTf.rotation = rot; }