예제 #1
0
        private IEnumerable <ResultPair> EvaluateSourceItem(SourcePair sourceItem, Period evalPeriod, IPeriodProfile evalProfile, IEnumerable <ResultPair> evalResults)
        {
            TargetItem targetInResult = sourceItem.Key;
            SourcePack sourceInResult = sourceItem.Value;

            IEnumerable <ResultPack> resultList = sourceInResult.OnSuccessToResultSetEvaluate(targetInResult, evalPeriod, evalProfile, evalResults, _evaluateResultsFunc);

            return(resultList.Select((r) => (new ResultPair(sourceItem.Key, r))).ToList());
        }
        protected override void OnReplaced(int collectionIndex, int index, TSource oldValue, TSource newValue)
        {
            var sourcePair = _rightKeys[index];

            Remove(sourcePair.Key, sourcePair.Value, _rightCount, _leftCount, OnRemovedFromRight);

            var key = _keySelector.Invoke(newValue);

            _rightKeys[index] = new SourcePair(key, newValue);
            Add(key, newValue, _rightCount, _leftCount, OnAddedToRight);
        }
예제 #3
0
    public AudioSource Play(Actor instigator, SoundCue sound, double time, float random, float random2, float random3, float random4, float random5)
    {
        if ((instigator != null) && (sound != null) && (sound.audioSourcePrefab != null))
        {
            MixerGroupState groupState;
            PlayingSource   playingSource;

            if (!CanPlay(instigator, instigator.go, sound, time, out groupState, out playingSource))
            {
                return(null);
            }

            var clip = sound.RandomClip(random, random2);
            if (clip != null)
            {
                AudioSource source = GameObject.Instantiate(sound.audioSourcePrefab);
                source.gameObject.name         = sound.name + "(" + clip.name + ")";
                source.transform.parent        = instigator.go.transform;
                source.transform.localPosition = Vector3.zero;
                source.transform.localRotation = Quaternion.identity;
                source.clip          = clip;
                source.volume        = sound.RandomVolume(random3);
                source.pitch         = sound.RandomPitch(random4);
                source.reverbZoneMix = sound.RandomReverb(random5);
                source.loop          = sound.loop;
                source.Play();

                if (groupState != null)
                {
                    groupState.hasPlayed    = true;
                    groupState.lastTime     = time;
                    playingSource.hasPlayed = true;
                    playingSource.lastTime  = time;
                    var sourcePair = new SourcePair();
                    sourcePair.audioSource   = source;
                    sourcePair.playingSource = playingSource;
                    playingSource.sources.Add(sourcePair);
                    groupState.activeSources.Add(sourcePair);
                    ++groupState.currentVoiceCount;
                }
                else
                {
                    source.gameObject.AddComponent <AudioSourceGC>();
                }

                return(source);
            }
        }

        return(null);
    }