Пример #1
0
 /// <summary>
 /// Start a spline switch
 /// </summary>
 /// <param name="target">the target spline to switch to</param>
 /// <param name="targetTF">the target TF</param>
 /// <param name="duration">duration of the switch phase</param>
 public virtual void SwitchTo(CurvySpline target, float targetTF, float duration)
 {
     mSwitchStartTime      = Time.time;
     mSwitchDuration       = duration;
     mSwitchEventArgs      = new CurvySplineMoveEventArgs(this, target, null, targetTF, 0, Direction);
     mSwitchEventArgs.Data = 0f;
 }
        void onControllerEndReached(CurvySplineMoveEventArgs e)
        {
            FsmEventData eventData = new FsmEventData();

            _OnEndReachedEventData = e;
            this.FirePlayMakerEvent(SplineControllerOnEndReached, splineControllerOnEndReachedTarget, eventData);
            e = _OnEndReachedEventData;
        }
Пример #3
0
 // while we travel past CP's, we update the track
 public void Track_OnControlPointReached(CurvySplineMoveEventArgs e)
 {
     if (--mUpdateIn == 0)
     {
         mUpdateSpline = true;
         mUpdateIn     = SectionCPCount;
     }
 }
Пример #4
0
 void onSwitchEvent(CurvySplineMoveEventArgs e)
 {
     OnSwitch.Invoke(e);
     if (e.Cancel)
     {
         mSwitchEventArgs = null;
     }
 }
Пример #5
0
 // Retrieve metadata
 public void OnCPReached(CurvySplineMoveEventArgs e)
 {
     mPossibleSwitchTarget = e.ControlPoint.GetMetadata <SplineRefMetadata>();
     // if not properly configured, ignore!
     if (mPossibleSwitchTarget && !mPossibleSwitchTarget.Spline)
     {
         mPossibleSwitchTarget = null;
     }
 }
        protected override void getData(CurvySplineMoveEventArgs e)
        {
            base.getData(e);
            if (e == null)
            {
                return;
            }

            if (!StoreControlPoint.IsNone)
            {
                StoreControlPoint.Value = e.ControlPoint;
            }
        }
 /// <summary>
 /// Use a follow up, if present
 /// </summary>
 public static void UseFollowUpStatic(CurvySplineMoveEventArgs e)
 {
     // we need a SplineController as well as a following spline to work with
     if (e.Sender is SplineController && e.ControlPoint.FollowUp)
     {
         // Follow the connected spline
         e.Follow(e.ControlPoint.FollowUp, e.ControlPoint.FollowUpHeading);
         // Set the controller to use the new spline
         SplineController controller = (SplineController)e.Sender;
         controller.Spline = e.Spline;
         controller.RelativePosition = e.TF;
         // Handle controller events for the new passed ControlPoint
         controller.OnControlPointReached.Invoke(e);
     }
 }
 /// <summary>
 /// Use a follow up, if present
 /// </summary>
 public static void UseFollowUpStatic(CurvySplineMoveEventArgs e)
 {
     // we need a SplineController as well as a following spline to work with
     if (e.Sender is SplineController && e.ControlPoint.FollowUp)
     {
         // Follow the connected spline
         e.Follow(e.ControlPoint.FollowUp, e.ControlPoint.FollowUpHeading);
         // Set the controller to use the new spline
         SplineController controller = (SplineController)e.Sender;
         controller.Spline           = e.Spline;
         controller.RelativePosition = e.TF;
         // Handle controller events for the new passed ControlPoint
         controller.OnControlPointReached.Invoke(e);
     }
 }
Пример #9
0
        protected virtual void getData(CurvySplineMoveEventArgs e)
        {
            if (e == null)
            {
                return;
            }

            if (!StoreSpline.IsNone)
            {
                StoreSpline.Value = e.Spline;
            }
            if (!StoreGameObject.IsNone)
            {
                StoreGameObject.Value = e.Spline.gameObject;
            }
        }
Пример #10
0
 void onEndReachedEvent(CurvySplineMoveEventArgs e)
 {
     if (!(_active == this))
     {
         return;
     }
     if (e.Spline && e.Spline != Spline)
     {
         e.Spline.OnMoveEndReached.RemoveListener(onEndReachedEvent);
     }
     else
     {
         e.Sender = this;
         OnEndReached.Invoke(e);
     }
 }
