示例#1
0
        protected override void Start()
        {
            base.Start();
            Skill.Framework.Audio.PitchListener listener = GetComponent <Skill.Framework.Audio.PitchListener>();
            if (listener != null)
            {
                listener.RelinkAudios();
            }

            _InTransition = false;
            _NextState    = null;
            _ScheduleNextStateTW.End();
            if (_CurrentState != null)
            {
                if (_CurrentState.Clip != null)
                {
                    _CurrentState.Initialize(false);
                    _CurrentState.StartTime(1, 0);
                }

                if (_CurrentState.NextState != null)
                {
                    float deltaTime = _CurrentState.End - _CurrentState.Begin + 1;
                    if (deltaTime > BufferTime)
                    {
                        _ScheduleNextStateTW.Begin(deltaTime);
                    }
                    else
                    {
                        ScheduleNextState(deltaTime);
                    }
                }
            }
        }
示例#2
0
        public void Play(Texture movie)
        {
#if SUPPORTMOVIE
            if (_Fading != null)
            {
                _Fading.Alpha = 1.0f;
            }

            if (_LastMovie != null)
            {
                _LastMovie.Stop();
                if (_Audio != null && _LastMovie.audioClip != null)
                {
                    _Audio.Stop();
                    _Audio.clip = null;
                }
            }
            if (movie != null && movie is MovieTexture)
            {
                MovieTexture movieTexture = (MovieTexture)movie;

                _LastMovie = movieTexture;
                movieTexture.Play();
                if (_Audio != null && movieTexture.audioClip != null)
                {
                    _Audio.clip = movieTexture.audioClip;
                    _Audio.Play();
                }
                if (_Fading != null)
                {
                    _Fading.FadeToZero(true);
                    _MovieTW.Begin(Mathf.Max(movieTexture.duration - _Fading.FadeOutTime, _Fading.FadeOutTime + 0.1f));
                }
                else
                {
                    _MovieTW.Begin(movieTexture.duration);
                }

                _EndTW.End();
                _ImgMovie.Texture     = movie;// change texture
                _SavedCutSceneEnable  = Global.CutSceneEnable;
                Global.CutSceneEnable = CutSceneEnable;
                if (SceneFading != null)
                {
                    SceneFading.FadeToOne();
                }
                OnBegin();
            }
            else
            {
                _ImgMovie.Texture = null;
            }
            enabled = true;
#endif
        }
示例#3
0
 /// <summary>
 /// Create an instance of TimeLimitAccessKey
 /// </summary>
 /// <param name="accessKey">The Unique access key in BehaviorTree.</param>
 /// <param name="timeInterval">time interval between access to key</param>
 public TimeLimitAccessKey(string accessKey, float timeInterval)
     : base(accessKey)
 {
     this.TimeInterval = timeInterval;
     if (this.TimeInterval < 0.1f)
     {
         this.TimeInterval = 0.1f;
     }
     _Lock = false;
     _TimeTW.Begin(TimeInterval);
 }
示例#4
0
 /// <summary>
 /// Start
 /// </summary>
 protected override void Start()
 {
     base.Start();
     _LastFrameCount = Time.frameCount;
     _LastTime       = Time.realtimeSinceStartup;
     if (Coroutine)
     {
         StartCoroutine(FPSCoroutine());
     }
     else
     {
         _UpdateTW.Begin(Frequency);
     }
 }
示例#5
0
        private void ShowNext()
        {
            if (_CurrentSplashIndex >= 0 && _Fading != null)
            {
                // fadeout
                _Fading.FadeToOne();

                //prepare to change texture after fadeout
                _NextSplashTW.Begin(_Fading.FadeOutTime + 0.2f);
            }
            else
            {
                _NextSplashTW.Begin(0.2f);
            }
        }
