public EntityDataFollower() : base()
 {
     Follow    = null;
     Offset    = Vector3.zero;
     Scale     = Vector3.one;
     ShowSound = EnumSound.None;
 }
    private static bool CanPlaySound(EnumSound sound)
    {
        switch (sound)
        {
        default:
            return(true);

        case EnumSound.PlayerMove:
            if (soundTimerDictionary.ContainsKey(sound))
            {
                float lastTimePlayed     = soundTimerDictionary[sound];
                float playerMoveTimerMax = .15f;
                if (lastTimePlayed + playerMoveTimerMax < Time.time)
                {
                    soundTimerDictionary[sound] = Time.time;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }
    }
 public override void Clear()
 {
     base.Clear();
     Follow    = null;
     Offset    = Vector3.zero;
     Scale     = Vector3.one;
     ShowSound = EnumSound.None;
 }
        public static EntityDataFollower Create(Transform follow, EnumSound enumSound, object userData = null)
        {
            EntityDataFollower entityData = ReferencePool.Acquire <EntityDataFollower>();

            entityData.Follow    = follow;
            entityData.ShowSound = enumSound;
            entityData.UserData  = userData;
            return(entityData);
        }
Exemple #5
0
        public static int?PlaySound(this SoundComponent soundComponent, EnumSound enumSound, Entity bindingEntity = null, object userData = null)
        {
            if (enumSound == EnumSound.None)
            {
                return(null);
            }

            return(soundComponent.PlaySound((int)enumSound, bindingEntity, userData));
        }
        public static EntityDataFollower Create(EnumSound enumSound, Vector3 position, Quaternion rotation, object userData = null)
        {
            EntityDataFollower entityData = ReferencePool.Acquire <EntityDataFollower>();

            entityData.ShowSound = enumSound;
            entityData.Position  = position;
            entityData.Rotation  = rotation;
            entityData.UserData  = userData;
            return(entityData);
        }
Exemple #7
0
        public static int?PlayMusic(this SoundComponent soundComponent, EnumSound enumSound, object userData = null)
        {
            if (enumSound == EnumSound.None)
            {
                return(null);
            }

            soundComponent.StopMusic();
            s_MusicSerialId = soundComponent.PlaySound((int)enumSound, null, userData);

            return(s_MusicSerialId);
        }
 private static AudioClip GetAudioClip(EnumSound sound)
 {
     foreach (GameAssets.SoundAudioClip soundAudioClip in GameAssets.i.soundAudioClipArray)
     {
         if (soundAudioClip.sound == sound)
         {
             return(soundAudioClip.audioClip);
         }
     }
     Debug.LogError("Sound " + sound + " not found!");
     return(null);
 }
 //playsound without time
 public static void PlaySound(EnumSound sound)
 {
     if (CanPlaySound(sound))
     {
         oneShotAudioSource.Stop();
         if (sound == EnumSound.PlayerMove)
         {
             oneShotAudioSource.loop = true;
         }
         else
         {
             oneShotAudioSource.loop = false;
         }
         oneShotAudioSource.PlayOneShot(GetAudioClip(sound));
     }
 }
 //this is a 3d sound
 public static void PlaySound(EnumSound sound, Vector3 position)
 {
     if (CanPlaySound(sound))
     {
         GameObject soundGameObject = new GameObject("Sound");
         soundGameObject.transform.position = position;
         AudioSource audioSource = soundGameObject.AddComponent <AudioSource>();
         audioSource.clip         = GetAudioClip(sound);
         audioSource.maxDistance  = 100f;
         audioSource.spatialBlend = 1f;
         audioSource.rolloffMode  = AudioRolloffMode.Linear;
         audioSource.dopplerLevel = 0f;
         audioSource.Play();
         //getting the length of the audio clip for delete
         Object.Destroy(soundGameObject, audioSource.clip.length);
     }
 }
Exemple #11
0
 /**
  * This class manage the states in the whole game (menus and minigame)
  *
  */
 public void onPlaySound(EnumSound name, Vector3 pos)
 {
     AudioSource.PlayClipAtPoint(soundList[name], pos);
 }
        public static EntityDataFollower Create(Transform follow, Vector3 offset, Vector3 scale, EnumSound enumSound, Vector3 position, Quaternion rotation, object userData = null)
        {
            EntityDataFollower entityData = ReferencePool.Acquire <EntityDataFollower>();

            entityData.Follow    = follow;
            entityData.Offset    = offset;
            entityData.Scale     = scale;
            entityData.ShowSound = enumSound;
            entityData.Position  = position;
            entityData.Rotation  = rotation;
            entityData.UserData  = userData;
            return(entityData);
        }