/// <summary>
 /// Switches camera mode to full view of given camera
 /// </summary>
 /// <param name="fullCameraViewToSwitch"></param>
 public void SwitchToFull(FullCameraView fullCameraViewToSwitch)
 {
     fullCameraView = fullCameraViewToSwitch;
     cameraViewMode = CameraViewMode.Full;
     uiCanvas.SetActive(false);
     UpdateCameras();
 }
Esempio n. 2
0
 // --- constructors ---
 /// <summary>Creates a new instance of this class.</summary>
 /// <param name="vehicle">The state of the train.</param>
 /// <param name="precedingVehicle">The state of the preceding train, or a null reference if there is no preceding train.</param>
 /// <param name="handles">The virtual handles.</param>
 /// <param name="totalTime">The current absolute time.</param>
 /// <param name="elapsedTime">The elapsed time since the last call to Elapse.</param>
 /// <param name="stations">The current route's list of stations.</param>
 /// <param name="cameraView">The current camera view mode</param>
 /// <param name="languageCode">The current language code</param>
 public ElapseData(VehicleState vehicle, PrecedingVehicleState precedingVehicle, Handles handles, Time totalTime, Time elapsedTime, List <Station> stations, CameraViewMode cameraView, string languageCode)
 {
     this.MyVehicle          = vehicle;
     this.MyPrecedingVehicle = precedingVehicle;
     this.MyHandles          = handles;
     this.MyTotalTime        = totalTime;
     this.MyElapsedTime      = elapsedTime;
     this.MyDebugMessage     = null;
     this.MyStations         = stations;
     this.MyCameraViewMode   = cameraView;
     this.MyLanguageCode     = languageCode;
 }
Esempio n. 3
0
    public void ModifyView(CameraViewMode viewMode)
    {
        switch (viewMode)
        {
        case CameraViewMode.aim:
            targetView = 40;
            break;

        case CameraViewMode.normal:
            targetView = 60;
            break;
        }
    }
Esempio n. 4
0
        /// <summary>
        /// Returns the Top Down or Pseudo3D direction.
        /// </summary>
        /// <param name="viewMode">The type of camera view.</param>
        /// <returns>The Top Down or Pseudo3D direction.</returns>
        private Vector3 GetTopDownPsuedo3DDirection(CameraViewMode viewMode)
        {
            var mousePosition = (Vector3)m_PlayerInput.GetMousePosition();

            if (viewMode == CameraViewMode.TopDown)
            {
                if ((mousePosition - m_PrevMousePosition).sqrMagnitude > 0.1f)
                {
                    m_PrevMousePosition = mousePosition;
                    var   ray = m_Camera.ScreenPointToRay(mousePosition);
                    float distance;
                    m_HitPlane.SetNormalAndPosition(Vector3.up, m_TargetLookRay.origin);
                    if (m_HitPlane.Raycast(ray, out distance))
                    {
                        return((ray.GetPoint(distance) - m_TargetLookRay.origin).normalized);
                    }
                }
            }
            if ((mousePosition - m_PrevMousePosition).sqrMagnitude > 0.1f)
            {
                m_PrevMousePosition = mousePosition;
                var screenPoint = m_Camera.WorldToScreenPoint(m_TargetLookRay.origin);
                var direction   = mousePosition - screenPoint;
                // Top down doesn't use the y direction.
                if (viewMode == CameraViewMode.TopDown)
                {
                    direction.z = direction.y;
                    direction.y = 0;
                }
                return(direction);
            }
            else
            {
                var direction = Vector3.zero;
                direction.x = m_PlayerInput.GetAxis(Constants.YawInputName);
                // Top down doesn't use the y direction.
                if (viewMode == CameraViewMode.TopDown)
                {
                    direction.z = m_PlayerInput.GetAxis(Constants.PitchInputName);
                }
                else
                {
                    direction.y = m_PlayerInput.GetAxis(Constants.PitchInputName);
                }
                if (direction.sqrMagnitude > 0.1f)
                {
                    return(direction.normalized);
                }
            }
            return(m_TargetLookRay.direction);
        }
Esempio n. 5
0
 /// <summary>Creates a new instance of this class.</summary>
 /// <param name="vehicle">The state of the train.</param>
 /// <param name="precedingVehicle">The state of the preceding train, or a null reference if there is no preceding train.</param>
 /// <param name="handles">The virtual handles.</param>
 /// <param name="doorinterlock">Whether the door interlock is currently enabled</param>
 /// <param name="totalTime">The current absolute time.</param>
 /// <param name="elapsedTime">The elapsed time since the last call to Elapse.</param>
 /// <param name="stations">The current route's list of stations.</param>
 /// <param name="cameraView">The current camera view mode</param>
 /// <param name="languageCode">The current language code</param>
 /// <param name="destination">The current destination</param>
 public ElapseData(VehicleState vehicle, PrecedingVehicleState precedingVehicle, Handles handles, DoorInterlockStates doorinterlock, Time totalTime, Time elapsedTime, List <Station> stations, CameraViewMode cameraView, string languageCode, int destination)
 {
     this.MyVehicle            = vehicle;
     this.MyPrecedingVehicle   = precedingVehicle;
     this.MyHandles            = handles;
     this.MyDoorInterlockState = doorinterlock;
     this.MyTotalTime          = totalTime;
     this.MyElapsedTime        = elapsedTime;
     this.MyDebugMessage       = null;
     this.MyStations           = stations;
     this.MyCameraViewMode     = cameraView;
     this.MyLanguageCode       = languageCode;
     this.CurrentDestination   = destination;
 }
