Example #1
0
    private Vector3 CullisionCamera()
    {
        this.v3CullisionCamera = this.target.position - this.rotation * Vector3.forward * this.currentDistance;
        this.v3CameraDirection = this.v3CullisionCamera - this.target.position;
        this.v3CameraDirection = this.v3CameraDirection.normalized;
        float num = this.currentDistance;

        if (this.m_bUseCameraLevel)
        {
            CAMERASETTING_DATA cameraData = NrTSingleton <NkCameraSettingsManager> .Instance.GetCameraData(this.m_nCameraLevel);

            if (cameraData != null)
            {
                this.fTargetHeight = Mathf.Lerp(this.m_fBeforeHeight, this.fLevelHeight, (Time.time - this.m_fLerpStartTime) / cameraData.m_LerpTime);
            }
        }
        this.position = this.target.position + new Vector3(0f, this.fTargetHeight, 0f);
        TsLayerMask layerMask = TsLayer.EVERYTHING - TsLayer.PC - TsLayer.PC_DECORATION - TsLayer.PC_OTHER - TsLayer.NPC - TsLayer.FADE_OBJECT;

        if (Physics.Raycast(this.position, this.v3CameraDirection, out this.rayCullisiton, num + 1f, layerMask))
        {
            float num2 = this.rayCullisiton.distance - 0.1f;
            num2 -= this.minDistance;
            num2 /= num - this.minDistance;
            this.fTargetHeight = Mathf.Lerp(2f, this.fLevelHeight, Mathf.Clamp(num2, 0f, 1f));
            this.position      = this.target.position + new Vector3(0f, this.fTargetHeight, 0f);
        }
        if (Physics.Raycast(this.position, this.v3CameraDirection, out this.rayCullisiton, num + 1f, layerMask))
        {
            num = this.rayCullisiton.distance - 0.1f;
        }
        this.v3CullisionCamera = this.position - this.rotation * Vector3.forward * num;
        return(this.v3CullisionCamera);
    }
Example #2
0
    public void SetLevelValue()
    {
        if (this.m_DisableContorl)
        {
            return;
        }
        CAMERASETTING_DATA cameraData = NrTSingleton <NkCameraSettingsManager> .Instance.GetCameraData(this.m_nCameraLevel);

        if (this.m_bUseCameraLevel && cameraData != null)
        {
            this.yMaxLimit          = cameraData.m_YRotate;
            this.yDeg               = maxCamera.ClampAngle(this.yDeg, this.yMinLimit, this.yMaxLimit);
            this.rotation           = Quaternion.Euler(this.yDeg, this.xDeg, 0f);
            base.transform.rotation = this.rotation;
            NrPersonInfoUser charPersonInfo = NrTSingleton <NkCharManager> .Instance.GetCharPersonInfo(1);

            if (charPersonInfo != null)
            {
                NkSoldierInfo soldierInfo = charPersonInfo.GetSoldierInfo(0);
                if (soldierInfo == null)
                {
                    return;
                }
                if (soldierInfo.GetSolID() <= 0L)
                {
                    return;
                }
                this.fLevelHeight = cameraData.GetTribeHeight(soldierInfo.GetCharKindInfo().GetCharTribe());
                if (this.fTargetHeight == 0f)
                {
                    this.fTargetHeight = this.fLevelHeight;
                }
                if (Scene.CurScene == Scene.Type.WORLD)
                {
                    this.minDistance = cameraData.GetTribeZoom(soldierInfo.GetCharKindInfo().GetCharTribe());
                    this.maxDistance = cameraData.GetTribeZoom(soldierInfo.GetCharKindInfo().GetCharTribe());
                }
                else
                {
                    this.minDistance = cameraData.m_Zoom;
                    this.maxDistance = cameraData.m_Zoom;
                }
            }
            if (Scene.CurScene == Scene.Type.WORLD && this.m_nCameraLevel >= NrTSingleton <NkCameraSettingsManager> .Instance.GetMaxLevel() - 1)
            {
                NrCharBase @char = NrTSingleton <NkCharManager> .Instance.GetChar(1);

                if (@char != null && @char.IsReady3DModel())
                {
                    @char.SetShowHide3DModel(false, false, false);
                }
            }
            this.m_bDistanceMove = true;
        }
    }
    public override bool ParseDataFromNDT(TsDataReader dr)
    {
        foreach (TsDataReader.Row data in dr)
        {
            CAMERASETTING_DATA cAMERASETTING_DATA = new CAMERASETTING_DATA();
            cAMERASETTING_DATA.SetData(data);
            cAMERASETTING_DATA.m_eType = NrTSingleton <NkCameraSettingsManager> .Instance.GetSceneEnum(cAMERASETTING_DATA.szSceneKind);

            NrTSingleton <NkCameraSettingsManager> .Instance.AddCameraSettingData(cAMERASETTING_DATA.m_eType, cAMERASETTING_DATA);
        }
        return(true);
    }
