Exemplo n.º 1
0
        void PlayDieSound()
        {
            string dieVoice = "";
            bool   ret      = AudioCore.GenerateAudio(m_actor.DieSound, ref dieVoice);

            if (ret && dieVoice.Length > 0)
            {
                m_actor.StopSound2();
                m_actor.PlaySound2(dieVoice);
            }
        }
Exemplo n.º 2
0
        //播放声音
        public void PlayBehitSound(ActorObj BeHitActor, ActorObj AttackActor, LuaTable skillDesc)
        {
            if (BeHitActor == null || AttackActor == null || skillDesc == null)
            {
                return;
            }

            if (!BeHitActor.IsMainPlayer() && !AttackActor.IsMainPlayer())
            {
                return;
            }


            m_actor = BeHitActor;
            bool ret = false;
            //if (AttackActor != null)
            //{
            //    //特效声音
            //    string behitSound = "";
            //    ret = AudioCore.GenerateAudio(skillDesc.Get<int>("behit_sound"), ref behitSound);
            //    if (ret && behitSound.Length > 0)
            //    {
            //        m_actor.StopSound();
            //        m_actor.PlaySound(behitSound);
            //    }
            //}

            //生物自己发声
            string behitVoice = "";

            ret = AudioCore.GenerateAudio(skillDesc.Get <int>("behit_sound"), ref behitVoice);
            if (ret && behitVoice.Length > 0)
            {
                m_actor.StopSound2();
                m_actor.PlaySound2(behitVoice);
            }
        }
Exemplo n.º 3
0
        //释放技能
        void CastSkill()
        {
            CancelInvoke("CastSkill");
            CancelInvoke("AutoLookatTarget");

            // 如果不是激活状态不往下运行
            if (!gameObject.activeInHierarchy)
            {
                return;
            }

            //释放吟唱阶段的动作特效
            SendEvent(SkillCellEventType.SE_DESTROY_ACTION_EFX, null);

            //销毁吟唱阶段数据
            DestroyEfx();

            //播放动作,特效,声音
            SkillPlayParam param        = new SkillPlayParam();
            LuaTable       skill_action = CoreEntry.gSkillMgr.GetSkillActon(m_skillID);

            if (skill_action == null)
            {
                Debug.LogError("skill_action is null...m_skillID = " + m_skillID);
                return;
            }
            if (skill_action != null)
            {
                param.action = skill_action.Get <string>("animation");

                param.actionEfx = skill_action.Get <string>("skilleffect");

                param.startTime = m_startPlayTimeSet;
                param.speed     = m_speed;

                param.remainEfx = skill_action.Get <string>("remain");
            }

            //播放声音
            string sound1 = "";
            string sound2 = "";

            AudioCore.GenerateAudio(m_skillDesc.Get <int>("sound_id"), ref sound1);
            AudioCore.GenerateAudio(m_skillDesc.Get <int>("talk_sound_id"), ref sound2);

            param.sound = sound1;
            param.voice = sound2;

            StartCoroutine(PlayActionEfxSound(param, skill_action.Get <float>("skillEfxDelay")));

            //技能元素
            SkillClassDisplayDesc skillClass = m_gameDBMgr.GetSkillClassDisplayDesc(m_skillDesc.Get <int>("skillDisplayID"));

            if (skillClass == null)
            {
                Debug.LogError("===skillClass== is null===");
                return;
            }
            bool isLocal = false;

            if (m_actor is PlayerObj || m_actor is PetObj)
            {
                isLocal = true;
            }
            for (int i = 0; i < skillClass.castStageDataList.Count; ++i)
            {
                if (null != m_actor && !isLocal)
                {
                    if (skillClass.castStageDataList[i] is MovePosAttackDesc)
                    {
                        continue;
                    }
                }

                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);

                CheckSkillCell(skillCell);
                AddSkillCell(cellObj);
            }

            //技能结束时间
            if (m_skillDesc.Get <int>("skill_end") > 0)
            {
                m_overTime = (m_skillDesc.Get <int>("skill_end") / 1000f - m_startPlayTimeSet) / m_speed;
            }
            else
            {
                m_overTime = (m_actor.GetActionLength(m_strActionName) - m_startPlayTimeSet) / m_speed;
            }

            //如果是不可打破机能,释放出后恢复动作
            if (canBeBroke == false)
            {
                float time = (m_actor.GetActionLength(m_strActionName) - m_startPlayTimeSet) / m_speed;
                CancelInvoke("SkillAnimationIsOver");
                Invoke("SkillAnimationIsOver", time);
            }
            LogMgr.UnityLog("overtime=" + m_overTime + ", skillid=" + m_skillID);

            //技能结束
            Invoke("SkillEnd", m_overTime);
        }
Exemplo n.º 4
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);
                }
            }
        }