Esempio n. 6
0
    public void SwitchViewAngle(CameraViewMode desiredAngle)
    {
        if(lockMovement)
            return;

        if(desiredAngle == CameraViewMode.Perspective)
        {
            SetViewAngle(VIEW_ANGLE_LOW, ROTATION_SPEED);
            distanceFromFocus = ACTION_CAMERA_DISTANCE;
            lockFocus = true;
        }

        if(desiredAngle == CameraViewMode.Top)
        {
            SetViewAngle(VIEW_ANGLE_HIGH, ROTATION_SPEED);
            distanceFromFocus = TOP_CAMERA_DISTANCE;
            lockFocus = false;
        }

        lockMovement = true;
    }
Esempio n. 7
0
            /// <summary>Called every frame to update the plugin.</summary>
            internal void UpdatePlugin()
            {
                if (Train.Cars == null || Train.Cars.Length == 0)
                {
                    return;
                }

                /*
                 * Prepare the vehicle state.
                 * */
                double location = this.Train.Cars[0].FrontAxle.Follower.TrackPosition - this.Train.Cars[0].FrontAxle.Position + 0.5 * this.Train.Cars[0].Length;
                //Curve Radius, Cant and Pitch Added
                double CurrentRadius = this.Train.Cars[0].FrontAxle.Follower.CurveRadius;
                double CurrentCant   = this.Train.Cars[0].FrontAxle.Follower.CurveCant;
                double CurrentPitch  = this.Train.Cars[0].FrontAxle.Follower.Pitch;

                //If the list of stations has not been loaded, do so
                if (!StationsLoaded)
                {
                    currentRouteStations = new List <Station>();
                    int s = 0;
                    foreach (Game.Station selectedStation in Game.Stations)
                    {
                        double stopPosition = -1;
                        int    stopIdx      = Game.Stations[s].GetStopIndex(Train.Cars.Length);
                        if (selectedStation.Stops.Length != 0)
                        {
                            stopPosition = selectedStation.Stops[stopIdx].TrackPosition;
                        }
                        Station i = new Station(selectedStation, stopPosition);
                        currentRouteStations.Add(i);
                        s++;
                    }
                    StationsLoaded = true;
                }
                //End of additions
                double       speed       = this.Train.Cars[this.Train.DriverCar].Specs.CurrentPerceivedSpeed;
                double       bcPressure  = this.Train.Cars[this.Train.DriverCar].CarBrake.brakeCylinder.CurrentPressure;
                double       mrPressure  = this.Train.Cars[this.Train.DriverCar].CarBrake.mainReservoir.CurrentPressure;
                double       erPressure  = this.Train.Cars[this.Train.DriverCar].CarBrake.equalizingReservoir.CurrentPressure;
                double       bpPressure  = this.Train.Cars[this.Train.DriverCar].CarBrake.brakePipe.CurrentPressure;
                double       sapPressure = this.Train.Cars[this.Train.DriverCar].CarBrake.straightAirPipe.CurrentPressure;
                VehicleState vehicle     = new VehicleState(location, new Speed(speed), bcPressure, mrPressure, erPressure, bpPressure, sapPressure, CurrentRadius, CurrentCant, CurrentPitch);

                /*
                 * Prepare the preceding vehicle state.
                 * */
                double bestLocation = double.MaxValue;
                double bestSpeed    = 0.0;
                PrecedingVehicleState precedingVehicle;

                try
                {
                    for (int i = 0; i < TrainManager.Trains.Length; i++)
                    {
                        if (TrainManager.Trains[i] != this.Train & TrainManager.Trains[i].State == TrainState.Available & Train.Cars.Length > 0)
                        {
                            int    c = TrainManager.Trains[i].Cars.Length - 1;
                            double z = TrainManager.Trains[i].Cars[c].RearAxle.Follower.TrackPosition - TrainManager.Trains[i].Cars[c].RearAxle.Position - 0.5 * TrainManager.Trains[i].Cars[c].Length;
                            if (z >= location & z < bestLocation)
                            {
                                bestLocation = z;
                                bestSpeed    = TrainManager.Trains[i].Specs.CurrentAverageSpeed;
                            }
                        }
                    }
                    precedingVehicle = bestLocation != double.MaxValue ? new PrecedingVehicleState(bestLocation, bestLocation - location, new Speed(bestSpeed)) : null;
                }
                catch
                {
                    precedingVehicle = null;
                }

                /*
                 * Get the driver handles.
                 * */
                Handles handles = GetHandles();

                /*
                 * Update the plugin.
                 * */
                double totalTime   = Game.SecondsSinceMidnight;
                double elapsedTime = Game.SecondsSinceMidnight - LastTime;

                /*
                 * Set the current camera view mode
                 * Could probably do away with the CurrentCameraViewMode and use a direct cast??
                 *
                 */
                CurrentCameraViewMode = (CameraViewMode)World.CameraMode;
                ElapseData data = new ElapseData(vehicle, precedingVehicle, handles, (DoorInterlockStates)this.Train.Specs.DoorInterlockState, new Time(totalTime), new Time(elapsedTime), currentRouteStations, CurrentCameraViewMode, Translations.CurrentLanguageCode, this.Train.Destination);
                ElapseData inputDevicePluginData = data;

                LastTime = Game.SecondsSinceMidnight;
                Elapse(data);
                this.PluginMessage = data.DebugMessage;
                this.Train.Specs.DoorInterlockState = (TrainManager.DoorInterlockStates)data.DoorInterlockState;
                DisableTimeAcceleration             = data.DisableTimeAcceleration;
                for (int i = 0; i < InputDevicePlugin.AvailablePluginInfos.Count; i++)
                {
                    if (InputDevicePlugin.AvailablePluginInfos[i].Status == InputDevicePlugin.PluginInfo.PluginStatus.Enable)
                    {
                        InputDevicePlugin.AvailablePlugins[i].SetElapseData(inputDevicePluginData);
                    }
                }

                /*
                 * Set the virtual handles.
                 * */
                this.PluginValid = true;
                SetHandles(data.Handles, true);
                this.Train.Destination = data.Destination;
            }
