Пример #1
0
        private IEnumerator PositionCubimalSequence()
        {
            _cubimal.PositionForRace();

            float seconds = 0f;

            while (seconds < POSITION_SECONDS)
            {
                float ratio = seconds / POSITION_SECONDS;
                _cubimal.transform.position = Vector3.Lerp(_cubimal.transform.position, transform.position, ratio);
                _cubimal.transform.rotation = Quaternion.Slerp(_cubimal.transform.rotation, transform.rotation, ratio);

                seconds += Time.deltaTime;

                yield return(null);
            }

            if (_cubimal != null)
            {
                if (!_cubimal.IsWound)
                {
                    yield return(_cubimal.AutoWind(WIND_SECONDS));
                }
            }

            _state = RaceTrackState.Set;

            if (_cubimal != null)
            {
                OnCubimalAdded?.Invoke();
            }

            _positionSequence = null;
        }
Пример #2
0
        public void StartRace()
        {
            _state = RaceTrackState.Racing;

            if (_cubimal != null)
            {
                _cubimal.StartRace(_destination.position);
            }
        }
Пример #3
0
        private void RemoveCubimal()
        {
            _state = RaceTrackState.Ready;

            _cubimal.OnPickedUp -= HandleCubimalPickedUp;
            _cubimal.OnStopped  -= HandleCubimalStopped;
            _cubimal             = null;

            OnCubimalRemoved?.Invoke();
        }