Exemplo n.º 1
0
        private void LateUpdate()
        {
            if (!(m_type == ActorType.Character) || !current)
            {
                return;
            }

            switch (m_playType)
            {
            case PlayType.Footstep:
            {
                if (m_stepCycle < m_nextStep)
                {
                    break;
                }
                m_nextStep = m_stepCycle + m_stepInterval;
                SoundPreset.PlayOneshot(m_source, current.footstepSound);
                break;
            }

            case PlayType.Jump:
                SoundPreset.PlayOneshot(m_source, current.jumpSound);
                break;

            case PlayType.Land:
                SoundPreset.PlayOneshot(m_source, current.landSound);
                break;

            default:
                break;
            }
            m_playType = PlayType.Footstep;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates sound preset from all the files in the folder.
        /// </summary>
        /// <param name="localSoundsFolderPath">Path inside "Content/Sounds/" folder.</param>
        /// <param name="throwExceptionIfNoFilesFound"></param>
        /// <returns></returns>
        public static ReadOnlySoundPreset <TSoundKey> CreateFromFolder <TSoundKey>(
            string localSoundsFolderPath,
            bool throwExceptionIfNoFilesFound = true)
            where TSoundKey : struct, Enum
        {
            if (!localSoundsFolderPath.EndsWith("/"))
            {
                localSoundsFolderPath += "/";
            }

            var preset = new SoundPreset <TSoundKey>();

            foreach (var enumValue in EnumExtensions.GetValues <TSoundKey>())
            {
                preset.Add(enumValue, localSoundsFolderPath + enumValue.ToString());
            }

            var result = preset.ToReadOnly();

            if (throwExceptionIfNoFilesFound && result.SoundsCount == 0)
            {
                throw new Exception("No sounds found at " + localSoundsFolderPath);
            }

            return(result);
        }
Exemplo n.º 3
0
        private ReadOnlySoundPreset <WeaponSound> PrepareSoundPresetWeapon()
        {
            var preset = SoundPreset.CreateFromFolder <WeaponSound>(
                this.SoundsFolderPath + "/Weapon/",
                throwExceptionIfNoFilesFound: false);

            //this.VerifySoundPreset(preset);
            return(preset);
        }
Exemplo n.º 4
0
        private ReadOnlySoundPreset <CharacterSound> PrepareSoundPresetMovement()
        {
            var preset = SoundPreset.CreateFromFolder <CharacterSound>(
                this.SoundsFolderPath + "/Movement/",
                throwExceptionIfNoFilesFound: false);

            //this.VerifySoundPreset(preset);
            return(preset);
        }
Exemplo n.º 5
0
        protected virtual ReadOnlySoundPreset <GroundSoundMaterial> PrepareSoundPresetFootsteps()
        {
            var preset = SoundPreset.CreateFromFolder <GroundSoundMaterial>(
                this.SoundsFolderPath + "/Footsteps/",
                throwExceptionIfNoFilesFound: false);

            this.VerifySoundPreset(preset);
            return(preset);
        }
Exemplo n.º 6
0
 private void OnCollisionEnter(Collision collision)
 {
     if (m_rd3 && m_type != ActorType.RigidBody || !material)
     {
         return;
     }
     if ((collision.relativeVelocity.sqrMagnitude > m_minSpeed * m_minSpeed) && m_source)
     {
         SoundPreset.PlayOneshot(m_source, material.hitSound);
     }
 }
Exemplo n.º 7
0
        protected virtual ReadOnlySoundPreset <CharacterSound> PrepareSoundPresetCharacter()
        {
            if (!Api.Shared.IsFolderExists(ContentPaths.Sounds + this.SoundsFolderPath))
            {
                throw new Exception("Sounds folder for " + this + " doesn't exist");
            }

            var preset = SoundPreset.CreateFromFolder <CharacterSound>(
                this.SoundsFolderPath + "/Character/",
                throwExceptionIfNoFilesFound: false);

            //this.VerifySoundPreset(preset);
            return(preset);
        }
Exemplo n.º 8
0
        protected override ReadOnlySoundPreset <CharacterSound> PrepareSoundPresetCharacter()
        {
            if (!Api.Shared.IsFolderExists(ContentPaths.Sounds + this.SoundsFolderPath))
            {
                throw new Exception("Sounds folder for " + this + " doesn't exist");
            }

            var preset = SoundPreset.CreateFromFolder <CharacterSound>(
                this.SoundsFolderPath + "/Character/",
                throwExceptionIfNoFilesFound: false,
                customDistance: (15, 45),
                customDistance3DSpread: (10, 35));

            //this.VerifySoundPreset(preset);
            return(preset);
        }
Exemplo n.º 9
0
 // Update is called once per frame
 public void Play()
 {
     SoundPreset.PlayOneshot(audioSource, preset);
 }