private void SetCameraModificationSettings(MultiWayCameraModificationSetting source) { if (source.zoomSettings.zoomPercentage == 0f) { throw new ArgumentOutOfRangeException("Zoom Percentage must not be 0."); } MultiWayCameraModificationSetting clone = CloneAndTranslaceCameraModificationSetting(source, _cameraController); CameraMovementSettings cameraMovementSettings = new CameraMovementSettings( clone.verticalLockSettings , clone.horizontalLockSettings , clone.zoomSettings , clone.smoothDampMoveSettings , clone.offset , clone.verticalCameraFollowMode , clone.horizontalOffsetDeltaMovementFactor ); var cameraController = Camera.main.GetComponent <CameraController>(); cameraController.SetCameraMovementSettings(cameraMovementSettings); _lastMultiWayCameraModificationSetting = source; Logger.Info("Applied " + (source == redCameraModificationSettings ? "red" : "green") + " camera setting for camera modifier " + this.name); }
public void SetCameraMovementSettings(CameraMovementSettings cameraMovementSettings) { _cameraMovementSettings = cameraMovementSettings; this.cameraOffset = new Vector3(_cameraMovementSettings.offset.x, _cameraMovementSettings.offset.y, this.cameraOffset.z); float targetOrthographicSize = (targetScreenSize.y * .5f) / _cameraMovementSettings.zoomSettings.zoomPercentage; if (!Mathf.Approximately(Camera.main.orthographicSize, targetOrthographicSize)) { Logger.Info("Start zoom to target size: " + targetOrthographicSize + ", current size: " + Camera.main.orthographicSize); if (_cameraMovementSettings.zoomSettings.zoomTime == 0f) { Camera.main.orthographicSize = targetOrthographicSize; } else { _zoomTimer = new ZoomTimer(_cameraMovementSettings.zoomSettings.zoomTime, Camera.main.orthographicSize, targetOrthographicSize, _cameraMovementSettings.zoomSettings.zoomEasingType); _zoomTimer.Start(); } } Logger.Info("Camera movement set to: " + _cameraMovementSettings.ToString()); Logger.Info("Camera size; current: " + Camera.main.orthographicSize + ", target: " + targetOrthographicSize); }
public static void InitializeAfterSceneLoad() { GameObject settingsGO = GameObject.Find("Settings"); PrefabHub = settingsGO.GetComponent <PrephabHub>(); MoveSettings = settingsGO.GetComponent <MovementSettings>(); DestroySettings = settingsGO.GetComponent <DestroySettings>(); CameraMoveSettings = settingsGO.GetComponent <CameraMovementSettings>(); DisableSystems(); }
public void AddSettings(CameraMovementSettings cameraMovementSettings) { if (_cameraMovementSettings.LastOrDefault() == cameraMovementSettings) { return; } _cameraMovementSettings.Add(cameraMovementSettings); ChangeSettings(cameraMovementSettings); }
private void ChangeSettings(CameraMovementSettings cameraMovementSettings) { ActiveSettings = cameraMovementSettings; var actionHandler = SettingsChanged; if (actionHandler != null) { actionHandler(); } }
public bool Contains(Vector2 point) { var cameraMovementSettings = new CameraMovementSettings( VerticalLockSettings, HorizontalLockSettings, ZoomSettings, SmoothDampMoveSettings, Offset, VerticalCameraFollowMode, HorizontalOffsetDeltaMovementFactor); return(cameraMovementSettings.Contains(point)); }
void Start() { _cameraController = Camera.main.GetComponent <CameraController>(); _cameraMovementSettings = CreateCameraMovementSettings(); var playerPosition = GameManager.Instance.Player.transform.position; if (_cameraMovementSettings.Contains(playerPosition)) { _cameraController.OnCameraModifierEnter(_cameraMovementSettings); } }
void Reset() { Logger.Info("Resetting camera movement settings."); CameraMovementSettings cameraMovementSettings = new CameraMovementSettings( new VerticalLockSettings() , new HorizontalLockSettings() , new ZoomSettings() , new SmoothDampMoveSettings() , Vector2.zero , VerticalCameraFollowMode.FollowAlways , 0f); SetCameraMovementSettings(cameraMovementSettings); }
void OnTriggerEnter2D(Collider2D col) { Vector3 transformPoint = parentPositionObject.transform.TransformPoint(Vector3.zero); if (this.zoomSettings.zoomPercentage == 0f) { throw new ArgumentOutOfRangeException("Zoom Percentage must not be 0."); } if (this.verticalLockSettings.enabled) { if (this.verticalLockSettings.enableTopVerticalLock) { this.verticalLockSettings.topBoundary = transformPoint.y + this.verticalLockSettings.topVerticalLockPosition - _cameraController.targetScreenSize.y * .5f / this.zoomSettings.zoomPercentage; } if (this.verticalLockSettings.enableBottomVerticalLock) { this.verticalLockSettings.bottomBoundary = transformPoint.y + this.verticalLockSettings.bottomVerticalLockPosition + _cameraController.targetScreenSize.y * .5f / this.zoomSettings.zoomPercentage; } } if (this.horizontalLockSettings.enabled) { if (this.horizontalLockSettings.enableLeftHorizontalLock) { this.horizontalLockSettings.leftBoundary = transformPoint.x + this.horizontalLockSettings.leftHorizontalLockPosition + _cameraController.targetScreenSize.x * .5f / this.zoomSettings.zoomPercentage; } if (this.horizontalLockSettings.enableRightHorizontalLock) { this.horizontalLockSettings.rightBoundary = transformPoint.x + this.horizontalLockSettings.rightHorizontalLockPosition - _cameraController.targetScreenSize.x * .5f / this.zoomSettings.zoomPercentage; } } this.verticalLockSettings.translatedVerticalLockPosition = transformPoint.y + this.verticalLockSettings.defaultVerticalLockPosition; CameraMovementSettings cameraMovementSettings = new CameraMovementSettings( verticalLockSettings , horizontalLockSettings , zoomSettings , smoothDampMoveSettings , offset , verticalCameraFollowMode , horizontalOffsetDeltaMovementFactor ); var cameraController = Camera.main.GetComponent <CameraController>(); cameraController.SetCameraMovementSettings(cameraMovementSettings); }
void Awake() { _cameraController = Camera.main.GetComponent <CameraController>(); OnSceneReset(); var enterTrigger = GetComponentInChildren <ITriggerEnterExit>(); if (enterTrigger != null) { enterTrigger.Entered += (_, e) => OnEnter(e.SourceCollider); enterTrigger.Exited += (_, e) => _cameraController.OnCameraModifierExit(_cameraMovementSettings); } _checkpoint = GetComponentInChildren <Checkpoint>(); _cameraMovementSettings = CreateCameraMovementSettings(); }
public void RemoveSettings(CameraMovementSettings cameraMovementSettings) { if (ActiveSettings != cameraMovementSettings) { _cameraMovementSettings.Clear(); _cameraMovementSettings.Add(ActiveSettings); return; } if (_cameraMovementSettings.Count() == 1) { return; } _cameraMovementSettings.Remove(ActiveSettings); ChangeSettings(_cameraMovementSettings.Last()); }
public void OnCameraModifierEnter(CameraMovementSettings cameraMovementSettings) { _cameraMovementSettingsManager.AddSettings(cameraMovementSettings); }
public bool IsCurrentCameraMovementSettings(CameraMovementSettings cameraMovementSettings) { return(_cameraMovementSettingsManager.ActiveSettings.Equals(cameraMovementSettings)); }
public void OnCameraModifierExit(CameraMovementSettings cameraMovementSettings) { _cameraMovementSettingsManager.RemoveSettings(cameraMovementSettings); }