示例#1
0
        //播放动画,特效,声音
        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);
        }
示例#2
0
        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);
                }
            }
        }