Example #1
0
        protected void BeginPathTravel(DFPosition targetPixel, bool starting = true)
        {
            if (targetPixel != null)
            {
                lastCrossed = 0;
                travelControlUI.SetDestination(road ? MsgFollowRoad : MsgFollowTrack);
                DFPosition targetMPworld = MapsFile.MapPixelToWorldCoord(targetPixel.X, targetPixel.Y);

                Rect targetRect = SetLocationRects(targetPixel, targetMPworld) ? locationBorderRect : new Rect(targetMPworld.X + MidLo, targetMPworld.Y + MidLo, PSize, PSize);

                DestinationCautious = true;
                if (starting && alwaysUseStartingAccel)
                {
                    travelControlUI.TimeAcceleration = defaultStartingAccel;
                }
                travelControlUI.HalfLimit = true;

                if (playerAutopilot == null)
                {
                    playerAutopilot            = new PlayerAutoPilot(targetPixel, targetRect, road ? RecklessTravelMultiplier : CautiousTravelMultiplier);
                    playerAutopilot.OnArrival += SelectNextPath;
                }
                else
                {
                    playerAutopilot.InitTargetRect(targetPixel, targetRect, road ? RecklessTravelMultiplier : CautiousTravelMultiplier);
                }
                InitTravelUI();
            }
        }
        public void BeginTravel()
        {
            if (!string.IsNullOrEmpty(DestinationName))
            {
                playerAutopilot            = new PlayerAutoPilot(DestinationSummary, GetTravelSpeedMultiplier());
                playerAutopilot.OnArrival += () =>
                {
                    travelControlUI.CloseWindow();
                    ClearTravelDestination();
                    DaggerfallUI.MessageBox(MsgArrived);
                    Debug.Log("Elapsed time for trip: " + (DaggerfallUnity.Instance.WorldTime.Now.ToClassicDaggerfallTime() - beginTime));
                };

                lastLocation = GameManager.Instance.PlayerGPS.CurrentLocation;
                SetTimeScale(travelControlUI.TimeAcceleration);
                DisableWeatherAndSound();
                diseaseCount = GameManager.Instance.PlayerEffectManager.DiseaseCount;

                // Register event for entering location rects
                if (locationPause == LocPauseEnter)
                {
                    PlayerGPS.OnEnterLocationRect += PlayerGPS_OnEnterLocationRect;
                }

                Debug.Log("Begun travel to " + DestinationName);
            }
        }
Example #3
0
 public void ClearTravelDestination()
 {
     DestinationName = null;
     playerAutopilot = null;
     if (travelControlUI.isShowing)
     {
         travelControlUI.CloseWindow();
     }
 }
Example #4
0
        public void BeginTravel()
        {
            if (!string.IsNullOrEmpty(DestinationName))
            {
                playerAutopilot            = new PlayerAutoPilot(DestinationSummary, GetTravelSpeedMultiplier());
                playerAutopilot.OnArrival += () =>
                {
                    travelControlUI.CloseWindow();
                    ClearTravelDestination();
                    DaggerfallUI.MessageBox(MsgArrived);
                    Debug.Log("Elapsed time for trip: " + (DaggerfallUnity.Instance.WorldTime.Now.ToClassicDaggerfallTime() - beginTime));
                };

                lastLocation = GameManager.Instance.PlayerGPS.CurrentLocation;
                InitTravelUI();

                Debug.Log("Begun accelerated travel to " + DestinationName);
            }
        }
        /// <summary>
        /// Stops travel, but leaves current destination active
        /// </summary>
        public void InterruptTravel()
        {
            Debug.Log("Travel interrupted");
            SetTimeScale(1);
            GameManager.Instance.PlayerMouseLook.enableMouseLook  = true;
            GameManager.Instance.PlayerMouseLook.lockCursor       = true;
            GameManager.Instance.PlayerMouseLook.simpleCursorLock = false;
            if (playerAutopilot != null)
            {
                playerAutopilot.MouseLookAtDestination();
            }
            playerAutopilot = null;
            EnableWeatherAndSound();

            // Remove event for entering location rects
            if (locationPause == LocPauseEnter)
            {
                PlayerGPS.OnEnterLocationRect -= PlayerGPS_OnEnterLocationRect;
            }
        }
Example #6
0
        protected void CircumnavigateLocation()
        {
            PlayerGPS  playerGPS    = GameManager.Instance.PlayerGPS;
            DFPosition currMapPixel = playerGPS.CurrentMapPixel;

            if (circumnavigatePathsDataPt == 0)
            {
                circumnavigatePathsDataPt = GetPathsDataPoint(currMapPixel);
            }
            int yaw = (int)GetNormalisedPlayerYaw();

            Rect    targetRect;
            Vector2 worldPos = new Vector2(playerGPS.WorldX, playerGPS.WorldZ);

            if (locBorderNERect.Contains(worldPos))                                                         // NE Corner
            {
                targetRect = (yaw > 45 && yaw < 225) ? locBorderSERect : locBorderNWRect;
            }
            else if (locBorderSERect.Contains(worldPos))                                                    // SE Corner
            {
                targetRect = (yaw > 135 && yaw < 315) ? locBorderSWRect : locBorderNERect;
            }
            else if (locBorderSWRect.Contains(worldPos))                                                    // SW Corner
            {
                targetRect = (yaw > 45 && yaw < 225) ? locBorderSERect : locBorderNWRect;
            }
            else if (locBorderNWRect.Contains(worldPos))                                                    // NW Corner
            {
                targetRect = (yaw > 135 && yaw < 315) ? locBorderSWRect : locBorderNERect;
            }

            else if (playerGPS.WorldZ > locationRect.yMax && playerGPS.WorldZ < locationBorderRect.yMax)    // North edge
            {
                targetRect = (yaw > 180 && yaw < 360) ? locBorderNWRect : locBorderNERect;
            }
            else if (playerGPS.WorldZ > locationBorderRect.yMin && playerGPS.WorldZ < locationRect.yMin)    // South edge
            {
                targetRect = (yaw > 180 && yaw < 360) ? locBorderSWRect : locBorderSERect;
            }
            else if (playerGPS.WorldX > locationRect.xMax && playerGPS.WorldX < locationBorderRect.xMax)    // East edge
            {
                targetRect = (yaw > 90 && yaw < 270) ? locBorderSERect : locBorderNERect;
            }
            else if (playerGPS.WorldX > locationBorderRect.xMin && playerGPS.WorldX < locationRect.xMin)    // West edge
            {
                targetRect = (yaw > 90 && yaw < 270) ? locBorderSWRect : locBorderNWRect;
            }
            else
            {
                return;
            }

            travelControlUI.SetDestination(string.Format(MsgCircumnavigate, GameManager.Instance.PlayerGPS.CurrentLocation.Name));

            DestinationCautious = false;
            if (alwaysUseStartingAccel)
            {
                travelControlUI.TimeAcceleration = defaultStartingAccel;
            }
            travelControlUI.HalfLimit = true;

            playerAutopilot            = new PlayerAutoPilot(currMapPixel, targetRect, GetTravelSpeedMultiplier());
            playerAutopilot.OnArrival += () => { CircumnavigateLocation(); };

            InitTravelUI(true);
        }