Пример #11
0
        void OnCPReached(CurvySplineMoveEventArgs e)
        {
            var jc = e.ControlPoint.GetMetadata <MDJunctionControl>();

            if (jc)
            {
                if (jc.UseJunction)
                {
                    e.Follow(e.ControlPoint.Connection.OtherControlPoints(e.ControlPoint)[0]);
                    // Set the controller to use the new spline
                    SplineController controller = (SplineController)e.Sender;
                    controller.Spline           = e.Spline;
                    controller.RelativePosition = e.TF;
                }
            }
        }
Пример #12
0
        // A: Use Head To/Follow Up ControlPoint to proceed
        // B: Start Falling if any Control Point connected
        // C: Else Die!
        public void UseFollowUpOrFall(CurvySplineMoveEventArgs e)
        {
            // we need a SplineController as well as a following spline to work with
            if (e.Sender is SplineController)
            {
                if (e.ControlPoint.FollowUp)
                {
                    // Follow the connected spline
                    e.Follow(e.ControlPoint.FollowUp, e.ControlPoint.FollowUpHeading);
                    // Set the controller to use the new spline
                    SplineController controller = (SplineController)e.Sender;
                    controller.Spline           = e.Spline;
                    controller.RelativePosition = e.TF;
                    // handle controller events for the new passed ControlPoint
                    controller.OnControlPointReached.Invoke(e);
                }
                else
                {
                    if (e.ControlPoint.Connection)
                    {
                        var otherCP = e.ControlPoint.Connection.OtherControlPoints(e.ControlPoint)[0];
                        mFreeFallTarget = otherCP.Spline;
                        if (mMode == GuideMode.Jumping)
                        {
                            e.Follow(otherCP, ConnectionHeadingEnum.Auto);
                            Spline           = mFreeFallTarget;
                            RelativePosition = otherCP.LocalFToTF(0);
                            mNewMode         = GuideMode.FreeFall;
                        }
                        else
                        {
                            mMode = GuideMode.FreeFall;
                        }
                    }
                    else
                    {
                        Debug.Log("YOU DIED!");
#if UNITY_EDITOR
                        UnityEditor.EditorApplication.isPlaying = false;
#else
                        Application.Quit();
#endif
                    }
                }
            }
        }
Пример #13
0
        /// <summary>
        /// Refresh the controller and advance position
        /// </summary>
        public override void Refresh()
        {
            if (IsSwitching)
            {
                mSwitchEventArgs.Delta = Mathf.Clamp01((Time.time - mSwitchStartTime) / mSwitchDuration);
                if (OnSwitch.HasListeners())
                {
                    onSwitchEvent(mSwitchEventArgs);
                }
                else
                {
                    mSwitchEventArgs.Data = mSwitchEventArgs.Delta;
                }
            }
            base.Refresh();

            if (IsSwitching)
            {
                Vector3 targetPos;
                Vector3 targetTan;
                Vector3 targetUp;
                getInterpolatedSourcePosition(mSwitchEventArgs.Spline, mSwitchEventArgs.TF, out targetPos, out targetTan, out targetUp);

                if (Space == Space.Self)
                {
                    Transform.localPosition = Vector3.Lerp(Transform.localPosition, targetPos, (float)mSwitchEventArgs.Data);
                }
                else
                {
                    Transform.position = Vector3.Lerp(Transform.localPosition, targetPos, (float)mSwitchEventArgs.Data);
                }

                if (OrientationMode != OrientationModeEnum.None)
                {
                    //transform.localRotation = Quaternion.Lerp(transform.localRotation, GetRotation(tan, up), 1 - OrientationDamping);
                }

                if (mSwitchEventArgs.Delta == 1)
                {
                    Spline           = mSwitchEventArgs.Spline;
                    RelativePosition = mSwitchEventArgs.TF;
                    mSwitchEventArgs = null;
                }
            }
        }
        public void UseRandomConnectionStatic(CurvySplineMoveEventArgs e)
        {
            // we need a SplineController as well as a connection to work with
            if (e.Sender is SplineController && e.ControlPoint.Connection)
            {
                CurvySplineSegment current = e.ControlPoint;

                // Find a new spline to follow:
                // Get all connected ControlPoints and check angle
                var others = e.ControlPoint.Connection.OtherControlPoints(current);
                // If it's smaller or equal 90°, consider the connected spline as a valid path to follow, otherwise remove it from the list
                for (int i = others.Count - 1; i >= 0; i--)
                {
                    if (e.AngleTo(others[i]) > 90)
                    {
                        others.RemoveAt(i);
                    }
                }

                int randomIndex = Random.Range(-1, others.Count);

                if (randomIndex < 0) // don't follow another, but use FollowUp if present
                {
                    if (current.FollowUp)
                    {
                        e.Follow(current.FollowUp, current.FollowUpHeading);    // Follow the connected spline
                    }
                }
                else
                {
                    e.Follow(others[randomIndex]); // Follow the new spline
                }

                // Set the controller to use the new spline
                SplineController controller = (SplineController)e.Sender;
                controller.Spline           = e.Spline;
                controller.RelativePosition = e.TF;
            }
        }
        public void UseRandomConnectionStatic(CurvySplineMoveEventArgs e)
        {
            // we need a SplineController as well as a connection to work with
            if (e.Sender is SplineController && e.ControlPoint.Connection)
            {
                CurvySplineSegment current = e.ControlPoint;
                
                // Find a new spline to follow:
                    // Get all connected ControlPoints and check angle
                    var others = e.ControlPoint.Connection.OtherControlPoints(current);
                    // If it's smaller or equal 90°, consider the connected spline as a valid path to follow, otherwise remove it from the list
                    for (int i = others.Count - 1; i >= 0; i--)
                    {
                        if (e.AngleTo(others[i]) > 90)
                            others.RemoveAt(i);
                    }

                int randomIndex = Random.Range(-1, others.Count);

                if (randomIndex < 0) // don't follow another, but use FollowUp if present
                {
                    if (current.FollowUp)
                        e.Follow(current.FollowUp, current.FollowUpHeading);    // Follow the connected spline
                }
                else
                {
                    e.Follow(others[randomIndex]); // Follow the new spline
                }

                // Set the controller to use the new spline
                SplineController controller = (SplineController)e.Sender;
                controller.Spline = e.Spline;
                controller.RelativePosition = e.TF;

            }
        }
