Esempio n. 1
0
        public void Update()
        {
            switch (State)
            {
            default:
            case FastTravelState.None:
                break;

            case FastTravelState.ArrivingAtDestination:
                WaitForNextChoice();
                break;

            case FastTravelState.WaitingForNextChoice:
                //this will loop about until traveling is either started or cancelled
                if ((mNextChoiceWaitStartTime + 2f) < WorldClock.AdjustedRealTime)
                {
                    if (Vector3.Distance(Player.Local.Position, Player.Local.Projections.DirectionArrowsParent.position) > MaxFastTravelWaitRadius)
                    {
                        //Debug.Log("Wait radius exceeded wait distance " + Vector3.Distance(Player.Local.Position, Player.Local.Projections.DirectionArrowsParent.position).ToString());
                        State = FastTravelState.Finished;
                    }
                }
                return;

            case FastTravelState.Traveling:
                //this will update our position over time
                UpdateTraveling();
                break;

            case FastTravelState.Finished:
                OnFinishTraveling();
                break;
            }
        }
Esempio n. 2
0
 public void CancelTraveling()
 {
     if (State != FastTravelState.None)
     {
         State = FastTravelState.Finished;
         Player.Local.Projections.ClearDirectionalArrows();
     }
 }
Esempio n. 3
0
        protected void WaitForNextChoice()
        {
            mNextChoiceWaitStartTime = WorldClock.AdjustedRealTime;
            AvailablePathMarkers.Clear();
            Paths.GetAllNeighbors(LastChosenPathMarker, DesiredLocationTypes, AvailablePathMarkers);
            //see if the player is holding down the forward key - if they are, keep moving
            bool             canSkipNextJunction = AvailablePathMarkers.Count > 1;
            Vector3          currentDirection    = Player.Local.ForwardVector;
            FastTravelChoice bestChoiceSoFar     = AvailablePathMarkers[0];

            if ((Mathf.Abs(UserActionManager.RawMovementAxisX) > MovementThreshold || Math.Abs(UserActionManager.RawMovementAxisY) > MovementThreshold) && canSkipNextJunction)
            {
                Debug.Log("Skipping junction");
                if (AvailablePathMarkers.Count == 2)
                {
                    //choose the one opposite us
                    if (bestChoiceSoFar.ConnectingPath == LastChosenPath)
                    {
                        bestChoiceSoFar = AvailablePathMarkers[1];
                    }
                }
                else
                {
                    float smallestDotSoFar = Mathf.Infinity;
                    foreach (FastTravelChoice choice in AvailablePathMarkers)
                    {
                        Vector3 nextDirection = choice.StartMarker.Position - choice.FirstInDirection.Position;
                        float   dot           = Vector3.Dot(currentDirection.normalized, nextDirection.normalized);
                        if (dot < smallestDotSoFar)
                        {
                            smallestDotSoFar = dot;
                            bestChoiceSoFar  = choice;
                        }
                    }
                }
                MakeChoice(bestChoiceSoFar);
            }
            else
            {
                if (Player.Local.IsHijacked)
                {
                    //let the player walk around again
                    mTerrainHit.feetPosition     = CurrentPosition;
                    mTerrainHit.overhangHeight   = 2f;
                    mTerrainHit.groundedHeight   = 3f;
                    mTerrainHit.ignoreWorldItems = true;
                    CurrentPosition.y            = GameWorld.Get.TerrainHeightAtInGamePosition(ref mTerrainHit) + 0.0125f;                                                 //just in case, pad it out
                    Player.Local.Position        = CurrentPosition;
                    Debug.Log(CurrentPosition.y.ToString());
                    Player.Local.RestoreControl(true);
                }
                Player.Local.Projections.ShowFastTravelChoices(LastChosenPathMarker, AvailablePathMarkers);
                FastTravelInterface.Maximize();
                State = FastTravelState.WaitingForNextChoice;
            }
        }
Esempio n. 4
0
 public bool FastTravel(PathMarker startingPathMarker)
 {
     if (State == FastTravelState.None)
     {
         if (startingPathMarker.HasPathMarkerProps)
         {
             OnStartTraveling(startingPathMarker.Props, startingPathMarker.Props.PathName);
             State = FastTravelState.ArrivingAtDestination;
         }
         else
         {
             Debug.Log("Starting path maker had no properties");
         }
     }
     return(true);
 }
Esempio n. 5
0
        public void MakeChoice(FastTravelChoice choice)
        {
            Player.Local.HijackControl();
            Player.Local.HijackLookSpeed = 0.05f;

            CurrentChoice = choice;
            //convert the current choice's indexes & whatnot into start / end spline params
            LastChosenPath = choice.ConnectingPath;
            Paths.SetActivePath(LastChosenPath, GameWorld.Get.PrimaryChunk);
            CurrentPosition    = Player.Local.Position;
            CurrentOrientation = Player.Local.Rotation.eulerAngles;
            PathEndMeters      = Paths.ActivePath.MetersFromPosition(CurrentChoice.EndMarker.Position);
            PathStartMeters    = Paths.ActivePath.MetersFromPosition(CurrentChoice.StartMarker.Position);
            PathCurrentMeters  = PathStartMeters;
            //go!
            State = FastTravelState.Traveling;
            //enabled = true;
            MasterAudio.PlaySound(MasterAudio.SoundType.PlayerInterface, "FastTravelMakeChoice");
        }