Example #4
0
 public void AddCameraSettingData(int eType, CAMERASETTING_DATA kData)
 {
     if (eType <= 0 || eType > 18)
     {
         return;
     }
     if (kData.m_Level < 0 || kData.m_Level >= this.m_nCameraLevelMax)
     {
         return;
     }
     if (this.m_kCameraSettings[eType].ContainsKey(kData.m_Level))
     {
         return;
     }
     this.m_kCameraSettings[eType].Add(kData.m_Level, kData);
 }
Example #5
0
    public void CameraWork()
    {
        if (null == this.target)
        {
            this.Init();
            return;
        }
        CAMERASETTING_DATA cAMERASETTING_DATA = null;

        if (this.m_bUseCameraLevel)
        {
            cAMERASETTING_DATA = NrTSingleton <NkCameraSettingsManager> .Instance.GetCameraData(this.m_nCameraLevel);
        }
        float num  = 0f;
        float num2 = 0f;

        if (this.GetAxisRange(ref num, ref num2))
        {
            this.xDeg += num;
            if (this.m_bUseCameraLevel && cAMERASETTING_DATA != null)
            {
                this.yDeg -= num2;
                this.yDeg  = maxCamera.ClampAngle(this.yDeg, this.yMinLimit, cAMERASETTING_DATA.m_YRotate);
            }
            else
            {
                this.yDeg -= num2;
                this.yDeg  = maxCamera.ClampAngle(this.yDeg, this.yMinLimit, this.yMaxLimit);
            }
            this.rotation           = Quaternion.Euler(this.yDeg, this.xDeg, 0f);
            base.transform.rotation = this.rotation;
        }
        else if (this.bFollowHero)
        {
            float num3 = this.target.rotation.eulerAngles.y;
            if (Mathf.Abs(this.xDeg - num3) > 180f)
            {
                num3 += 360f;
            }
            this.fFollowHeroDepending  = 1.25f;
            this.fFollowHeroDepending += 1f;
            this.fFollowHeroDepending  = Time.deltaTime * this.fFollowHeroDepending;
            this.xDeg               = Mathf.Lerp(this.xDeg, num3, this.fFollowHeroDepending);
            this.yDeg               = Mathf.Lerp(this.yDeg, 5f, this.fFollowHeroDepending);
            this.rotation           = Quaternion.Euler(this.yDeg, this.xDeg, 0f);
            base.transform.rotation = this.rotation;
        }
        if (this.m_bUseCameraLevel && cAMERASETTING_DATA != null)
        {
            if (this.m_bDistanceMove)
            {
                this.desiredDistance = Mathf.Clamp(this.desiredDistance, this.minDistance, this.maxDistance);
                this.currentDistance = Mathf.Lerp(this.m_fBeforeCurrentDistance, this.desiredDistance, (Time.time - this.m_fLerpStartTime) / cAMERASETTING_DATA.m_LerpTime);
                if (this.desiredDistance == this.currentDistance)
                {
                    if (this.m_nCameraLevel < NrTSingleton <NkCameraSettingsManager> .Instance.GetMaxLevel() - 1)
                    {
                        NrCharBase @char = NrTSingleton <NkCharManager> .Instance.GetChar(1);

                        if (@char != null && @char.IsReady3DModel())
                        {
                            @char.SetShowHide3DModel(true, true, true);
                        }
                    }
                    this.m_bDistanceMove = false;
                }
            }
        }
        else
        {
            float axis = Input.GetAxis("Mouse ScrollWheel");
            if (!this.m_bToolCamera && axis != 0f && NrTSingleton <FormsManager> .Instance.IsMouseOverForm())
            {
                return;
            }
            this.desiredDistance -= axis * Time.deltaTime * (float)this.zoomRate * Mathf.Abs(this.desiredDistance);
            this.desiredDistance  = Mathf.Clamp(this.desiredDistance, this.minDistance, this.maxDistance);
            this.currentDistance  = Mathf.Lerp(this.currentDistance, this.desiredDistance, Time.deltaTime * this.zoomDampening);
        }
        if (this.bCullisionCamera)
        {
            this.position = this.CullisionCamera();
        }
        else
        {
            this.position = this.target.position - (base.transform.rotation * Vector3.forward * this.currentDistance + this.targetOffset);
        }
        base.transform.position = this.position;
        Camera component = base.GetComponent <Camera>();

        if (this.m_bUseCameraLevel && cAMERASETTING_DATA != null)
        {
            this.fieldOfView = Mathf.Lerp(this.m_fBeforeFov, cAMERASETTING_DATA.GetFOV(), (Time.time - this.m_fLerpStartTime) / cAMERASETTING_DATA.m_LerpTime);
        }
        component.fieldOfView = this.fieldOfView;
    }