Пример #16
0
        // A: Use Head To/Follow Up ControlPoint to proceed
        // B: Start Falling if any Control Point connected
        // C: Else Die!
        public void UseFollowUpOrFall(CurvySplineMoveEventArgs e)
        {
            // we need a SplineController as well as a following spline to work with
            if (e.Sender is SplineController)
            {
                if (e.ControlPoint.FollowUp)
                {
                    // Follow the connected spline
                    e.Follow(e.ControlPoint.FollowUp, e.ControlPoint.FollowUpHeading);
                    // Set the controller to use the new spline
                    SplineController controller = (SplineController)e.Sender;
                    controller.Spline = e.Spline;
                    controller.RelativePosition = e.TF;
                    // handle controller events for the new passed ControlPoint
                    controller.OnControlPointReached.Invoke(e);
                }
                else
                {
                    if (e.ControlPoint.Connection){
                        var otherCP=e.ControlPoint.Connection.OtherControlPoints(e.ControlPoint)[0];
                        mFreeFallTarget = otherCP.Spline;
                        if (mMode==GuideMode.Jumping)
                        {
                            e.Follow(otherCP, ConnectionHeadingEnum.Auto);
                            Spline = mFreeFallTarget;
                            RelativePosition = otherCP.LocalFToTF(0);
                            mNewMode = GuideMode.FreeFall;
                        } else
                            mMode = GuideMode.FreeFall;

                    } else
                    {
                        Debug.Log("YOU DIED!");
#if UNITY_EDITOR
                        UnityEditor.EditorApplication.isPlaying = false;
#else                        
                        Application.Quit();
#endif
                    } 
                }
            }
        }
 /// <summary>
 /// Print some event details to the console
 /// </summary>
 /// <param name="e"></param>
 public static void DebugLogStatic(CurvySplineMoveEventArgs e)
 {
     Debug.Log(string.Format("Segment/TF/Direction: {0}/{1}/{2}", e.ControlPoint, e.TF, e.Direction));
 }
 public static void DebugLog(CurvySplineMoveEventArgs e)
 {
     DebugLogStatic(e);
 }
 public void UseRandomConnection(CurvySplineMoveEventArgs e)
 {
     UseRandomConnectionStatic(e);
 }
