/// <summary> /// Change State using look at point if the cameraMode is FixedPoint /// </summary> /// <param name="stateName"></param> /// <param name="pointName"></param> /// <param name="hasSmooth"></param> public void ChangeState(string stateName, string pointName, bool hasSmooth) { useSmooth = hasSmooth; if (!currentState.Name.Equals(stateName)) { // search for the camera state string name var state = CameraStateList.tpCameraStates.Find(delegate(vThirdPersonCameraState obj) { return(obj.Name.Equals(stateName)); }); if (state != null) { currentStateName = stateName; currentState.cameraMode = state.cameraMode; lerpState = state; // set the state of transition (lerpstate) to the state finded on the list // in case there is no smooth, a copy will be make without the transition values if (currentState != null && !hasSmooth) { currentState.CopyState(state); } } else { // if the state choosed if not real, the first state will be set up as default if (CameraStateList.tpCameraStates.Count > 0) { state = CameraStateList.tpCameraStates[0]; currentStateName = state.Name; currentState.cameraMode = state.cameraMode; lerpState = state; if (currentState != null && !hasSmooth) { currentState.CopyState(state); } } } // in case a list of states does not exist, a default state will be created if (currentState == null) { currentState = new vThirdPersonCameraState("Null"); currentStateName = currentState.Name; } indexList = CameraStateList.tpCameraStates.IndexOf(state); currentZoom = state.defaultDistance; currentState.fixedAngle = new Vector3(mouseX, mouseY); indexLookPoint = 0; } if (currentState.cameraMode == TPCameraMode.FixedPoint) { var point = currentState.lookPoints.Find(delegate(LookPoint obj) { return(obj.pointName.Equals(pointName)); }); if (point != null) { indexLookPoint = currentState.lookPoints.IndexOf(point); } else { indexLookPoint = 0; } } }
/// <summary> /// Change CameraState /// </summary> /// <param name="stateName"></param> /// <param name="Use smoth"></param> public void ChangeState(string stateName, bool hasSmooth) { if (currentState != null && currentState.Name.Equals(stateName) || !isInit) { if (firstStateIsInit) { useSmooth = hasSmooth; } return; } useSmooth = !firstStateIsInit ? startSmooth : hasSmooth; // search for the camera state string name vThirdPersonCameraState state = CameraStateList != null?CameraStateList.tpCameraStates.Find(delegate(vThirdPersonCameraState obj) { return(obj.Name.Equals(stateName)); }) : new vThirdPersonCameraState("Default"); if (state != null) { currentStateName = stateName; currentState.cameraMode = state.cameraMode; lerpState = state; // set the state of transition (lerpstate) to the state finded on the list if (!firstStateIsInit) { currentState.defaultDistance = Vector3.Distance(targetLookAt.position, transform.position); currentState.height = state.height; currentState.fov = state.fov; StartCoroutine(ResetFirstState()); } // in case there is no smooth, a copy will be make without the transition values if (currentState != null && !useSmooth) { currentState.CopyState(state); } } else { // if the state choosed if not real, the first state will be set up as default if (CameraStateList != null && CameraStateList.tpCameraStates.Count > 0) { state = CameraStateList.tpCameraStates[0]; currentStateName = state.Name; currentState.cameraMode = state.cameraMode; lerpState = state; if (currentState != null && !useSmooth) { currentState.CopyState(state); } } } // in case a list of states does not exist, a default state will be created if (currentState == null) { currentState = new vThirdPersonCameraState("Null"); currentStateName = currentState.Name; } if (CameraStateList != null) { indexList = CameraStateList.tpCameraStates.IndexOf(state); } currentZoom = state.defaultDistance; if (currentState.cameraMode == TPCameraMode.FixedAngle) { mouseX = currentState.fixedAngle.x; mouseY = currentState.fixedAngle.y; } currentState.fixedAngle = new Vector3(mouseX, mouseY); indexLookPoint = 0; }