示例#6
0
        /// <summary>
        /// Called by weapon when initialize bullet
        /// </summary>
        public virtual void StartJourney()
        {
            if (LifeTime > 0)
            {
                _LifeTimeTW.Begin(LifeTime);
            }
            enabled = true;
            _IsDead = false;

            if (TrailParticle != null && TrailPosition != null)
            {
                _TrailInstance = Skill.Framework.Managers.Cache.Spawn(TrailParticle, TrailPosition.position, TrailPosition.rotation);
                _TrailLifTime  = _TrailInstance.GetComponent <Skill.Framework.Managers.CacheLifeTime>();
                if (_TrailLifTime != null)
                {
                    _TrailLifTime.enabled = false;
                }
                _TrailInstance.transform.parent = TrailPosition;
                _Particle = _TrailInstance.GetComponent <ParticleSystem>();
                _Particle.Clear(true);

                var emission = _Particle.emission;
                emission.enabled = true;
            }
        }
示例#7
0
 /// <summary>
 /// Update
 /// </summary>
 protected override void Update()
 {
     if (CleanInterval > 0)
     {
         if (_CleanTW.IsEnabled)
         {
             if (_CleanTW.IsOver)
             {
                 foreach (var item in Caches)
                 {
                     if (item != null)
                     {
                         item.Clean();
                     }
                 }
                 _CleanTW.End();
             }
         }
         else
         {
             _CleanTW.Begin(CleanInterval);
         }
     }
     base.Update();
 }
示例#8
0
 /// <summary>
 /// Notify chassis that a wheel is punctured
 /// </summary>
 /// <param name="puncturedWheel"> Punctured wheel </param>
 public virtual void NotifyWheelPuncture(PuncturableWheel puncturedWheel)
 {
     _Euler.Target += puncturedWheel.PunctureRotation;
     //transform.position -= new Vector3(0, wheel.DeadRadius, 0);
     _UpdateTW.Begin(PunctureSmoothing.SmoothTime + 0.5f);
     enabled = true;
 }
示例#9
0
 private void ScheduleNextState(double deltaTime)
 {
     if (_CurrentState != null)
     {
         float fdeltaTime = System.Convert.ToSingle(deltaTime);
         _CurrentState.EndTime(System.Math.Max(0, deltaTime - NextStateFix), 0);
         _NextState = FindState(_CurrentState.NextState);
         if (_NextState != null)
         {
             _NextStateTW.Begin(fdeltaTime);
             if (_NextState.Clip != null)
             {
                 _NextState.Initialize(false);
                 _NextState.StartTime(fdeltaTime, 0);
             }
         }
     }
 }
示例#10
0
 public void Reschedule()
 {
     _StartTW.Begin(Delay, true);
     if (this._Renderer != null)
     {
         this._Renderer.enabled = false;
     }
     enabled = true;
 }
示例#11
0
 public void StartRain()
 {
     if (_IsRaining)
     {
         return;
     }
     _IsRaining = true;
     _RainAudio.Play();
     _Fading.FadeToZero();
     _Starting            = true;
     _Stopping            = false;
     RainLight.enabled    = true;
     Particle.minEmission = 0;
     Particle.maxEmission = 0;
     Particle.gameObject.SetActive(true);
     Specular.SpecularColor = Specular.DefaultColor;
     _FadeTW.Begin(_Fading.FadeInTime + 0.1f);
 }
示例#12
0
        private void EndMovie()
        {
            if (FastEscape)
            {
                _EndTW.Begin(0);
            }
            else if (_Fading != null)
            {
                _EndTW.Begin(_Fading.FadeOutTime + 0.1f);
            }
            else
            {
                _EndTW.Begin(0.1f);
            }

            if (_Fading != null)
            {
                _Fading.FadeToOne();
            }
            _MovieTW.End();
        }
