/// <summary> /// This method is called at the end of Update. /// This method have rules to change between camera states. /// </summary> private void UpdateStatus() { // rule 1: AT_PLAYER to MANUAL if (status == MyCameraStatusEnum.AT_PLAYER && InputManager.instance.GetPanAxis() != Vector2.zero) { status = MyCameraStatusEnum.MANUAL; } // rule 2: MANUAL to AT_PLAYER else if (status == MyCameraStatusEnum.MANUAL && InputManager.instance.GetJumpBackToPlayer()) { status = MyCameraStatusEnum.AT_PLAYER; } }
private void Start() { status = MyCameraStatusEnum.AT_PLAYER; // the camera must start at AT_PLAYER status }
private MyCameraStatusEnum status; // holds the current status #endregion #region MonoBehavior Methods private void Start() { status = MyCameraStatusEnum.AT_PLAYER; // the camera must start at AT_PLAYER status }
/// <summary> /// This method is called at the end of Update. /// This method have rules to change between camera states. /// </summary> private void UpdateStatus() { // rule 1: AT_PLAYER to MANUAL if (status == MyCameraStatusEnum.AT_PLAYER && InputManager.instance.GetPanAxis() != Vector2.zero) { status = MyCameraStatusEnum.MANUAL; Debug.Log (status); } //bonus rule supposed to apply MANUAL status if moving mouse cursor over screen edge //TODO: make it work lol. It works, but it doesn't center focus back to FF. Figure out how to fix it else if (status == MyCameraStatusEnum.AT_PLAYER && (Input.mousePosition.x >= Screen.width*0.98f || Input.mousePosition.y >= Screen.height*0.98f || Input.mousePosition.x == 0 || Input.mousePosition.y == 0)) { status = MyCameraStatusEnum.MANUAL; Debug.Log (status); } else if (status == MyCameraStatusEnum.AT_PLAYER && MiniMapController.main.m_MiniMapRect.Contains (Input.mousePosition)) { status = MyCameraStatusEnum.MANUAL; Debug.Log (status); } // rule 2: MANUAL to AT_PLAYER else if (status == MyCameraStatusEnum.MANUAL && InputManager.instance.GetJumpBackToPlayer()) { status = MyCameraStatusEnum.AT_PLAYER; Debug.Log (status); } }