private void OnTriggerStatusChanged(object sender, TwoBoundaryTriggerEventArgs args)
        {
            TwoBoundaryTriggerState triggerState = args.TriggerState;

            if (triggerState == TwoBoundaryTriggerState.End)
            {
                EjectBulletShell();
            }
        }
 protected override void Init()
 {
     base.Init();
     if (_angleEndBound < _angleStartBound)
     {
         Debug.LogError("End bound cannot be closer to starting point than the start bound.");
     }
     _angleEndBound   = Mathf.Clamp(_angleEndBound, 0, AngleLimit);
     _curTriggerState = TwoBoundaryTriggerState.Start;
 }
        /// <summary>
        /// Update the trigger state. If the current trigger state is "start" and
        /// rotation angle exceeds the angle end bound, the state is changed to
        /// "end" and event is triggered. If the current state is "end" and the
        /// rotation angle drops below the angle sstart bound, the state is changeed
        /// to "start" and event is triggered.
        /// </summary>
        /// <param name="currentAngle">Current angle of rotation.</param>
        private void UpdateTriggerState(float currentAngle)
        {
            switch (_curTriggerState)
            {
            case TwoBoundaryTriggerState.Start:
                if (currentAngle >= _angleEndBound)
                {
                    _curTriggerState = TwoBoundaryTriggerState.End;
                    OnTriggerStatusChanged();
                }
                break;

            case TwoBoundaryTriggerState.End:
                if (currentAngle <= _angleStartBound)
                {
                    _curTriggerState = TwoBoundaryTriggerState.Start;
                    OnTriggerStatusChanged();
                }
                break;
            }
        }
        /// <summary>
        /// Update the trigger state. If the state is "start" and the position of
        /// slider is beyond the end bound, the state is changed to "end" and the
        /// event is triggered. If the state is "end" and the position of the
        /// slider is below the start bound, the state is changed to "start" and the
        /// event is triggered.
        /// </summary>
        /// <param name="movementNormalized">Normalized value between 0 and 1
        /// representing the position along the linear moving axis. If the value
        /// is 0, it means the point is on the start position of the line. If
        /// it is 1, it means the point is on the end position of the line.</param>
        private void UpdateTriggerState(float movementNormalized)
        {
            switch (_curTriggerState)
            {
            case TwoBoundaryTriggerState.Start:
                if (movementNormalized >= _endBoundLinearDistanceNormalized)
                {
                    _curTriggerState = TwoBoundaryTriggerState.End;
                    OnTriggerStatusChanged();
                }
                break;

            case TwoBoundaryTriggerState.End:
                if (movementNormalized <= _startBoundLinearDistanceNormalized)
                {
                    _curTriggerState = TwoBoundaryTriggerState.Start;
                    OnTriggerStatusChanged();
                }
                break;
            }
        }
 public TwoBoundaryTriggerEventArgs(TwoBoundaryTriggerState state)
 {
     TriggerState = state;
 }