示例#1
0
        public override void Process()
        {
            base.Process();
            float value = input.value;
            bool  flag  = value >= 0.5f;

            if (flag == knownState)
            {
                return;
            }
            knownState = flag;
            if (!flag || SignalManager.skipTransitions)
            {
                return;
            }
            GameObject gameObject = GameObject.Find(soundGameObjectName);

            if (gameObject != null)
            {
                sound2 = gameObject.GetComponent <Sound2>();
                if (sound2 != null)
                {
                    sound2.SetBaseVolume(0.35f);
                }
            }
        }
示例#2
0
        private void OnEnable()
        {
            if (showDebug)
            {
                Debug.Log(base.name + " Ran the Enable stuff ");
            }
            if (sound2 == null)
            {
                sound2 = GetComponentInChildren <Sound2>();
            }
            startPos = base.transform.position;
            startRot = base.transform.rotation;
            Vector3 size = GetComponent <BoxCollider>().size;

            if (size.x > size.y && size.x > size.z)
            {
                axis = Vector3.right * size.x;
            }
            else if (size.y > size.z)
            {
                axis = Vector3.up * size.y;
            }
            else
            {
                axis = Vector3.forward * size.z;
            }
            leftJoint  = AddJoint(-axis / 3f);
            rightJoint = AddJoint(axis / 3f);
        }
示例#3
0
        public SoundMaster GetMaster(Sound2 sound)
        {
            string key = sound.group + ":" + sound.name;

            map.TryGetValue(key, out SoundMaster value);
            return(value);
        }
 protected override void OnEnable()
 {
     base.OnEnable();
     if (sound2 == null)
     {
         sound2 = GetComponent <Sound2>();
     }
 }
示例#5
0
 protected void Awake()
 {
     priority = NodePriority.Update;
     sound2   = GetComponent <Sound2>();
     if (sound2 == null)
     {
         Debug.LogError("SignalSoundTrigger requires a sound", this);
     }
 }
示例#6
0
 protected override void Awake()
 {
     sound = GetComponent <Sound2>();
     if (sound == null)
     {
         unitySound = GetComponent <AudioSource>();
     }
     base.Awake();
 }
        private void FindSound()
        {
            GameObject gameObject = GameObject.Find(soundGameObjectName);

            if (gameObject != null)
            {
                sound2 = gameObject.GetComponent <Sound2>();
            }
        }
 private void Awake()
 {
     if (sound == null)
     {
         sound = GetComponent <Sound2>();
     }
     else if (unitySound == null)
     {
         unitySound = GetComponentInChildren <AudioSource>();
     }
 }
示例#9
0
 protected override void OnEnable()
 {
     base.OnEnable();
     if (sound2 == null)
     {
         GameObject gameObject = GameObject.Find(soundGameObjectName);
         if (gameObject != null)
         {
             sound2 = gameObject.GetComponent <Sound2>();
         }
     }
 }
示例#10
0
        public void Deserialize(Sound2 sound, GrainState grainState)
        {
            Grain grain = sound as Grain;

            if (!(grain == null))
            {
                grain.slowVolume = grainState.slowVolume;
                grain.slowPitch  = grainState.slowPitch;
                grain.frequencyAtMaxIntensity = grainState.frequency;
                grain.fastJitter = grainState.fastJitter;
                grain.slowJitter = grainState.slowJitter;
            }
        }
示例#11
0
 protected override void Awake()
 {
     if (showDebug)
     {
         Debug.Log(base.name + " Lerp Volume setting vars ");
     }
     sound = GetComponent <Sound2>();
     if (sound == null)
     {
         unitySound = GetComponent <AudioSource>();
     }
     base.Awake();
 }
示例#12
0
 private void Awake()
 {
     if (showDebug)
     {
         Debug.Log(base.name + " Awake ");
     }
     if (sound == null)
     {
         sound = GetComponentInChildren <Sound2>();
     }
     else if (unitySound == null)
     {
         unitySound = GetComponentInChildren <AudioSource>();
     }
 }
示例#13
0
        public void Save(bool saveMaster)
        {
            List <SoundState> list  = new List <SoundState>();
            List <GrainState> list2 = new List <GrainState>();

            if (type == SoundManagerType.Main)
            {
                list  = state.soundStateMap.Values.ToList();
                list2 = state.grainStateMap.Values.ToList();
            }
            else
            {
                for (int i = 0; i < sounds.Count; i++)
                {
                    Sound2 master = sounds[i].master;
                    Grain  grain  = master as Grain;
                    if (master.useMaster && saveMaster)
                    {
                        main.state.soundStateMap[master.fullName] = Serialize(sounds[i]);
                        if (grain != null)
                        {
                            main.state.grainStateMap[master.fullName] = Serialize(grain);
                        }
                    }
                    else
                    {
                        list.Add(Serialize(sounds[i]));
                        if (grain != null)
                        {
                            list2.Add(Serialize(grain));
                        }
                    }
                }
            }
            SoundManagerState soundManagerState = new SoundManagerState();

            soundManagerState.sounds = list.ToArray();
            soundManagerState.grains = list2.ToArray();
            SoundManagerState obj      = soundManagerState;
            string            contents = JsonUtility.ToJson(obj, prettyPrint: true);
            string            path     = GetPath(type);

            File.WriteAllText(path, contents);
            if (saveMaster)
            {
                main.Save(saveMaster: false);
            }
        }
示例#14
0
        private IEnumerator Start()
        {
            Sound2 sound = GetComponent <Sound2>();

            yield return(new WaitForSeconds(Random.Range(0f, maxDelay)));

            while (true)
            {
                if (sound.isPlaying)
                {
                    yield return(null);

                    continue;
                }
                sound.Play();
                yield return(new WaitForSeconds(Random.Range(minDelay, maxDelay)));
            }
        }
示例#15
0
 public void Deserialize(Sound2 sound, SoundState soundState, bool pasteSample)
 {
     if (pasteSample)
     {
         sound.SetSample(GetSample(soundState.sample));
     }
     sound.useMaster    = soundState.useMaster;
     sound.basePitch    = soundState.pitch;
     sound.baseVolume   = soundState.volume;
     sound.maxDistance  = soundState.maxDistance;
     sound.falloffStart = soundState.falloffStart;
     sound.falloffPower = soundState.falloffPower;
     sound.lpStart      = soundState.lpStart;
     sound.lpPower      = soundState.lpPower;
     sound.spreadNear   = soundState.spreadNear;
     sound.spreadFar    = soundState.spreadFar;
     sound.spatialNear  = soundState.spatialNear;
     sound.spatialFar   = soundState.spatialFar;
     sound.ApplyAttenuation();
 }
示例#16
0
        public static SoundState Serialize(SoundMaster master)
        {
            Sound2     master2    = master.master;
            SoundState soundState = new SoundState();

            soundState.id           = master2.group + ":" + master2.name;
            soundState.useMaster    = master2.useMaster;
            soundState.sample       = master2.sample;
            soundState.volume       = master2.baseVolume;
            soundState.pitch        = master2.basePitch;
            soundState.maxDistance  = master2.maxDistance;
            soundState.falloffStart = master2.falloffStart;
            soundState.falloffPower = master2.falloffPower;
            soundState.lpStart      = master2.lpStart;
            soundState.lpPower      = master2.lpPower;
            soundState.spreadNear   = master2.spreadNear;
            soundState.spreadFar    = master2.spreadFar;
            soundState.spatialNear  = master2.spatialNear;
            soundState.spatialFar   = master2.spatialFar;
            return(soundState);
        }
示例#17
0
 private void Awake()
 {
     sound = GetComponentInChildren <Sound2>();
 }