示例#1
0
 void OnGenericValueChange(GenericValueSystem.ValueType Type, float Value)
 {
     //Debug.Log("value " + Type + " changed to " + Value);
     foreach (Action a in actions)
     {
         a.ForceValue(Value);
     }
 }
示例#2
0
        void OnValueChange(GenericValueSystem.ValueType Type, float Value)
        {
            if (onlyInsideCollider && !_insideCollider)
            {
                return;
            }
            if (sources != null && sources.Length > 0)
            {
                //int index = Mathf.FloorToInt(Mathf.Clamp(value_main,0,0.999f) * sources.Length);
                int index = System.Convert.ToInt32(MainValueCurve.Evaluate(Value) * multiplier * (sources.Length - 1));
                if (reverseOrder)
                {
                    index = (sources.Length - 1) - index;
                }

                for (int i = 0; i < sources.Length; i++)
                {
                    if (!sources[i] || !sources[i].gameObject.activeSelf || !sources[i].gameObject.activeInHierarchy)
                    {
                        continue;
                    }
                    bool changed = _playing[i] != (i == index);
                    _playing[i] = i == index;
                    //_soundManager.SetVolume(sources[i], volume * (_playing[i] ? 1 : (playMode == PlayMode.Continue ? 0 : 1)));
                    sources[i].volume = volume * (_playing[i] ? 1 : (playMode == PlayMode.Continue ? 0 : 1));
                    if (i == index && changed)
                    {
                        if (playMode == PlayMode.Reset)
                        {
                            sources[i].timeSamples = 0;
                            sources[i].Play();
                        }
                        if (playMode == PlayMode.Randomize)
                        {
                            sources[i].timeSamples = Mathf.FloorToInt(Random.value * sources[i].clip.samples);
                            sources[i].Play();
                        }
                    }
                }
            }
        }