public IEnumerator ShowLevel() // IEnumerator's are functions that can be run as coroutines, enabling the ability to have code run parallel to the main code ( started with StartCoroutine(CoroutineName()); ) { // this IEnumerator shows the entire level at the start of a new level, then resumes focus on the cannon lockToggle = true; // lock the user's ability to toggle bewtween camera move types cameraMovementType = CameraMovementType.showStage; // set the camera move type to showStage yield return(new WaitForSecondsRealtime(5)); // wait for 5 seconds cameraMovementType = CameraMovementType.followTarget; // set the camera move type to followTarget lockToggle = false; // unlock the user's ability to toggle bewtween camera move types }
public GameController(ILevelManager level, Octree octree, IPlayer player, CameraMover cameraMover, float sensitivity = 0.1f) { this.cameraMover = cameraMover; this.Sensitivity = sensitivity; this.Level = level; this.octree = octree; this.DoOnlySingleRaycasts = true; this.Player = player; //SwitchToContinuousMovement(); SwitchToDiscontinuousMovement(); movementType = CameraMovementType.Horizontal; Enable(); }
/// <summary> /// Switches camera mode to/from free float mode, /// based on the current camera mode. /// </summary> /// <param name="args">The key down event data.</param> void CameraSwitchMode(KeyDownEventArgs args) { activeCameraMovement.StopAll(); if (cameraType == CameraMovementType.FreeFloat) { camera.SwitchToFixed(); cameraType = CameraMovementType.Fixed; input.ShowCursor(); } else { camera.SwitchToFree(); cameraType = CameraMovementType.FreeFloat; input.HideCursor(); input.Level.Map.DisableHighlight(); input.Level.ToolManager.DisableTools(); } }
/// <summary> /// Creates a translator from user input to camera movement. /// </summary> /// <param name="input">The user input provider.</param> /// <param name="ui">User interface controller.</param> /// <param name="cameraMover">The component directing the camera movement.</param> public CameraController(GameController input, GameUI ui, CameraMover cameraMover) { this.input = input; this.ui = ui; this.camera = cameraMover; this.CameraRotationSensitivity = 10.0f; this.CameraScrollSensitivity = 10.0f; this.WheelSensitivity = 10.0f; this.MouseRotationSensitivity = 0.5f; this.MouseBorderCameraMovement = true; this.cameraType = CameraMovementType.Fixed; input.MouseMove += OnMouseMoved; input.MouseWheelMoved += OnMouseWheel; input.EnteredScreenBorder += OnScreenBorderEntered; input.LeftScreenBorder += OnScreenBorderLeft; RegisterCameraControlKeys(); }
void FixedUpdate() // updates not every frame, but 0.02 seconds, allowing us to have accurate camera movement based off time, not frames { switch (cameraMovementType) // basically, run the function based on what move type being used { default: cameraMovementType = CameraMovementType.followTarget; // if the cameraMoveType bugged out, just set it to follow target break; case CameraMovementType.followTarget: FollowTarget(); break; case CameraMovementType.playerControlled: PlayerControlled(); break; case CameraMovementType.showStage: ShowStage(); break; } Shake(); }