示例#13
0
        private void TransitBy(AudioTransition transition)
        {
            if (transition.Destination != null)
            {
                _ActiveTransition = transition;

                double deltaTime = 0;
                bool   isPlaying = _CurrentState.IsPlaying;
                if (isPlaying)
                {
                    float time = _CurrentState.AudioTime;
                    if (_ActiveTransition.WaitForBreakPoint)
                    {
                        float breakPoint = FindNextBreakPoint(time + _ActiveTransition.FadeOut, _CurrentState.BreakPoints, _CurrentState.End);
                        deltaTime = breakPoint - time;
                    }
                    else
                    {
                        deltaTime = Mathf.Min(_ActiveTransition.FadeOut, _CurrentState.End - time);
                    }
                }

                if (_NextState != null)
                {
                    _NextState.Stop();
                }

                _InTransition = true;
                _NextState    = FindState(transition.Destination);

                float fdeltaTime = System.Convert.ToSingle(deltaTime);
                _NextStateTW.Begin(fdeltaTime);

                if (isPlaying)
                {
                    _CurrentState.EndTime(deltaTime, _ActiveTransition.FadeOut);
                }

                if (_NextState.Clip != null)
                {
                    _NextState.Initialize(_ActiveTransition.FadeIn > AudioState.MINFADETIME);
                    if (_ActiveTransition.CrossFade)
                    {
                        _UpdateNextStateTW.Begin(Mathf.Max(0, fdeltaTime - _ActiveTransition.FadeIn));
                        _NextState.StartTime(_UpdateNextStateTW.Length, _ActiveTransition.FadeIn);
                    }
                    else
                    {
                        _NextState.StartTime(deltaTime, _ActiveTransition.FadeIn);
                    }
                }
            }
        }
示例#14
0
 /// <summary>
 /// This function is called when the object becomes enabled and active.
 /// </summary>
 protected override void OnEnable()
 {
     base.OnEnable();
     if (!Continues)
     {
         _LifeTimeTW.Begin(LifeTime);
         float randomScale = Random.Range(MinScale, MaxScale);
         transform.localScale = new Vector3(randomScale, randomScale, randomScale);
     }
     if (Particle != null)
     {
         Managers.Cache.Spawn(Particle, transform.position, transform.rotation);
     }
 }
示例#15
0
        protected override void Update()
        {
            if (Global.IsGamePaused)
            {
                return;
            }
            if (_SoundTW.IsEnabledAndOver)
            {
                _SoundTW.End();
                Global.Instance.PlayOneShot(_Audio, Sounds[Random.Range(0, Sounds.Length)], Skill.Framework.Audio.SoundCategory.FX);
            }

            if (_IntervalTW.IsEnabledAndOver)
            {
                _ActiveCurve  = Curves[Random.Range(0, Curves.Length)];
                _CurveTime    = 0;
                _MaxCurveTime = _ActiveCurve[_ActiveCurve.length - 1].time;
                _SoundTW.Begin(_MaxCurveTime + 1);
                _PreIntensity  = SceneLight.intensity;
                _PreLightColor = SceneLight.color;
                Reschedule();
                if (LightingParticle != null)
                {
                    LightingParticle.Emit(1);
                }
            }
            else if (_ActiveCurve != null)
            {
                _CurveTime += Time.deltaTime * CurveSpeed;
                if (_CurveTime >= _MaxCurveTime)
                {
                    _ActiveCurve         = null;
                    SceneLight.intensity = _PreIntensity;
                    SceneLight.color     = _PreLightColor;
                }
                else
                {
                    float factor = _ActiveCurve.Evaluate(_CurveTime);
                    SceneLight.intensity = _PreIntensity + (factor * ExtraIntensity);
                    SceneLight.color     = Color.Lerp(_PreLightColor, LightColor, factor);
                }
            }

            base.Update();
        }
示例#16
0
        /// <summary>
        /// The GameObject dies and explosion happened
        /// </summary>
        /// <param name="sender"> The source of the event. </param>
        /// <param name="e"> An System.EventArgs that contains no event data. </param>
        protected virtual void Events_Die(object sender, System.EventArgs e)
        {
            Skill.Framework.Global.RaiseCameraShake(this, Shake, transform.position);

            if (ExpPrefab != null) // spawn explosion prefab
            {
                foreach (var item in ExpPositions)
                {
                    SpawnExplosionPrefab(item);
                }
            }
            if (DestroyDelay >= 0)
            {
                _DestroyTW.Begin(DestroyDelay);
                enabled = true;
            }
            else
            {
                enabled = false;
            }
        }
