PlayerSpeedChanger FindPlayerSpeedChanger()
        {
            GameObject         player       = FindPlayer();
            PlayerSpeedChanger speedChanger = player.GetComponent <PlayerSpeedChanger>();

            return(speedChanger);
        }
Exemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     playerSpeedChanger = GameManager.Instance.SpeedChanger;
     //sets to -2 to ensure it updates the tile object on every relaunch of mod.
     lastTile = -2;
 }
        public void ApplyStartSettings()
        {
            // Resolution
            if (DaggerfallUnity.Settings.ExclusiveFullscreen && DaggerfallUnity.Settings.Fullscreen)
            {
                Screen.SetResolution(
                    DaggerfallUnity.Settings.ResolutionWidth,
                    DaggerfallUnity.Settings.ResolutionHeight,
                    FullScreenMode.ExclusiveFullScreen);
            }
            else
            {
                Screen.SetResolution(
                    DaggerfallUnity.Settings.ResolutionWidth,
                    DaggerfallUnity.Settings.ResolutionHeight,
                    DaggerfallUnity.Settings.Fullscreen);
            }

            // Camera settings
            GameObject cameraObject = GameObject.FindGameObjectWithTag("MainCamera");

            if (cameraObject)
            {
                // Set camera FOV
                Camera camera = cameraObject.GetComponent <Camera>();
                if (camera)
                {
                    camera.fieldOfView = DaggerfallUnity.Settings.FieldOfView;
                }

                // Set mouse look
                PlayerMouseLook mouseLook = cameraObject.GetComponent <PlayerMouseLook>();
                if (mouseLook)
                {
                    mouseLook.invertMouseY = DaggerfallUnity.Settings.InvertMouseVertical;
                }

                // Set mouse look smoothing
                if (mouseLook)
                {
                    mouseLook.enableSmoothing = DaggerfallUnity.Settings.MouseLookSmoothing;
                }

                // Set mouse look sensitivity
                if (mouseLook)
                {
                    mouseLook.sensitivityScale = DaggerfallUnity.Settings.MouseLookSensitivity;
                }
            }

            // Set shadow resolution
            GameManager.UpdateShadowResolution();

            // VSync settings
            if (DaggerfallUnity.Settings.VSync)
            {
                QualitySettings.vSyncCount = 1;
            }
            else
            {
                QualitySettings.vSyncCount = 0;
            }

            // Target frame rate settings
            // Does nothing if VSync enabled
            // Default is 0 but anything below 30 is ignored and treated as disabled
            if (DaggerfallUnity.Settings.TargetFrameRate >= 30 && !DaggerfallUnity.Settings.VSync)
            {
                Application.targetFrameRate = DaggerfallUnity.Settings.TargetFrameRate;
            }

            // Filter settings
            DaggerfallUnity.Instance.MaterialReader.MainFilterMode         = (FilterMode)DaggerfallUnity.Settings.MainFilterMode;
            DaggerfallUnity.Instance.MaterialReader.CompressModdedTextures = DaggerfallUnity.Settings.CompressModdedTextures;

            // HUD settings
            DaggerfallHUD hud = DaggerfallUI.Instance.DaggerfallHUD;

            if (hud != null)                                              //null at startup
            {
                hud.ShowCrosshair = DaggerfallUnity.Settings.Crosshair;
            }

            // Weapon swing settings
            WeaponManager weaponManager = GameManager.Instance.WeaponManager;

            weaponManager.AttackThreshold = DaggerfallUnity.Settings.WeaponAttackThreshold;
            TransportManager transportManager = GameManager.Instance.TransportManager;

            // Weapon hand settings
            // Only supporting left-hand rendering for now
            // More handedness options may be added later
            if (DaggerfallUnity.Settings.Handedness == 1)
            {
                weaponManager.ScreenWeapon.FlipHorizontal = true;
            }

            // GodMode setting
            PlayerEntity playerEntity = FindPlayerEntity();

            playerEntity.GodMode = GodMode;

            PlayerSpeedChanger speedChanger = FindPlayerSpeedChanger();

            speedChanger.ToggleSneak = DaggerfallUnity.Settings.ToggleSneak;

            // Enable/disable videos
            DaggerfallUI.Instance.enableVideos = EnableVideos;

            // Streaming world terrain distance
            GameManager.Instance.StreamingWorld.TerrainDistance = DaggerfallUnity.Settings.TerrainDistance;
        }
        public void ApplyStartSettings()
        {
            // Resolution
            if (DaggerfallUnity.Settings.ExclusiveFullscreen && DaggerfallUnity.Settings.Fullscreen)
            {
                Screen.SetResolution(
                    DaggerfallUnity.Settings.ResolutionWidth,
                    DaggerfallUnity.Settings.ResolutionHeight,
                    FullScreenMode.ExclusiveFullScreen);
            }
            else
            {
                Screen.SetResolution(
                    DaggerfallUnity.Settings.ResolutionWidth,
                    DaggerfallUnity.Settings.ResolutionHeight,
                    DaggerfallUnity.Settings.Fullscreen);
            }

            // Camera settings
            GameObject cameraObject = GameObject.FindGameObjectWithTag("MainCamera");

            if (cameraObject)
            {
                // Set camera FOV
                Camera camera = cameraObject.GetComponent <Camera>();
                if (camera)
                {
                    camera.fieldOfView = DaggerfallUnity.Settings.FieldOfView;
                }

                // Set mouse look
                PlayerMouseLook mouseLook = cameraObject.GetComponent <PlayerMouseLook>();
                if (mouseLook)
                {
                    mouseLook.invertMouseY = DaggerfallUnity.Settings.InvertMouseVertical;
                    // Set mouse look smoothing
                    mouseLook.enableSmoothing = DaggerfallUnity.Settings.MouseLookSmoothing;
                    // Set mouse look sensitivity
                    mouseLook.sensitivityScale = DaggerfallUnity.Settings.MouseLookSensitivity;

                    mouseLook.joystickSensitivityScale = DaggerfallUnity.Settings.JoystickLookSensitivity;
                }

                // Anti-aliasing method
                PostProcessLayer postProcessLayer = camera.GetComponent <PostProcessLayer>();
                if (postProcessLayer)
                {
                    switch ((AntiAliasingMethods)DaggerfallUnity.Settings.Antialiasing)
                    {
                    case AntiAliasingMethods.None:
                        postProcessLayer.antialiasingMode = PostProcessLayer.Antialiasing.None;
                        break;

                    case AntiAliasingMethods.FXAA:
                        postProcessLayer.antialiasingMode = PostProcessLayer.Antialiasing.FastApproximateAntialiasing;
                        break;

                    case AntiAliasingMethods.SMAA:
                        postProcessLayer.antialiasingMode = PostProcessLayer.Antialiasing.SubpixelMorphologicalAntialiasing;
                        break;

                    case AntiAliasingMethods.TAA:
                        postProcessLayer.antialiasingMode = PostProcessLayer.Antialiasing.TemporalAntialiasing;
                        break;
                    }
                }
            }

            InputManager.Instance.JoystickCursorSensitivity = DaggerfallUnity.Settings.JoystickCursorSensitivity;

            InputManager.Instance.JoystickMovementThreshold = DaggerfallUnity.Settings.JoystickMovementThreshold;

            InputManager.Instance.JoystickDeadzone = DaggerfallUnity.Settings.JoystickDeadzone;

            InputManager.Instance.EnableController = DaggerfallUnity.Settings.EnableController;

            Application.runInBackground = DaggerfallUnity.Settings.RunInBackground;

            // Set shadow resolution
            GameManager.UpdateShadowResolution();

            // VSync settings
            if (DaggerfallUnity.Settings.VSync)
            {
                QualitySettings.vSyncCount = 1;
            }
            else
            {
                QualitySettings.vSyncCount = 0;
            }

            // Target frame rate settings
            // Does nothing if VSync enabled
            // Default is 0 but anything below 30 is ignored and treated as disabled
            if (DaggerfallUnity.Settings.TargetFrameRate >= 30 && !DaggerfallUnity.Settings.VSync)
            {
                Application.targetFrameRate = DaggerfallUnity.Settings.TargetFrameRate;
            }

            // Filter settings
            DaggerfallUnity.Instance.MaterialReader.MainFilterMode         = (FilterMode)DaggerfallUnity.Settings.MainFilterMode;
            DaggerfallUnity.Instance.MaterialReader.CompressModdedTextures = DaggerfallUnity.Settings.CompressModdedTextures;

            // HUD settings
            DaggerfallHUD hud = DaggerfallUI.Instance.DaggerfallHUD;

            if (hud != null)                                              //null at startup
            {
                hud.ShowCrosshair = DaggerfallUnity.Settings.Crosshair;
            }

            // Weapon swing settings
            WeaponManager weaponManager = GameManager.Instance.WeaponManager;

            weaponManager.AttackThreshold = DaggerfallUnity.Settings.WeaponAttackThreshold;
            TransportManager transportManager = GameManager.Instance.TransportManager;

            // Weapon hand settings
            // Only supporting left-hand rendering for now
            // More handedness options may be added later
            if (DaggerfallUnity.Settings.Handedness == 1)
            {
                weaponManager.ScreenWeapon.FlipHorizontal = true;
            }

            // GodMode setting
            PlayerEntity playerEntity = FindPlayerEntity();

            playerEntity.GodMode = GodMode;

            PlayerSpeedChanger speedChanger = FindPlayerSpeedChanger();

            speedChanger.ToggleSneak = DaggerfallUnity.Settings.ToggleSneak;

            // Enable/disable videos
            DaggerfallUI.Instance.enableVideos = EnableVideos;

            // Streaming world terrain distance
            GameManager.Instance.StreamingWorld.TerrainDistance = DaggerfallUnity.Settings.TerrainDistance;
        }