コード例 #1
0
        /// <summary>
        /// Determines the next state this object should be in
        /// </summary>
        protected virtual void DetermineNextState()
        {
            switch (_currentState)
            {
            case AppearDisappearStates.Visible:
                _nextChangeIn = _visibleDuration;
                _nextState    = AppearDisappearStates.VisibleToHidden;
                _nextFeedback = VisibleToHiddenFeedback;
                break;

            case AppearDisappearStates.Hidden:
                _nextChangeIn = _hiddenDuration;
                _nextState    = AppearDisappearStates.HiddenToVisible;
                _nextFeedback = HiddenToVisibleFeedback;
                break;

            case AppearDisappearStates.HiddenToVisible:
                _nextChangeIn = _hiddenToVisibleDuration;
                _nextState    = AppearDisappearStates.Visible;
                _nextFeedback = VisibleFeedback;
                break;

            case AppearDisappearStates.VisibleToHidden:
                _nextChangeIn = _visibleToHiddenDuration;
                _nextState    = AppearDisappearStates.Hidden;
                _nextFeedback = HiddenFeedback;
                break;
            }
        }
コード例 #2
0
        /// <summary>
        /// Changes the state for the next in line
        /// </summary>
        public virtual void ChangeState()
        {
            if (((_nextState == AppearDisappearStates.HiddenToVisible) || (_nextState == AppearDisappearStates.Visible)) &&
                _characterInTriggerArea &&
                PreventAppearWhenCharacterInArea)
            {
                return;
            }

            if (((_nextState == AppearDisappearStates.VisibleToHidden) || (_nextState == AppearDisappearStates.Hidden)) &&
                _characterInTriggerArea &&
                PreventDisappearWhenCharacterInArea)
            {
                return;
            }

            _lastStateChangedAt = Time.time;
            _currentState       = _nextState;
            _nextFeedback?.PlayFeedbacks();
            RandomizeDurations();

            if (_currentState == AppearDisappearStates.Hidden)
            {
                UpdateBoundComponents(false);
            }

            if (_currentState == AppearDisappearStates.Visible)
            {
                UpdateBoundComponents(true);
            }

            DetermineNextState();
        }
コード例 #3
0
        /// <summary>
        /// On Init, we set our active state, grab components, and determine our next state
        /// </summary>
        protected virtual void Initialization()
        {
            _currentState       = InitialState;
            _lastStateChangedAt = Time.time;

            Active = (StartMode == StartModes.Automatic);

            if (_currentState == AppearDisappearStates.HiddenToVisible)
            {
                _currentState = AppearDisappearStates.Visible;
            }
            if (_currentState == AppearDisappearStates.VisibleToHidden)
            {
                _currentState = AppearDisappearStates.Hidden;
            }

            _animator   = this.gameObject.GetComponent <Animator>();
            _renderer   = this.gameObject.GetComponent <Renderer>();
            _collider   = this.gameObject.GetComponent <Collider>();
            _collider2D = this.gameObject.GetComponent <Collider2D>();

            RandomizeDurations();

            _visibleDuration += Random.Range(InitialOffset.x, InitialOffset.y);
            _hiddenDuration  += Random.Range(InitialOffset.x, InitialOffset.y);

            UpdateBoundComponents(_currentState == AppearDisappearStates.Visible);

            DetermineNextState();
        }