示例#17
0
 /// <summary>
 /// Update
 /// </summary>
 protected override void Update()
 {
     if (_IsBreaking)
     {
         if (_BreakDelay.IsOver)
         {
             Break();
             _BreakDelay.End();
             _IsBreaking = false;
             enabled = false;
         }
     }
     else if (Matinee != null && Matinee.IsPlaying)
     {
         if (Matinee.PlaybackTime > StartDelay)
         {
             if (Input.GetKey(BreakKey))
             {
                 if (!_KeyHoldTW.IsEnabled)
                 {
                     _KeyHoldTW.Begin(KeyHoldTime);
                 }
                 else if (_KeyHoldTW.IsEnabledAndOver)
                 {
                     _KeyHoldTW.End();
                     BreakStart();
                     _BreakDelay.Begin(Delay);
                     _IsBreaking = true;
                 }
             }
             else
             {
                 _KeyHoldTW.End();
             }
         }
     }
     base.Update();
 }
示例#18
0
        public void Fire()
        {
            if (BulletPrefab != null && _Clip != null)
            {
                _MoveTimeTW.Begin(LifeTime);
                _BulletDirection = -transform.forward;

                _BulletStartPosition = transform.position + transform.forward * BulletDistance;

                if (BulletPrefab != null)
                {
                    GameObject go = Skill.Framework.Managers.Cache.Spawn(BulletPrefab, _BulletStartPosition, Quaternion.LookRotation(_BulletDirection));
                    _BulletObject = go.transform;
                }

                if (IndicatorPrefab != null)
                {
                    GameObject go = Skill.Framework.Managers.Cache.Spawn(IndicatorPrefab, transform.position, IndicatorPrefab.transform.rotation);
                    Skill.Framework.Effects.ExplosionIndicator indicator = go.GetComponent <Skill.Framework.Effects.ExplosionIndicator>();
                    if (indicator != null)
                    {
                        indicator.LifeTime = LifeTime;
                        indicator.Radius   = ExplosionRadius;
                        indicator.Show();
                    }
                }

                if (AudioSource != null)
                {
                    AudioSource.PlayOneShot(_Clip);
                }
            }
            else
            {
                Debug.LogWarning("Invalid Mortar parameters");
            }
        }
示例#19
0
 private void Reschedule()
 {
     _IntervalTW.Begin(Random.Range(Interval * 0.6f, Interval));
 }
示例#20
0
文件: Weapon.cs 项目: TagsRocks/skill
        /// <summary>
        /// Update
        /// </summary>
        protected override void Update()
        {
            if (Global.IsGamePaused)
            {
                return;
            }
            if (_BusyTW.IsEnabledAndOver)
            {
                _BusyTW.End();
                if (State == WeaponState.Reloading)
                {
                    OnReloadCompleted();
                }
                else if (State == WeaponState.ChangeProjectile)
                {
                    OnProjectileChanged(_SelectedProjectileIndex, _SwitchProjectileIndex);
                    _SelectedProjectileIndex = _SwitchProjectileIndex;
                }
                State = WeaponState.Ready;
            }

            if (State == WeaponState.Ready)
            {
                if (_RequestReload && (SelectedProjectile.Ammo > 0 || SelectedProjectile.InfinitClip || SelectedProjectile.InfinitAmmo))
                {
                    bool completeReload = SelectedProjectile.ClipAmmo == 0;
                    if (completeReload)
                    {
                        _BusyTW.Begin(SelectedProjectile.CompleteReloadTime);
                    }
                    else
                    {
                        _BusyTW.Begin(SelectedProjectile.ReloadTime);
                    }

                    State          = WeaponState.Reloading;
                    _RequestReload = false;
                    OnReload(completeReload);
                }
                else if (_RequestBusy > 0)
                {
                    _BusyTW.Begin(_RequestBusy);
                    State        = WeaponState.Busy;
                    _RequestBusy = 0;
                }
                else if (_SwitchProjectileIndex != _SelectedProjectileIndex)
                {
                    _BusyTW.Begin(SelectedProjectile.EquipTime);
                    State = WeaponState.ChangeProjectile;
                }
                else if (IsFiring)
                {
                    if (SelectedProjectile.ClipAmmo < 0)
                    {
                        SelectedProjectile.ClipAmmo = 0;
                    }
                    if (SelectedProjectile.ClipAmmo == 0)
                    {
                        if (AutoReload)
                        {
                            if (!RequestReload())
                            {
                                PlayEmptySound();
                            }
                            else
                            {
                                IsFiring = false;
                            }
                        }
                        else
                        {
                            PlayEmptySound();
                            IsFiring = false;
                        }
                    }
                    else
                    {
                        OnShoot();

                        if (SelectedProjectile.ClipAmmo == 0)
                        {
                            if (AutoReload)
                            {
                                RequestReload();
                                _ShootCount = 0;
                            }
                        }
                        else
                        {
                            _BusyTW.Begin(SelectedProjectile.FireInterval);
                            State = WeaponState.Refill;
                        }
                        _ShootCount++;
                        int mode = this.Automatic;
                        if (mode > 0 && _ShootCount >= mode)
                        {
                            if (AutoStopFire)
                            {
                                StopFire();
                            }
                            IsFiring = false;
                        }
                    }
                }
                else if (AutoReload && SelectedProjectile.ClipAmmo == 0)
                {
                    if (!_RequestReload)
                    {
                        RequestReload();
                        _ShootCount = 0;
                    }
                }
            }

            base.Update();
        }
