private void changeCam(cameraMode newMode, Transform newUnit, bool isStart = false) { camMode = newMode; switch (newMode) { case cameraMode.Unit: throw new NotImplementedException(); case cameraMode.Free: camControllerBase.enabled = false; camControllerFree.enabled = true; if (!isStart) { camControllerFree.AdjustPosition(cam.transform.position); } break; case cameraMode.Base: camControllerFree.enabled = false; camControllerBase.enabled = true; camControllerBase.AdjustPosition(player.transform.position); break; default: break; } }
/// <summary> ///Start following the pilgrim /// </summary> /// <param name="pilgrim"> /// A <see cref="Transform"/> /// </param> public void StartFollingMode(Transform LookAt) { cameraLookAt = LookAt; if (currentMode != CameraController.cameraMode.Follow) { currentMode = CameraController.cameraMode.Follow; //Rotate the camera this.transform.rotation = this.currentZoomRotation = Quaternion.Lerp(this._zoomRotationMin, this._zoomRotationMax, 1); } }
public void setUp( int worldWidth, int worldHeight, float zoomInLimit = 0.0f, float zoomOutLimit = 0.0f, float zoom = 1.0f, cameraMode mode = cameraMode.moveViaLeftStick, float rotation = 0.0f, float rotationDrawCompensatorMultiplier = 0, float rotationSpeed = 0f, float movmentSpeed = 0, Nullable<Buttons> zoomInButton = Buttons.LeftTrigger, Nullable<Buttons> zoomOutButton = Buttons.RightTrigger, Nullable<Buttons> rotateButton = Buttons.RightStick, Nullable<Buttons> resetViewButton = null) { // Start setUp. #region Setting up input delegates: if ( zoomInButton != null ) { // Setting up the zoom in controls: InputManager.getInstance ( ).addInputToMonitor ( ( Buttons ) zoomInButton, GameGlobals.allPlayers ); getZoomInput += InputManager.getInstance ( ).getInputByButton ( 0, ( Buttons ) zoomInButton ).triggerMovment; } if ( zoomOutButton != null ) { // Setting up the zoom out controls: InputManager.getInstance ( ).addInputToMonitor ( ( Buttons ) zoomOutButton, GameGlobals.allPlayers ); getZoomOutInput += InputManager.getInstance ( ).getInputByButton ( 0, ( Buttons ) zoomOutButton ).triggerMovment; } if ( rotateButton != null ) { // Setting up the rotation controls: InputManager.getInstance ( ).addInputToMonitor ( ( Buttons ) rotateButton, GameGlobals.allPlayers ); getRotationInput += InputManager.getInstance ( ).getInputByButton ( 0, ( Buttons ) rotateButton ).stickMovement; } if ( resetViewButton != null ) { // Setting up the resetView controls: InputManager.getInstance ( ).addInputToMonitor ( ( Buttons ) resetViewButton, GameGlobals.allPlayers ); wasViewReset += InputManager.getInstance ( ).getInputByButton ( 0, ( Buttons ) resetViewButton ).Pushed; } else if ( getZoomInput != null && getZoomOutInput != null ) { wasViewReset += wasResetTriggered; } #endregion _position = Vector2.Zero; _worldWidth = worldWidth; _worldHeight = worldHeight; _viewPortWidth = GameData.getInstance().ViewportWidth; _viewPortHeight = GameData.getInstance().ViewportHeight; if (zoomInLimit == 0) _zoomOutLimit = CameraGlobals.zoomOutLimit; else _zoomOutLimit = zoomOutLimit; if (zoomInLimit == 0) _zoomInLimit = CameraGlobals.zoomInLimit; else _zoomInLimit = zoomInLimit; _zoom = zoom; _rotation = rotation; if ( rotationDrawCompensatorMultiplier == 0 ) _rotationDrawCompensatorMultiplier = MapGlobals.tileViewMultiplier; else _rotationDrawCompensatorMultiplier = rotationDrawCompensatorMultiplier; if ( rotationSpeed == 0 ) _rotationSpeed = CameraGlobals.rotationSpeed; else _rotationSpeed = rotationSpeed; _mode = mode; if ( movmentSpeed == 0 ) _cameraMovmentSpeed = CameraGlobals.cameraMovementSpeed; else _cameraMovmentSpeed = movmentSpeed; if ( mode == cameraMode.moveViaLeftStick ) { InputManager.getInstance ( ).addInputToMonitor ( Buttons.LeftStick, GameGlobals.allPlayers ); getMoveByStickInput += InputManager.getInstance ( ).getInputByButton ( 0, Buttons.LeftStick ).stickMovement; } else if ( mode == cameraMode.moveViaRightStick ) { InputManager.getInstance ( ).addInputToMonitor ( Buttons.RightStick, GameGlobals.allPlayers ); getMoveByStickInput += InputManager.getInstance ( ).getInputByButton ( 0, Buttons.RightStick ).stickMovement; } // Setting the defaults: _defaultZoom = _zoom; _defaultRotation = _rotation; }
/// <summary> /// lock camera /// </summary> private void setLockCamera() { this.currentMode = CameraController.cameraMode.Lock; }
/// <summary> /// lock camera /// Free camera /// </summary> private void setFreeCamera() { this.currentMode = CameraController.cameraMode.Free; }
/// <summary> /// Change camera mode /// </summary> private void changeMode(cameraMode newMode) { this.currentMode = newMode; }