Esempio n. 6
0
        protected void OnFinishTraveling()
        {
            //Debug.Log("Finished traveling");
            Player.Local.Projections.ClearDirectionalArrows();
            State = FastTravelState.None;
            Player.Get.AvatarActions.ReceiveAction((AvatarAction.FastTravelStop), WorldClock.AdjustedRealTime);
            FastTravelInterface.Minimize();
            CurrentChoice = null;

            if (Player.Local.IsHijacked)
            {
                mTerrainHit.feetPosition = CurrentPosition;
                CurrentPosition.y        = GameWorld.Get.TerrainHeightAtInGamePosition(ref mTerrainHit) + 0.05f;                                         //just in case, pad it out
                //WorldClock.Get.SetTargetSpeed (1.0f);
                Player.Local.HijackedPosition.position = CurrentPosition + Player.Local.Height;
                Player.Local.Position = CurrentPosition;
                Player.Local.RestoreControl(true);
            }
        }
Esempio n. 7
0
 protected void ArriveAtDestination()
 {
     LastChosenPathMarker = CurrentChoice.EndMarker;
     CurrentChoice        = null;
     State = FastTravelState.ArrivingAtDestination;
 }
Esempio n. 8
0
        protected void UpdateTraveling()
        {
            if (!Paths.HasActivePath)
            {
                return;
            }

            if (Paths.IsEvaluating)
            {
                return;
            }

            if (StrengthStatusKeeper.NormalizedValue < 0f)
            {
                GUIManager.PostDanger("You're too exhausted to fast travel");
                State = FastTravelState.Finished;
                return;
            }

            CurrentSegment = Paths.ActivePath.SegmentFromMeters(PathCurrentMeters);
            float metersToMove = (float)(TimeScaleTravel * WorldClock.RTDeltaTime);

            PathCurrentMeters            = Paths.MoveAlongPath(PathCurrentMeters, metersToMove, CurrentDirection);
            CurrentPosition              = Paths.ActivePath.PositionFromMeters(PathCurrentMeters);
            mTerrainHit.feetPosition     = CurrentPosition;
            mTerrainHit.overhangHeight   = 2f;
            mTerrainHit.groundedHeight   = 2f;
            mTerrainHit.ignoreWorldItems = false;
            CurrentPosition.y            = GameWorld.Get.TerrainHeightAtInGamePosition(ref mTerrainHit) + Player.Local.Height.y;
            if (mTerrainHit.hitWater)
            {
                GUIManager.PostDanger("You can't fast travel over water");
                CurrentPosition.y += 2f;                                                //TEMP just to be safe
                CancelTraveling();
                return;
            }

                                                #if UNITY_EDITOR
            if (VRManager.VRMode | VRManager.VRTestingMode && Profile.Get.CurrentPreferences.Video.VRStaticCameraFastTravel)
            {
                                                #else
            if (VRManager.VRMode && Profile.Get.CurrentPreferences.Video.VRStaticCameraFastTravel)
            {
                                                #endif
                //if we're in vr mode and we want to use a static camera
                //just fade out, and hold the fade, then release it once we're done
                if (!mFadingOutOverTime)
                {
                    mFadingOutOverTime = true;
                    StartCoroutine(FadeOutOverTime());
                }
            }
            else
            {
                //make sure hijacked position is facing the right direction, etc
                Player.Local.State.HijackMode          = PlayerHijackMode.OrientToTarget;
                Player.Local.HijackedPosition.position = CurrentPosition;
                Player.Local.HijackedPosition.rotation = Quaternion.identity;
                Player.Local.HijackLookSpeed           = Globals.PlayerHijackLerp;
                CurrentOrientation = Paths.ActivePath.OrientationFromMeters(PathCurrentMeters, true);
                Player.Local.HijackedPosition.transform.Rotate(CurrentOrientation);
                if (CurrentDirection == PathDirection.Backwards)
                {
                    Player.Local.HijackedPosition.transform.Rotate(0f, 180f, 0f);
                }
            }

            if (HasReachedOrPassedDestination)
            {
                //Debug.Log("Has reached destination...");
                ArriveAtDestination();
            }

            //update the passage of time
            //fast travel time is updated according to how many meters the player has moved since the last update
            //the number of meters per second is deterimed by the player's motor throttle speed
            //plus the skill level of fast travel
            //(i've tried it a half-dozen different ways and this one is the most stable)
            double timeAdvanced = (metersToMove / Player.Local.MotorAccelerationMultiplier) * 0.1f;
            StrengthStatusKeeper.ChangeValue(Globals.FastTravelStrengthReducedPerMeterTraveled * metersToMove, StatusSeekType.Negative);
            WorldClock.AddARTDeltaTime(timeAdvanced);
        }