Browse Source

视角转化

lvjincheng 4 years ago
parent
commit
84147de3cd

+ 22 - 1
Assets/BowArrow/Scripts/Game/BowCamera.cs

@@ -97,12 +97,33 @@ public class BowCamera : MonoBehaviour
         }
     }
 
-    bool needLookAtPoint = false; //需要-镜头看向九轴姿态虚拟节点?
+    //需要-镜头看向九轴姿态虚拟节点?
+    bool needLookAtPoint = false; 
+    //镜头旋转转换比值
+    float[] _bowRotateConvertRate = null;
+    float bowRotateConvertRate {
+        get {
+            if (_bowRotateConvertRate == null) {
+                _bowRotateConvertRate = new float[]{ UserSettings.ins.bowRotateConvert.GetRate() };
+            }
+            return _bowRotateConvertRate[0];
+        }
+    }
     void LateUpdate() {
         if (needLookAtPoint) {
             needLookAtPoint = false;
             //镜头看向九轴姿态虚拟节点
             this.transform.LookAt(CameraToLook.ins.point);
+            //镜头旋转比值转换
+            Vector3 localEulerAngles = this.transform.localEulerAngles;
+            float angleY = localEulerAngles.y;
+            if (angleY < 180) {
+                angleY = Mathf.Clamp(angleY * bowRotateConvertRate, 0, 180);
+            } else {
+                angleY = Mathf.Clamp((angleY - 360) * bowRotateConvertRate, -180, 0);
+            }
+            localEulerAngles.y = angleY;
+            this.transform.localEulerAngles = localEulerAngles;
         }
     }
 

+ 3 - 3
Assets/BowArrow/Scripts/Manager/LoginMgr.cs

@@ -121,7 +121,7 @@ public class UserSettings {
 public class BowRotateConvert {
     public float screenSize = 60; //屏幕尺寸(英寸)
     public float screenDistance = 2.5f; //玩家距离屏幕多远(米)
-    
+
     // 游戏旋转角度 : 实际旋转角度
     public float GetRate() {
         float rateMeterInch = 0.0254f; //比率(米:英寸)
@@ -144,12 +144,12 @@ public class BowRotateConvert {
         //单位屏幕比值对应大小
         float unitWeightSize = rateMeterInch * screenSize 
             / (Mathf.Pow(weightScreenWidth, 2) + Mathf.Pow(weightScreenHeight, 2));
-        float q1 = (float) Math.Tan(5.79 / 180 * Math.PI) * screenDistance; //实际玩家到左树的横向距离
+        float q1 = (float) Math.Tan(5.56 / 180 * Math.PI) * screenDistance; //实际玩家到左树的横向距离
         float w1 = q1 / unitWeightSize; //实际玩家到左树的横向距离比重
         return w1;
     }
 
     private float GetTreeAngleInRadian() {
-        return (float) (30.11 / 180 * Math.PI);
+        return (float) (27.3 / 180 * Math.PI);
     }
 }