public virtual void Init(BulletParam param) { m_param = param; m_aimTransform = m_param.aimTransform; if (m_param.bTraceTarget && m_param.m_skillBase.m_hitActor != null) { //ActorObj actorBase = m_param.m_skillBase.GetTargetFromSelector(null); //if (actorBase != null) //{ m_aimTransform = m_param.m_skillBase.m_hitActor.transform; ////转向 //m_param.m_skillBase.m_actor.transform.LookAt(m_aimTransform); //} } //是否绑在技能上 if (m_param.bAttachToSkill) { m_param.m_skillBase.AttachABullet(this); BaseTool.ResetTransform(transform); } if (m_aimTransform != null) { distanceToTarget = Vector3.Distance(this.transform.position, m_aimTransform.position); } else if (m_param.targetpos != Vector3.zero) { distanceToTarget = Vector3.Distance(this.transform.position, m_param.targetpos); } }
public void Load() { if (MapMgr.Instance.InMainCity == false) { if (BossDeadEffect.GameObj != null) { BossDeadEffect.Load("Animation/effect/BossDeadEffect", (a, b) => { BossDeadEffect.GameObj.SetActive(false); }); //在GetComponentInChildren之前先判断是否active,如果不是的话,先打开 if (BossDeadEffect.GameObj.activeInHierarchy == false) { BossDeadEffect.GameObj.SetActive(true); } Camera cam = BossDeadEffect.GameObj.GetComponentInChildren <Camera>(); if (cam != null && null != CoreEntry.gCameraMgr.MainCamera) { cam.CopyFrom(CoreEntry.gCameraMgr.MainCamera); BaseTool.ResetTransform(cam.transform); } if (null != CoreEntry.gCameraMgr.MainCamera) { BossDeadEffect.GameObj.transform.parent = CoreEntry.gCameraMgr.MainCamera.transform; } BaseTool.ResetTransform(BossDeadEffect.GameObj.transform); //不让动画自动播放 BossDeadEffect.GameObj.SetActive(false); BossDeadEffect_PlayAction = BossDeadEffect.GameObj.GetComponent <PlayAction>(); } } }
public override void Init(ISkillCellData cellData, SkillBase skillBase) { m_skillBase = skillBase; cellDesc = (PositionCellDesc)cellData; skillBase.ShouldUpdatePositionToCastObj = false; orgPos = m_skillBase.m_actor.transform.position; orgFront = m_skillBase.m_actor.transform.forward; orgRight = m_skillBase.m_actor.transform.right; targetTransform = null; if (cellDesc != null) { //有对应的行为技能ID if (cellDesc.BehaviorSkillId > 0) { behaviorSkillDesc = skillBase.m_actor.GetCurSkillDesc(cellDesc.BehaviorSkillId); if (behaviorSkillDesc != null) { ActorObj targetActorBase = skillBase.m_actor.GetTargetFromSelector(behaviorSkillDesc, null); if (targetActorBase != null) { targetTransform = targetActorBase.transform; } } } else { //默认技能行为 if (skillBase.m_hitActor != null) { targetTransform = skillBase.m_hitActor.transform; } } //是否attach到actor上 if (cellDesc.AttachToActor) { if (cellDesc.SyncRotation) { skillBase.transform.parent = targetTransform; BaseTool.ResetTransform(skillBase.transform); skillBase.transform.localPosition += cellDesc.AttachOffset; } else { SyncPosition(); BaseTool.SetLocalPosition(m_skillBase.transform, curMovingPos); } } else { //走相应的轨迹 if (cellDesc.PointList.Count > 0) { BaseTool.SetPosition(skillBase.transform, GetPos(0)); skillBase.transform.forward = skillBase.transform.forward; currentIndex = 0; } } //同步施法者位置 if (cellDesc.SyncOwnerPosition) { BaseTool.SetPosition(m_skillBase.m_actor.transform, skillBase.transform.position); } Reset(); if (cellDesc.DelayMovingTime >= 0) { //吟唱后,发射子弹 float curTime = m_skillBase.GetCurActionTime(); if (cellDesc.DelayMovingTime <= curTime) { StartToMove(); } else { Invoke("StartToMove", cellDesc.DelayMovingTime - curTime); } } } }
void DoAction() { //播放动作,特效 if (m_actionCellDesc.name.Length > 0) { m_actor.PlayAction(m_actionCellDesc.name, false); m_actor.SetActionTime(m_actionCellDesc.name, m_actionCellDesc.setStartTime); m_actor.SetActionSpeed(m_actionCellDesc.name, m_actionCellDesc.speed); } //播放声音 string sound1 = ""; string sound2 = ""; bool ret1 = AudioCore.GenerateAudio(m_actionCellDesc.sound1, ref sound1); bool ret2 = AudioCore.GenerateAudio(m_actionCellDesc.sound2, ref sound2); if (ret1 && sound1.Length > 0) { m_actor.StopSound(); m_actor.PlaySound(sound1); } if (ret2 && sound2.Length > 0) { m_actor.StopSound2(); m_actor.PlaySound2(sound2); } if (m_actionCellDesc.efx.Length > 0) { //GameObject efxObj = Instantiate( // CoreEntry.gResLoader.LoadResource(m_actionCellDesc.efx)) as GameObject; GameObject efxObj = CoreEntry.gGameObjPoolMgr.InstantiateEffect(m_actionCellDesc.efx); float maxEfxTime = 0; NcCurveAnimation[] efxAnimations = efxObj.GetComponentsInChildren <NcCurveAnimation>(); for (int i = 0; i < efxAnimations.Length; ++i) { efxAnimations[i].m_fDelayTime /= m_actionCellDesc.speed; efxAnimations[i].m_fDurationTime /= m_actionCellDesc.speed; float efxTime = efxAnimations[i].m_fDelayTime + efxAnimations[i].m_fDurationTime; if (efxTime > maxEfxTime) { maxEfxTime = efxTime; } } LuaTable skill_action = CoreEntry.gSkillMgr.GetSkillActon(m_skillBase.m_skillID); if (skill_action != null && skill_action.Get <float>("skillEfxLength") > 0) { maxEfxTime = skill_action.Get <float>("skillEfxLength"); } //LogMgr.UnityLog("maxEfxTime=" + maxEfxTime + ", " + m_strActionName); //特效存在时间 if (maxEfxTime <= 0.001) { maxEfxTime = 5; } EfxAttachActionPool efx = efxObj.GetComponent <EfxAttachActionPool>(); if (efx == null) { efx = efxObj.AddComponent <EfxAttachActionPool>(); } m_actionEfx = efx; if (m_actionCellDesc.shouldAttachToOwner) { efx.Init(m_skillBase.m_actor.transform, maxEfxTime); //设置有挂点的特效 Transform[] childTransform = efxObj.GetComponentsInChildren <Transform>(); foreach (Transform childTrans in childTransform) { EfxSetAttachPoint setAttach = childTrans.gameObject.GetComponent <EfxSetAttachPoint>(); if (setAttach == null || setAttach.m_attachPointEnum == AttachPoint.E_None) { continue; } setAttach.Init(false); Transform parent = m_actor.GetChildTransform(setAttach.m_attachPointEnum.ToString()); if (parent != null) { childTrans.parent = parent; childTrans.localPosition = Vector3.zero; childTrans.localRotation = Quaternion.identity; childTrans.localScale = Vector3.one; if (m_attachEfxObjectlist == null) { m_attachEfxObjectlist = new List <GameObject>(); } m_attachEfxObjectlist.Add(childTrans.gameObject); } } //影子 ghostMesh[] ghostMesh = efx.GetComponentsInChildren <ghostMesh>(); SkinnedMeshRenderer MianSkinMesh = m_actor.m_skinnedMeshRenderer[0]; for (int i = 0; i < m_actor.m_skinnedMeshRenderer.Length; ++i) { if (m_actor.m_skinnedMeshRenderer[i].name.Contains("weapon")) { continue; } MianSkinMesh = m_actor.m_skinnedMeshRenderer[i]; } for (int i = 0; i < ghostMesh.Length; ++i) { ghostMesh[i].characterMesh[0] = MianSkinMesh; } } else { efx.Init(m_skillBase.transform, maxEfxTime, false); efx.transform.parent = m_skillBase.transform; BaseTool.ResetTransform(efx.transform); } } }