Exemple #1
0
    /// <summary>
    /// 在指定的位置,播放指定名称的声音
    /// </summary>
    /// <param name="AudioNameID"></param>
    /// <param name="pos"></param>
    public void Play(string audioPath, Vector3 pos, bool is3D = false)
    {
        AudioClip audioClip = UnityEditor.AssetDatabase.LoadAssetAtPath <AudioClip>(string.Format("Assets/{0}", audioPath));

        if (audioClip == null)
        {
            return;
        }

        AudioInfo info = FindSameAudio(audioClip.name);

        if (info != null)
        {
            //如果缓存列表中 有相同的声音
            //更新其audioclip,确保其是最新的,非常重要!
            info.AudioName            = audioClip.name;
            info.CurrAudioSource.clip = audioClip;

            //开始播放
            info.Play(pos, is3D);
        }
        else
        {
            //移除过期的
            RemoveOverSound();

            //新建一个
            info = new AudioInfo(audioClip, gameObject);
            m_AudioList.Add(info);

            //开始播放
            info.Play(pos, is3D);
        }
    }
Exemple #2
0
    private void Play(string audioPath, string name, Vector3 pos, bool is3D = false)
    {
        AssetBundleManager.Instance.LoadOrDownload(audioPath, name, (AudioClip clip) =>
        {
            if (clip == null)
            {
                return;
            }
            AudioInfo info = FindSameAudio(clip.name);
            if (info != null)
            {
                info.AudioName = clip.name;
                info.CurrentAudioSource.clip = clip;
                info.Play(pos, is3D);
            }
            else
            {
                RemoveInvalidSound();

                info = new AudioInfo(clip, gameObject);
                m_AudioList.Add(info);

                info.Play(pos, is3D);
            }
        }, 0);
    }
    void MakeSardarFall(bool _shouldStayAtLastFrame, GameObject _animObj, AnimationClip _animClip)
    {
        bool          shouldStayAtLastFrame = _shouldStayAtLastFrame;
        GameObject    animobj = _animObj;
        AnimationClip clip    = _animClip;
        string        name    = clip.name;

        if (!shouldStayAtLastFrame)
        {
            animobj.animation.Play(name);

            //particle
            step_B_Objects_03_SardarParticle.Play(true);

            step_B_Objects_04_SardarAudioInfo.Play();
        }
        else
        {
            animobj.animation.Play(name);
            animobj.animation[name].time = animobj.animation[name].length;
        }
    }
    void Update()
    {
        #region Start
        if (step == 0)
        {
            timeCounter = step01_Driving_Time;

            step = 1;
        }
        #endregion

        #region Step01 Driving
        if (step == 1)
        {
            timeCounter = MathfPlus.DecByDeltatimeToZero(timeCounter);

            if (!isWoodDropSoundPlayed)
            {
                if (timeCounter < (step01_Driving_Time - timeToPlayWoodDrop))
                {
                    isWoodDropSoundPlayed = true;
                    woodDropAudInfo.Play();
                }
            }

            if (timeCounter == 0)
            {
                step = 2;
            }
        }
        #endregion

        #region Step02 Dezhbani
        if (step == 2)
        {
            timeCounter = step02_Dezhabni;

            step = 2.1f;
        }
        #endregion

        #region Step 2.1
        if (step == 2.1f)
        {
            timeCounter = MathfPlus.DecByDeltatimeToZero(timeCounter);

            #region AnimsWeight FirstDecreasement
            if ((timeCounter < (step02_Dezhabni - timeToDecAnimsWeight)) && (timeCounter >= (step02_Dezhabni - timeToIncAnimsWeightAgain)))
            {
                foreach (Animation ani in animsToChangeWeight)
                {
                    ani[ani.clip.name].weight = MathfPlus.DecByDeltatimeToZeroWithAdditionalCoef(ani[ani.clip.name].weight, animsWeightIncDecSpeed);
                }
            }
            #endregion

            #region AnimsWeight LastIncreasement
            if (timeCounter < (step02_Dezhabni - timeToIncAnimsWeightAgain))
            {
                foreach (Animation ani in animsToChangeWeight)
                {
                    ani[ani.clip.name].weight += Time.deltaTime * animsWeightIncDecSpeed;
                    ani[ani.clip.name].weight  = Mathf.Clamp01(ani[ani.clip.name].weight);
                }
            }
            #endregion

            #region Soldier Start
            if (!isSoldierRun)
            {
                if (timeCounter < (step02_Dezhabni - timeToRunSoldier))
                {
                    isSoldierRun = true;

                    soldier.SetActiveRecursively(true);
                    soldierLight.active = false;
                    soldier.animation.Play();
                }
            }
            #endregion

            #region Soldier End
            if (!isSoldierStopped)
            {
                if (timeCounter < (step02_Dezhabni - timeToEndSoldier))
                {
                    isSoldierStopped = true;

                    soldier.transform.position = new Vector3(1000, 1000, 1000);
                }
            }
            #endregion

            #region SoldierLight Start
            if (!isSoldierLightStarted)
            {
                if (timeCounter < (step02_Dezhabni - timeToStartSoldierLight))
                {
                    isSoldierLightStarted = true;

                    soldierLight.active = true;
                }
            }
            #endregion

            #region SoldierLight End
            if (!isSoldierLightStopped)
            {
                if (timeCounter < (step02_Dezhabni - timeToEndSoldierLight))
                {
                    isSoldierLightStopped = true;

                    soldierLight.active = false;
                }
            }
            #endregion

            #region PlayerAnim Start
            if (!isPlayerAnimStarted)
            {
                if (timeCounter < (step02_Dezhabni - timeToStartPlayerAnim))
                {
                    isPlayerAnimStarted = true;

                    palyerObjectForFearAnim.animation[palyerObjectForFearAnim.animation.clip.name].enabled = true;
                    palyerObjectForFearAnim.animation[palyerObjectForFearAnim.animation.clip.name].weight  = 0;
                }
            }
            #endregion

            #region PlayerAnim Run
            if (isPlayerAnimStarted && (timeCounter >= (step02_Dezhabni - timeToEndPlayerAnim)))
            {
                palyerObjectForFearAnim.animation[palyerObjectForFearAnim.animation.clip.name].weight += Time.deltaTime * animPlayerWeightIncDecSpeed;
                palyerObjectForFearAnim.animation[palyerObjectForFearAnim.animation.clip.name].weight  = Mathf.Clamp01(palyerObjectForFearAnim.animation[palyerObjectForFearAnim.animation.clip.name].weight);
            }
            #endregion

            #region PlayerAnim End
            if (!isPlayerAnimFinished)
            {
                if (timeCounter < (step02_Dezhabni - timeToEndPlayerAnim))
                {
                    palyerObjectForFearAnim.animation[palyerObjectForFearAnim.animation.clip.name].weight -= Time.deltaTime * animPlayerWeightIncDecSpeed;
                    palyerObjectForFearAnim.animation[palyerObjectForFearAnim.animation.clip.name].weight  = Mathf.Clamp01(palyerObjectForFearAnim.animation[palyerObjectForFearAnim.animation.clip.name].weight);

                    if (palyerObjectForFearAnim.animation[palyerObjectForFearAnim.animation.clip.name].weight == 0)
                    {
                        palyerObjectForFearAnim.animation[palyerObjectForFearAnim.animation.clip.name].enabled = false;
                        //palyerCameraToSlerp.GetComponent<MouseLook>().enabled = true;
                        palyerCameraToSlerp.GetComponent <TruckMapMouseLook>().RestartIt();
                        CustomInputManager.ResetInputAxes();
                        isPlayerAnimFinished = true;
                    }
                }
            }
            #endregion

            #region PlayerRotateLerp (All)
            if ((timeCounter < (step02_Dezhabni - timeToStartPlayerRotateLerp)) && timeCounter >= (step02_Dezhabni - timeToStopPlayerRotateLerp))
            {
                //palyerCameraToSlerp.GetComponent<MouseLook>().enabled = false;

                palyerCameraToSlerp.GetComponent <TruckMapMouseLook>().DisableIt();
                Quaternion toQuat = Quaternion.Euler(new Vector3(0, 270, 0));
                palyerCameraToSlerp.transform.localRotation = Quaternion.Slerp(palyerCameraToSlerp.transform.localRotation, toQuat, playerRotateLerpSpeed * Time.deltaTime);
            }
            #endregion

            #region AudiosVol FirstDecreasement
            if ((timeCounter < (step02_Dezhabni - timeToDecAudiosVolume)) && (timeCounter >= (step02_Dezhabni - timeToIncAudiosVolumeAgain)))
            {
                foreach (AudioInfo aud in audioInfosToChangeVolume)
                {
                    aud.SetCustomVolume(aud.customVolume - Time.deltaTime * audioDecIncSpeed);
                }
            }
            #endregion

            #region AudiosVol LastIncreasement
            if (timeCounter < (step02_Dezhabni - timeToIncAudiosVolumeAgain))
            {
                foreach (AudioInfo aud in audioInfosToChangeVolume)
                {
                    aud.SetCustomVolume(aud.customVolume + Time.deltaTime * audioDecIncSpeed);
                }
            }
            #endregion

            if (timeCounter == 0)
            {
                step = 3;
            }
        }
        #endregion

        #region 3 Start screen fading
        if (step == 3f)
        {
            MapLogic.Instance.blackScreenFader.StartFadingOut();

            step = 3.1f;
        }
        #endregion

        #region 3.1 W8 for finish
        if (step == 3.1f)
        {
            if (MapLogic.Instance.blackScreenFader.isFadingFinished)
            {
                SetMissionIsFinished();
                step = 4;
            }
        }
        #endregion
    }