Esempio n. 8
0
        /// <summary>
        /// Returns the point that the camera is looking at.
        /// </summary>
        /// <param name="lookRay">The look ray of the camera.</param>
        /// <param name="targetLock">The transform to look at.</param>
        /// <param name="distance">The distance that the character should look.</param>
        /// <param name="viewMode">The type of camera view.</param>
        /// <returns>The point that the camera is looking at.</returns>
        public static Vector3 TargetLookPosition(Ray lookRay, Transform targetLock, float distance, CameraViewMode viewMode)
        {
            // Look at the target lock if there is one.
            if (targetLock != null)
            {
                return(targetLock.position);
            }

            return(lookRay.GetPoint(distance == -1 ? 1000 : distance));
        }
Esempio n. 9
0
        /// <summary>
        /// Returns the direction that the camera is looking.
        /// </summary>
        /// <param name="lookRay">The look ray of the camera.</param>
        /// <param name="lookPoint">The reference point to compute the direction from.</param>
        /// <param name="targetLock">The transform to look at.</param>
        /// <param name="recoil">The amount of recoil the direction should add.</param>
        /// <param name="distance">The distance that the character should look.</param>
        /// <param name="viewMode">The type of camera view.</param>
        /// <returns>The direction that the camera is looking.</returns>
        public static Vector3 TargetLookDirection(Ray lookRay, Vector3 lookPoint, Transform targetLock, float recoil, float distance, CameraViewMode viewMode)
        {
            // Look at the target lock if there is one.
            if (targetLock != null)
            {
                return((targetLock.position - lookPoint).normalized);
            }

            // Account for any recoil
            var direction = lookRay.direction;

            if (recoil != 0)
            {
                direction.y      += recoil;
                lookRay.direction = direction;
            }

            if (viewMode == CameraViewMode.ThirdPerson || viewMode == CameraViewMode.RPG || viewMode == CameraViewMode.Pseudo3D)
            {
                return((lookRay.GetPoint(distance == -1 ? 1000 : distance) - lookPoint).normalized);
            }
            return(direction);
        }
 /// <summary>
 /// Switches camera mode to split dividing each camera view in half
 /// </summary>
 public void SwitchToSplit()
 {
     cameraViewMode = CameraViewMode.Split;
     uiCanvas.SetActive(true);
     UpdateCameras();
 }
Esempio n. 11
0
		// --- constructors ---
		/// <summary>Creates a new instance of this class.</summary>
		/// <param name="vehicle">The state of the train.</param>
		/// <param name="precedingVehicle">The state of the preceding train, or a null reference if there is no preceding train.</param>
		/// <param name="handles">The virtual handles.</param>
		/// <param name="totalTime">The current absolute time.</param>
		/// <param name="elapsedTime">The elapsed time since the last call to Elapse.</param>
		/// <param name="stations">The current route's list of stations.</param>
		/// <param name="cameraView">The current camera view mode</param>
		/// <param name="languageCode">The current language code</param>
		public ElapseData(VehicleState vehicle, PrecedingVehicleState precedingVehicle, Handles handles, Time totalTime, Time elapsedTime, List<Station> stations, CameraViewMode cameraView, string languageCode) {
			this.MyVehicle = vehicle;
			this.MyPrecedingVehicle = precedingVehicle;
			this.MyHandles = handles;
			this.MyTotalTime = totalTime;
			this.MyElapsedTime = elapsedTime;
			this.MyDebugMessage = null;
			this.MyStations = stations;
			this.MyCameraViewMode = cameraView;
			this.MyLanguageCode = languageCode;
		}