Exemplo n.º 1
0
    public void ChangeState(string stateName, bool hasSmooth)
    {
        var state = CameraStateList.tpCameraStates.Find(
            delegate(TPCameraState obj)
        {
            return(obj.Name.Equals(stateName));
        }
            );

        if (state != null)
        {
            lerpState.CopyState(state);
            cacheLerpState.CopyState(state);

            if (currentState != null)
            {
                if (!hasSmooth)
                {
                    currentState.CopyState(state);
                }
                else
                {
                    isLerpState = true;
                    currentSmoothBetweenStateTime = 0.0f;
                }
            }
        }
        else
        {
            state = CameraStateList.tpCameraStates[0];
            lerpState.CopyState(state);
            cacheLerpState.CopyState(state);

            if (currentState != null)
            {
                if (!hasSmooth)
                {
                    currentState.CopyState(state);
                }
                else
                {
                    isLerpState = true;
                    currentSmoothBetweenStateTime = 0.0f;
                }
            }
        }

        //设置摄像机广角;
        if (mainCamera != null)
        {
            mainCamera.fieldOfView = state.fieldOfView;
        }
        index = CameraStateList.tpCameraStates.IndexOf(state);

        cacheLerpState.mouseX   = mouseX;
        cacheLerpState.mouseY   = mouseY;
        cacheLerpState.distance = distance;
        cacheLerpState.Height   = targetHeight;
        currentLerpCameraTime   = 0.0f;
    }
Exemplo n.º 2
0
    /// Change CameraState
    /// <param name="stateName"></param>
    /// <param name="Use smoth"></param>
    public void ChangeState(string stateName, bool hasSmooth)
    {
        if (currentState != null && currentState.Name.Equals(stateName))
        {
            return;
        }
        // search for the camera state string name
        var state = CameraStateList.tpCameraStates.Find(delegate(TPCameraState 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 TPCameraState("Null");
            currentStateName = currentState.Name;
        }

        indexList               = CameraStateList.tpCameraStates.IndexOf(state);
        currentZoom             = state.defaultDistance;
        currentState.fixedAngle = new Vector3(mouseX, mouseY);
        useSmooth               = hasSmooth;
        indexLookPoint          = 0;
    }