Пример #20
0
 void onEndReachedEvent(CurvySplineMoveEventArgs e)
 {
     if (!(_active == this))
         return;
     if (e.Spline && e.Spline != Spline)
         e.Spline.OnMoveEndReached.RemoveListener(onEndReachedEvent);
     else
     {
         e.Sender = this;
         OnEndReached.Invoke(e);
     }
 }
Пример #21
0
 void OnCPReached(CurvySplineMoveEventArgs e)
 {
     var jc = e.ControlPoint.GetMetadata<MDJunctionControl>();
     if (jc)
     {
         if (jc.UseJunction)
         {
             e.Follow(e.ControlPoint.Connection.OtherControlPoints(e.ControlPoint)[0]);
             // Set the controller to use the new spline
             SplineController controller = (SplineController)e.Sender;
             controller.Spline = e.Spline;
             controller.RelativePosition = e.TF;
         }
     }
 }
 public void UseFollowUp(CurvySplineMoveEventArgs e)
 {
     UseFollowUpStatic(e);
 }
 public void UseFollowUp(CurvySplineMoveEventArgs e)
 {
     UseFollowUpStatic(e);
 }
Пример #24
0
        /// <summary>
        /// Refresh the controller and advance position
        /// </summary>
        public override void Refresh()
        {
            if (IsSwitching)
            {
                mSwitchEventArgs.Delta = Mathf.Clamp01((Time.time - mSwitchStartTime) / mSwitchDuration);
                if (OnSwitch.HasListeners())
                    onSwitchEvent(mSwitchEventArgs);
                else
                    mSwitchEventArgs.Data = mSwitchEventArgs.Delta;
            }
            base.Refresh();

            if (IsSwitching)
            {
                Vector3 targetPos;
                Vector3 targetTan;
                Vector3 targetUp;
                getInterpolatedSourcePosition(mSwitchEventArgs.Spline, mSwitchEventArgs.TF, out targetPos, out targetTan, out targetUp);

                if (Space == Space.Self)
                    transform.localPosition = Vector3.Lerp(transform.localPosition, targetPos, (float)mSwitchEventArgs.Data);
                else
                    transform.position = Vector3.Lerp(transform.localPosition, targetPos, (float)mSwitchEventArgs.Data);

                if (OrientationMode != OrientationModeEnum.None)
                {
                    //transform.localRotation = Quaternion.Lerp(transform.localRotation, GetRotation(tan, up), 1 - OrientationDamping);
                }

                if (mSwitchEventArgs.Delta == 1)
                {
                    Spline = mSwitchEventArgs.Spline;
                    RelativePosition = mSwitchEventArgs.TF;
                    mSwitchEventArgs = null;
                }

            }
        }
 /// <summary>
 /// Print some event details to the console
 /// </summary>
 /// <param name="e"></param>
 public static void DebugLogStatic(CurvySplineMoveEventArgs e)
 {
     Debug.Log(string.Format("Segment/TF/Direction: {0}/{1}/{2}", e.ControlPoint, e.TF, e.Direction));
 }
Пример #26
0
 // Retrieve metadata
 public void OnCPReached(CurvySplineMoveEventArgs e)
 {
     mPossibleSwitchTarget = e.ControlPoint.GetMetadata<SplineRefMetadata>();
     // if not properly configured, ignore!
     if (mPossibleSwitchTarget && !mPossibleSwitchTarget.Spline)
         mPossibleSwitchTarget = null;
 }
Пример #27
0
 /// <summary>
 /// Start a spline switch
 /// </summary>
 /// <param name="target">the target spline to switch to</param>
 /// <param name="targetTF">the target TF</param>
 /// <param name="duration">duration of the switch phase</param>
 public virtual void SwitchTo(CurvySpline target, float targetTF, float duration)
 {
     mSwitchStartTime = Time.time;
     mSwitchDuration = duration;
     mSwitchEventArgs = new CurvySplineMoveEventArgs(this, target, null, targetTF, 0, Direction);
     mSwitchEventArgs.Data = 0f;
 }
 public static void DebugLog(CurvySplineMoveEventArgs e)
 {
     DebugLogStatic(e);
 }
Пример #29
0
 void onSwitchEvent(CurvySplineMoveEventArgs e)
 {
     OnSwitch.Invoke(e);
     if (e.Cancel)
         mSwitchEventArgs = null;
 }
 public void UseRandomConnection(CurvySplineMoveEventArgs e)
 {
     UseRandomConnectionStatic(e);
 }