示例#21
0
 /// <summary>
 /// called when the Collider other enters the trigger.
 /// </summary>
 /// <param name="other">other Collider</param>
 /// <returns>True if event handled, otherwise false</returns>
 protected override bool OnEnter(Collider other)
 {
     _DelayTW.Begin(Delay);
     enabled = true;
     return(true);
 }
示例#22
0
 public override void Show()
 {
     this.gameObject.SetActive(true);
     _InTW.Begin(InDelay);
 }
示例#23
0
        private void MoveNext()
        {
            _NextSplashTW.End();
            // stop previous movie
#if SUPPORTMOVIE
            if (_CurrentSplashIndex >= 0)
            {
                if (Images[_CurrentSplashIndex].Image is MovieTexture)
                {
                    MovieTexture movie = (MovieTexture)Images[_CurrentSplashIndex].Image;
                    movie.Stop();
                    if (_Audio != null && movie.audioClip != null)
                    {
                        _Audio.Stop();
                        _Audio.clip = null;
                    }
                }
            }
#endif

            _CurrentSplashIndex++;                   // go next splash
            if (_CurrentSplashIndex < Images.Length) // if another splash exist
            {
#if SUPPORTMOVIE
                if (Images[_CurrentSplashIndex].Image is MovieTexture)
                {
                    MovieTexture movie = (MovieTexture)Images[_CurrentSplashIndex].Image;
                    movie.Play();
                    if (_Audio != null && movie.audioClip != null)
                    {
                        _Audio.clip = movie.audioClip;
                        _Audio.Play();
                    }
                    if (FullScreenMovies)
                    {
                        SetSize(1.0f, 1.0f, Images[_CurrentSplashIndex].Scale);
                    }
                    else
                    {
                        SetSize(Images[_CurrentSplashIndex].WidthPercent, Images[_CurrentSplashIndex].HeightPercent, Images[_CurrentSplashIndex].Scale);
                    }

                    if (_Fading != null)
                    {
                        _Fading.FadeToZero(true);
                        _SplashTW.Begin(Mathf.Max(movie.duration - _Fading.FadeOutTime, Images[_CurrentSplashIndex].MaxDuration - _Fading.FadeOutTime, _Fading.FadeOutTime + 0.1f));
                    }
                    else
                    {
                        _SplashTW.Begin(Mathf.Max(movie.duration - 0.1f, Images[_CurrentSplashIndex].MaxDuration - 0.1f, 0.1f));
                    }
                }
                else
                {
#endif
                SetSize(Images[_CurrentSplashIndex].WidthPercent, Images[_CurrentSplashIndex].HeightPercent, Images[_CurrentSplashIndex].Scale);
                if (_Fading != null)
                {
                    _Fading.FadeToZero(true);
                    _SplashTW.Begin(Mathf.Max(Images[_CurrentSplashIndex].MaxDuration - _Fading.FadeOutTime, _Fading.FadeOutTime + 0.1f));
                }
                else
                {
                    _SplashTW.Begin(Mathf.Max(Images[_CurrentSplashIndex].MaxDuration - 0.1f, 0.1f));
                }
#if SUPPORTMOVIE
            }
#endif

                _ImgSplash.Texture = Images[_CurrentSplashIndex].Image;// change texture
            }
            else
            {
                if (_Fading != null)
                {
                    _Fading.Alpha = 1.0f;
                }
                _ImgSplash.Texture = null;
            }
        }
