/// <summary> /// 添加技能特效。 /// </summary> /// <param name="actioncfg">技能效果配置。</param> public static void AddSkillEffect(LuaTable actioncfg) { //技能特效 if (SkillEffect != null) { CoreEntry.gGameObjPoolMgr.Destroy(SkillEffect); } string actionEfx = actioncfg.Get <string>("skilleffect"); if (!string.IsNullOrEmpty(actionEfx)) { SkillEffect = CoreEntry.gGameObjPoolMgr.InstantiateEffect(actionEfx); if (SkillEffect != null) { EfxAttachActionPool efx = SkillEffect.GetComponent <EfxAttachActionPool>(); if (efx == null) { efx = SkillEffect.AddComponent <EfxAttachActionPool>(); } Transform player = CurModeShow.mPlayerObject.transform; Transform eft = SkillEffect.transform; efx.Init(player, actioncfg.Get <float>("skillEfxLength"), false); if (actioncfg.Get <bool>("isBind")) { Transform bindTran; string hangpoint = actioncfg.Get <string>("hangPoint"); if (!string.IsNullOrEmpty(hangpoint)) { bindTran = player.transform.DeepFindChild(hangpoint); if (null == bindTran) { bindTran = player; } } else { bindTran = player; } eft.SetParent(bindTran); eft.localPosition = Vector3.zero; eft.localScale = Vector3.one; eft.localRotation = Quaternion.identity; } else { eft.SetParent(player.parent); eft.position = player.position; eft.localScale = Vector3.one; eft.rotation = player.rotation; } } } }
void Start() { CancelInvoke("Start"); if (m_skillBase == null || m_skillBase.m_actor == null) { return; } m_skillBase.m_actor.ReqirueCanNotBeControlledByInput(); //主角在电梯上禁止美术位移 if (CoreEntry.gSceneMgr.IsPlayerOnElevator()) { return; } if (m_movePosAttackDesc == null) { return; } LuaTable skillDesc = m_skillBase.m_actor.GetCurSkillDesc(m_skillBase.m_skillID); if (skillDesc == null) { LogMgr.UnityError("non SkillDesc! " + m_skillBase.m_skillID); return; } //SkillClassDisplayDesc skillClass = m_gameDBMgr.GetSkillClassDisplayDesc(skillDesc.Get<int>("skillDisplayID")); //计算位移距离 m_distance = m_movePosAttackDesc.moveDistance; //使用目标的位置, 前面0.5米 if (m_skillBase.m_actor.IsMainPlayer()) { if (m_skillBase.m_actor.m_SelectTargetObject != null) { float dist1 = Vector3.Distance(transform.position, m_skillBase.m_actor.m_SelectTargetObject.transform.position) - 0.5f; if (dist1 > m_distance) { dist1 = m_distance; } m_distance = dist1; } } float resetDistance = m_distance; //设置位移 do { ActorObj ActorObj = m_skillBase.m_actor.GetAttackObj(); if (ActorObj == null) { ActorObj = m_skillBase.m_hitActor; } if (ActorObj == null) { LogMgr.UnityLog("CurveMove:no target"); break; } GameObject targetObj = ActorObj.thisGameObject; if (targetObj == null) { LogMgr.UnityLog("CurveMove:no target"); break; } ActorObj targetActorBase = targetObj.GetComponent <ActorObj>(); if (targetActorBase == null) { LogMgr.UnityError("CurveMove:no actorbase"); break; } if (m_movePosAttackDesc.isStopForTarget) { float fDistTo = m_skillBase.m_actor.GetColliderRadius() + targetObj.GetComponent <ActorObj>().GetColliderRadius(); if (CoreEntry.gGameMgr.IsPvpState()) { fDistTo += 1.2f; } //不可以穿透,重置位移大小 float aimDistance = Vector3.Distance(m_transform.position, targetObj.transform.position) - fDistTo - 0.2f; //两个物体间的距离 //范围内,不需要位移 if (aimDistance <= 0) { //Debug.LogWarning("CurveMove: don't need excute!"); return; } resetDistance = Mathf.Min(aimDistance, resetDistance); } else { resetDistance = m_distance; } } while (false); Quaternion r0 = Quaternion.Euler(m_transform.eulerAngles); Vector3 pos = m_transform.position + r0 * Vector3.forward * resetDistance; //找到对应地面上的点 Vector3 aimPos = m_baseTool.GetGroundPoint(pos); if (aimPos.Equals(Vector3.zero)) { return; } Vector3 dstDir = aimPos - m_transform.position; dstDir.Normalize(); //左手方向 //Vector3 leftDir = Quaternion.Euler(new Vector3(0, 90, 0)) * dstDir; //Vector3 rightDir = Quaternion.Euler(new Vector3(0, -90, 0)) * dstDir; //Vector3 backDir = Quaternion.Euler(new Vector3(0, 180, 0)) * dstDir; //float dstDistance = Vector3.Distance(m_transform.position, aimPos); m_needMove = true; //向上移动点 //aimPos += new Vector3(0, 0.2f, 0); aimPos = m_baseTool.GetLineReachablePos(m_transform.position, aimPos); aimPos = m_baseTool.GetGroundPoint(aimPos); if (m_skillBase.m_actor.IsMainPlayer()) { m_dstPos = aimPos; } else { m_dstPos = m_skillBase.m_actor.m_CurveMovePos; } //使用曲线 CurveMoveParam param = new CurveMoveParam(); param.aimActorTypeList = m_movePosAttackDesc.resetAimActorTypeList; param.isCarryOffTarget = m_movePosAttackDesc.isCarryOffTarget; param.isStopForTarget = m_movePosAttackDesc.isStopForTarget; LuaTable skill_action = CoreEntry.gSkillMgr.GetSkillActon(m_skillBase.m_skillID); if (skill_action != null) { m_uuid = m_skillBase.m_actor.UseCurveData3(skill_action.Get <string>("animation"), m_dstPos,// m_dstPos, param); } m_param = param; //拖尾特效 if (m_movePosAttackDesc.efxPrefab.Length > 0) { //GameObject efxObj = Instantiate(CoreEntry.gResLoader.LoadResource(m_movePosAttackDesc.efxPrefab)) as GameObject; GameObject efxObj = CoreEntry.gGameObjPoolMgr.InstantiateEffect(m_movePosAttackDesc.efxPrefab); EfxAttachActionPool efx = efxObj.GetComponent <EfxAttachActionPool>(); if (efx == null) { efx = efxObj.AddComponent <EfxAttachActionPool>(); } float efxTime = 1.0f; if (skill_action != null) { m_skillBase.m_actor.GetLeftActionTime(skill_action.Get <string>("animation")); } efx.Init(m_skillBase.m_actor.transform, efxTime); } }
public void ShowSkillScope() { SkillClassDisplayDesc skillClass = m_gameDBMgr.GetSkillClassDisplayDesc(m_skillDesc.Get <int>("skillDisplayID")); if (skillClass == null) { Debug.LogError("===skillClass== is null==="); return; } LuaTable skilleffect = ConfigManager.Instance.Skill.GetEffectConfig(m_skillID); if (skilleffect.Get <int>("range") == (int)SkillRangeType.SKILL_TARGET) // if ((int)m_skillDesc.atkType == (int)Configs.skillConfig.AtkTypeEnum.SINGLE) { m_bIsAoe = false; } //吟唱阶段 for (int i = 0; i < skillClass.prepareStageDataList.Count; ++i) { GameObject cellObj = CoreEntry.gGameObjPoolMgr.InstantiateSkillCell(skillClass.prepareStageDataList[i].prefabPath); cellObj.transform.parent = transform; ISkillCell skillCell = cellObj.GetComponent <ISkillCell>(); skillCell.Init(skillClass.prepareStageDataList[i], this); skillCell.SetAoeState(m_bIsAoe); AddSkillCell(cellObj); } //技能元素 for (int i = 0; i < skillClass.castStageDataList.Count; ++i) { GameObject cellObj = CoreEntry.gGameObjPoolMgr.InstantiateSkillCell(skillClass.castStageDataList[i].prefabPath); cellObj.transform.parent = transform; ISkillCell skillCell = cellObj.GetComponent <ISkillCell>(); skillCell.Init(skillClass.castStageDataList[i], this); skillCell.SetAoeState(m_bIsAoe); AddSkillCell(cellObj); } // 删除原来的预警贴花 if (m_actor.m_WarningefxObj != null) { Destroy(m_actor.m_WarningefxObj); m_actor.m_WarningefxObj = null; } // 读取新的预警贴花 for (int i = 0; i < m_skillCellObjectlist.Count; i++) { ISkillCell skillCell = m_skillCellObjectlist[i].GetComponent <ISkillCell>(); skillCell.ShowSkillScope(); if (m_actor.m_WarningefxObj != null) { break; } } if (m_actor.m_WarningefxObj != null) { EfxAttachActionPool efx = m_actor.m_WarningefxObj.GetComponent <EfxAttachActionPool>(); if (efx == null) { efx = m_actor.m_WarningefxObj.AddComponent <EfxAttachActionPool>(); } efx.Init(m_actor.transform, 100000f, true); } }
//播放动画,特效,声音 IEnumerator PlayActionEfxSound(SkillPlayParam param, float delayTime) { if (m_actor == null) { yield break; } m_strActionName = param.action; if (m_strActionName != null && m_strActionName.Length > 0) { //动作带位移 的 不能延迟播放, 延迟播放将影响 位移曲线计算 m_actor.PlayAction(m_strActionName, false); m_actor.SetActionTime(m_strActionName, param.startTime); m_actor.SetSkillActionSpeed(m_strActionName, param.speed, m_skillDesc); } //其它玩家不播放了 if (m_actor.mActorType == ActorType.AT_REMOTE_PLAYER) { yield break; } if (m_actor.mActorType == ActorType.AT_PET) { PetObj pet = m_actor as PetObj; if (null != pet && pet.m_MasterActor != CoreEntry.gActorMgr.MainPlayer) { yield break; } } //播放声音 string sound1 = param.sound; string sound2 = param.voice; if (sound1 != null && sound1.Length > 0) { m_actor.StopSound(); m_actor.PlaySound(sound1); } if (sound2 != null && sound2.Length > 0) { m_actor.StopSound2(); m_actor.PlaySound2(sound2); } LuaTable skill_action = CoreEntry.gSkillMgr.GetSkillActon(m_skillID); if (skill_action == null) { Debug.LogError("==skill_action == is null m_skillID = " + m_skillID); yield break; } Vector3 efxPos = m_actor.transform.position; bool isBind = skill_action.Get <bool>("isBind"); int bindType = skill_action.Get <int>("skillEfxPos"); if (!isBind) { if (bindType == 1) { ActorObj target = m_actor.GetSelTarget(); if (null != target) { efxPos = target.transform.position; } } } if (delayTime > 0.0001f) { yield return(new WaitForSeconds(delayTime)); } //if (ByteToString.toString(m_skillDesc.szAttackEfxPrefab).Length > 0) if (param.actionEfx != null && param.actionEfx.Length > 0) { if (/*m_skillDesc.skilltype == 0 && */ m_actor.mActorType == ActorType.AT_BOSS) { yield return(new WaitForSeconds(m_actor.NoramalAttackEffectDelayTime)); } if (skill_action != null) { param.actionEfx = skill_action.Get <string>("skilleffect"); //efxObj = Instantiate(CoreEntry.gResLoader.LoadResource(param.actionEfx)) as GameObject;//CoreEntry.gGameObjPoolMgr.InstantiateEffect(param.actionEfx); efxObj = CoreEntry.gGameObjPoolMgr.InstantiateEffect(param.actionEfx); if (efxObj == null) { LogMgr.LogError("找不到attackEfxPrefab:" + skill_action.Get <string>("skilleffect") + " " + m_skillDesc.Get <string>("name")); } } float maxEfxTime = 0; if (skill_action.Get <float>("skillEfxLength") > 0) { maxEfxTime = skill_action.Get <float>("skillEfxLength"); } //LogMgr.UnityLog("maxEfxTime=" + maxEfxTime + ", " + m_strActionName); //特效存在时间 if (maxEfxTime <= 0.001) { maxEfxTime = m_actor.GetActionLength(m_strActionName); if (maxEfxTime <= 0.001) { LogMgr.UnityError("技能 动作时间 没有配置 skillID:" + m_skillDesc.Get <int>("id")); } } bool isFollowMove = false; EfxAttachActionPool efx = efxObj.GetComponent <EfxAttachActionPool>(); if (efx == null) { efx = efxObj.AddComponent <EfxAttachActionPool>(); } if (efx != null) { efx.Init(m_actor.transform, maxEfxTime, isFollowMove); m_actionEfx = efx; if (isBind) { ActorObj bindActor = null; if (bindType == 0) { bindActor = m_actor; } else { bindActor = m_actor.GetSelTarget(); } Transform bindTran = null; if (null != bindActor) { string hangPoint = skill_action.Get <string>("hangPoint"); if (!string.IsNullOrEmpty(hangPoint)) { bindTran = bindActor.transform.FindChild(hangPoint); } if (null == bindTran) { bindTran = bindActor.transform; } } else { bindTran = m_actor.transform; } m_actionEfx.transform.parent = bindTran; m_actionEfx.transform.localPosition = Vector3.zero; m_actionEfx.transform.localScale = Vector3.one; m_actionEfx.transform.rotation = m_actor.transform.rotation; } else { if (bindType == 1) { m_actionEfx.transform.position = efxPos; } else { m_actionEfx.transform.position = m_actor.transform.position; } m_actionEfx.transform.localScale = Vector3.one; m_actionEfx.transform.rotation = m_actor.transform.rotation; } //设置有挂点的特效 Transform[] childTransform = efxObj.GetComponentsInChildren <Transform>(); //foreach (Transform childTrans in childTransform) for (int i = 0; i < childTransform.Length; ++i) { Transform childTrans = childTransform[i]; 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; m_attachEfxObjectlist.Add(childTrans.gameObject); } } //影子 ghostMesh[] ghostMesh = efx.GetComponentsInChildren <ghostMesh>(); if (ghostMesh.Length > 0) { 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; } } } } yield return(1); }
private void ShowBossSkillWarning() { if (null == m_actor || m_actor.mActorType != ActorType.AT_BOSS) { return; } if (null == m_skillDesc || null == m_skilleffect) { return; } int castSkillType = m_skillDesc.Get <int>("faction_limit"); if (castSkillType == 2) { return; } castSkillType = m_skillDesc.Get <int>("subtype"); if (castSkillType < (int)SkillType.SKILL_CHARGE || castSkillType > (int)SkillType.SKILL_BIGAOE) { LogMgr.UnityError(string.Format("skill:{0} has an invalid skill subtype:{1}", m_skillID, castSkillType)); return; } if (castSkillType == (int)SkillType.SKILL_NORMAL) { return; } int rangeType = m_skilleffect.Get <int>("range"); int param1 = m_skilleffect.Get <int>("distance"); int param2 = m_skilleffect.Get <int>("angle"); GameObject efxObj = null; Vector3 pos; bool isRectWarning = false; if (rangeType == (int)SkillRangeType.SKILL_TARGET || rangeType == (int)SkillRangeType.SKILL_TARGET_CIRCLE) { ActorObj target = m_actor.GetSelTarget(); if (null == target) { return; } pos = target.transform.position; efxObj = CoreEntry.gGameObjPoolMgr.InstantiateEffect("Effect/skill/remain/fx_yujing_yuan"); if (null != efxObj) { efxObj.transform.localRotation = Quaternion.identity; efxObj.transform.localScale = new Vector3(param1 * 2.0f, 1.0f, param1 * 2.0f); } } else { pos = m_actor.transform.position; if (rangeType == (int)SkillRangeType.SKILL_SELF_FUN) { efxObj = CoreEntry.gGameObjPoolMgr.InstantiateEffect("Effect/skill/remain/fx_yujing_shanxing"); if (null != efxObj) { efxObj.transform.rotation = m_actor.transform.rotation; efxObj.transform.localScale = new Vector3(param1, 1.0f, param1); } } else if (rangeType == (int)SkillRangeType.SKILL_SELF_RECT) { efxObj = CoreEntry.gGameObjPoolMgr.InstantiateEffect("Effect/skill/remain/fx_yujing_changfang"); if (null != efxObj) { efxObj.transform.rotation = m_actor.transform.rotation; efxObj.transform.localScale = new Vector3(param2, 1.0f, param1); } isRectWarning = true; } else if (rangeType == (int)SkillRangeType.SKILL_SELF_CIRCLE) { efxObj = CoreEntry.gGameObjPoolMgr.InstantiateEffect("Effect/skill/remain/fx_yujing_yuan"); if (null != efxObj) { efxObj.transform.localRotation = Quaternion.identity; efxObj.transform.localScale = new Vector3(param1 * 2.0f, 1.0f, param1 * 2.0f); } } } if (null == efxObj) { return; } efxObj.transform.position = pos; int delayTime = m_skilleffect.Get <int>("delay"); EfxAttachActionPool efx = efxObj.GetComponent <EfxAttachActionPool>(); if (efx == null) { efx = efxObj.AddComponent <EfxAttachActionPool>(); } if (efx != null) { efx.Init(null, delayTime * 0.001f + 0.5f); } Transform aniTransform = efxObj.transform.FindChild("liquan"); if (null != aniTransform) { if (isRectWarning) { aniTransform.localPosition = Vector3.zero; TweenPosition.Begin(aniTransform.gameObject, delayTime * 0.001f, Vector3.forward); } else { aniTransform.localScale = Vector3.zero; TweenScale.Begin(aniTransform.gameObject, delayTime * 0.001f, Vector3.one); } } }
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); } } }
public override void OnExit() { base.OnExit(); //boneEffect = GameObject.Instantiate(CoreEntry.gResLoader.LoadResource(effectPath)) as GameObject; if (string.IsNullOrEmpty(effectPath)) { return; } boneEffect = CoreEntry.gGameObjPoolMgr.InstantiateEffect(effectPath); if (boneEffect == null) { return; } EfxAttachActionPool efx = boneEffect.GetComponent <EfxAttachActionPool>(); if (efx == null) { efx = boneEffect.AddComponent <EfxAttachActionPool>(); } //if (effectDesc.fParam[1]!=0) // efx.Init(null, effectDesc.fParam[1]); //else efx.Init(null, 2f); // 默认两秒 if (sBindPos != "") { // 取得所有子Transform列表 Transform[] transforms = owner.gameObject.GetComponentsInChildren <Transform>(); for (int i = 0; i < transforms.Length; ++i) { if (transforms[i].name == sBindPos) { refNode = transforms[i]; boneEffect.transform.parent = transforms[i]; boneEffect.transform.localPosition = Vector3.zero; boneEffect.transform.localRotation = Quaternion.identity; break; } } } else { refNode = owner.transform; boneEffect.transform.parent = owner.transform; boneEffect.transform.localPosition = Vector3.zero; boneEffect.transform.localRotation = Quaternion.identity; } if (refNode == null) // 无绑定点 { // 没有绑定点的特效不继承旋转 refNode = owner.transform; boneEffect.transform.localPosition = new Vector3(refNode.transform.position.x, refNode.transform.position.y + 0.1f, refNode.transform.position.z); boneEffect.transform.localRotation = Quaternion.identity; boneEffect.transform.localScale = refNode.transform.localScale; } // 延时销毁特效 //GameObject.Destroy(boneEffect, effectDesc.fParam[0]); OnStealth(owner.m_bStealthState); }