示例#24
0
 public override void Hide()
 {
     _OutTW.Begin(OutDelay);
     OnOut();
 }
示例#25
0
 /// <summary>
 /// On Enable
 /// </summary>
 protected override void OnEnable()
 {
     base.OnEnable();
     _LifeTimeTW.Begin(LifeTime);
 }
示例#26
0
        /// <summary>
        /// Render ListBox
        /// </summary>
        protected override void Render()
        {
            bool selectionChange = CheckForRemovedSelectedItems();

            // we need to check event here because render called inside scroll view and mouse position is in scrollview space
            Event e = Event.current;

            if (e != null)
            {
                if (e.isMouse && e.type == EventType.MouseDown && e.button == 0)
                {
                    Vector2 mousePos   = e.mousePosition;
                    Vector2 localMouse = mousePos - _ScrollPosition;
                    Rect    ra         = RenderAreaShrinksByPadding;
                    if (ra.Contains(localMouse))
                    {
                        for (int i = 0; i < Controls.Count; i++)
                        {
                            var  c   = Controls[i];
                            Rect cRA = c.RenderArea;
                            if (cRA.Contains(mousePos))
                            {
                                if (SelectionMode == SelectionMode.Single)
                                {
                                    if (!_SelectedItems.Contains(c))
                                    {
                                        _SingleSelectedCandidateIndex         = i;
                                        _SingleSelectedCandidateMousePosition = mousePos;
                                        _SingleSelectedCandidate      = c;
                                        _SingleSelectedDeltaTouchMove = Vector2.zero;
                                        _DoubleClickTW.Begin(DoubleClickInterval, true);
                                    }
                                    else
                                    {
                                        if (_DoubleClickTW.IsEnabledButNotOver)
                                        {
                                            OnSelectedDoubleClick();
                                        }
                                        else
                                        {
                                            _DoubleClickTW.Begin(DoubleClickInterval, true);
                                        }
                                    }
                                }
                                else if (SelectionMode == SelectionMode.Multiple)
                                {
                                    if (_SelectedItems.Contains(c))
                                    {
                                        _SelectedItems.Remove(c);
                                    }
                                    else
                                    {
                                        _SelectedItems.Add(c);
                                    }
                                    selectionChange = true;
                                }
                                else //if (SelectionMode == SelectionMode.Extended)
                                {
                                    if (e.modifiers == EventModifiers.Shift)
                                    {
                                        int firstSelectedIndex = i;
                                        // find first selected item after this item
                                        for (int j = i + 1; j < Controls.Count; j++)
                                        {
                                            if (_SelectedItems.Contains(Controls[j]))
                                            {
                                                firstSelectedIndex = j;
                                                break;
                                            }
                                        }

                                        if (firstSelectedIndex > i)
                                        {
                                            _SelectedItems.Clear();
                                            for (int k = i; k <= firstSelectedIndex; k++)
                                            {
                                                _SelectedItems.Add(Controls[k]);
                                            }
                                            selectionChange = true;
                                            break;
                                        }
                                        else
                                        {
                                            int lastSelectedIndex = i;
                                            // find last selected item before this item
                                            for (int j = i - 1; j >= 0; j--)
                                            {
                                                if (_SelectedItems.Contains(Controls[j]))
                                                {
                                                    lastSelectedIndex = j;
                                                    break;
                                                }
                                            }

                                            if (lastSelectedIndex < i)
                                            {
                                                _SelectedItems.Clear();
                                                for (int k = i; k >= lastSelectedIndex; k--)
                                                {
                                                    _SelectedItems.Add(Controls[k]);
                                                }
                                                selectionChange = true;
                                                break;
                                            }
                                        }
                                    }
                                    else if (e.modifiers == EventModifiers.Control)
                                    {
                                        if (_SelectedItems.Contains(c))
                                        {
                                            _SelectedItems.Remove(c);
                                        }
                                        else
                                        {
                                            _SelectedItems.Add(c);
                                        }
                                        selectionChange = true;
                                    }
                                    else
                                    {
                                        if (!_SelectedItems.Contains(c))
                                        {
                                            _SelectedItems.Clear();
                                            _SelectedItems.Add(c);
                                            selectionChange = true;
                                        }
                                        else if (_SelectedItems.Count > 1)
                                        {
                                            _SelectedItems.Clear();
                                            _SelectedItems.Add(c);
                                            selectionChange = true;
                                        }
                                    }
                                }
                                break;
                            }
                        }
                    }
                }
                else if (SelectionMode == UI.SelectionMode.Single)
                {
                    if (e.isMouse && e.type == EventType.mouseUp && e.button == 0)
                    {
                        if (_SingleSelectedCandidate != null)
                        {
                            if ((Orientation == UI.Orientation.Vertical && Mathf.Abs(e.mousePosition.y - _SingleSelectedCandidateMousePosition.y) < _SingleSelectedCandidate.Height * 0.5f) ||
                                (Orientation == UI.Orientation.Horizontal && Mathf.Abs(e.mousePosition.x - _SingleSelectedCandidateMousePosition.x) < _SingleSelectedCandidate.Width * 0.5f))
                            {
                                _SelectedItems.Clear();
                                _SelectedItems.Add(_SingleSelectedCandidate);
                                _SelectedIndex  = _SingleSelectedCandidateIndex;
                                selectionChange = true;
                            }
                        }
                        _SingleSelectedCandidate = null;
                    }
                }
            }

            if (selectionChange)
            {
                Focus();
                OnSelectionChanged();
            }

            if (_SelectedItems.Count > 0)
            {
                if (SelectedStyle == null)
                {
                    SelectedStyle = GUI.skin.box;
                }

                Rect boxRA = RenderAreaShrinksByPadding;
                if (Orientation == UI.Orientation.Vertical)
                {
                    boxRA.x     += 1;
                    boxRA.width -= 2;
                }
                else
                {
                    boxRA.y      += 1;
                    boxRA.height -= 2;
                }
                foreach (var c in _SelectedItems)
                {
                    Rect      cRA     = c.RenderArea;
                    Thickness cMargin = c.Margin;

                    if (Orientation == UI.Orientation.Vertical)
                    {
                        cRA.x     = boxRA.x;
                        cRA.width = boxRA.width;

                        cRA.y      -= cMargin.Top;
                        cRA.height += cMargin.Vertical;
                    }
                    else
                    {
                        cRA.x     -= cMargin.Left;
                        cRA.width += cMargin.Horizontal;

                        cRA.y      = boxRA.y;
                        cRA.height = boxRA.height;
                    }

                    GUI.Box(cRA, string.Empty, SelectedStyle);
                }
            }

            base.Render();
        }
示例#27
0
 /// <summary>
 /// Change pitch for specific time than fallback
 /// </summary>
 /// <param name="targetPitch">Target pitch</param>
 /// <param name="length">lenght of change</param>
 /// <param name="realtime"> use realtime or gametime?</param>
 public void Change(float targetPitch, float length, bool realtime = true)
 {
     _PrePitch = Pitch;
     Pitch     = targetPitch;
     _PitchTimeTW.Begin(length, realtime);
 }