Browse Source

抽离个人配置

lvjincheng 4 years ago
parent
commit
97bf46d328

+ 1 - 1
Assets/BowArrow/Scripts/Bluetooth/BluetoothHolder.cs

@@ -68,6 +68,6 @@ public class BluetoothHolder : MonoBehaviour
 
     public void SetArrowWeight(InputField inputField) {
         string text = inputField.text;
-        ShootCheck.ins.arrowWeight = float.Parse(text);
+        CommonConfig.arrowWeight = float.Parse(text);
     }
 }

+ 2 - 4
Assets/BowArrow/Scripts/Bluetooth/ShootCheck.cs

@@ -226,8 +226,6 @@ public class ShootCheck : MonoBehaviour
         return (int)shortNum;
     }
 
-    public float arrowWeight = 75; //实体模具箭重,单位克
-
     bool check(float ax, float ay, float az, string t)
     {
         float acc = ay;
@@ -293,7 +291,7 @@ public class ShootCheck : MonoBehaviour
 
                 string strShootSpeed = "弓轨速度: " + shootSpeed + " 帧数: " + keyAccList.Count + "\n";
 
-                shootSpeed = Mathf.Sqrt(shootSpeed * shootSpeed * arrowWeight / LoginMgr.myUserInfo.actualArrowWeight);  
+                // shootSpeed = Mathf.Sqrt(shootSpeed * shootSpeed * arrowWeight / LoginMgr.myUserInfo.actualArrowWeight);  
 
                 strShootSpeed += "箭的速度: " + shootSpeed + "\n";
                 
@@ -346,7 +344,7 @@ public class ShootCheck : MonoBehaviour
         //弓轨速度
         float speed = 0.05f / (totalTime / 1000f);
         //通过动能定理求箭的速度(实体箭质量*实体箭速度^2=游戏中箭的质量*游戏中箭的速度^2)
-        shootSpeed = Mathf.Sqrt(speed * speed * arrowWeight / LoginMgr.myUserInfo.actualArrowWeight);  
+        shootSpeed = Mathf.Sqrt(speed * speed * CommonConfig.arrowWeight / UserSettings.ins.actualArrowWeight);  
         //打印
         string logTxt = $"序号{id},时区1:{time1}毫秒,时区2:{time2}毫秒,校验:{sumCheckRes},弓轨速度:{speed}m/s,箭的速度:{shootSpeed}m/s";
         if (DebugForDevice.ins) DebugForDevice.ins.LogInfrared(logTxt);

+ 3 - 0
Assets/BowArrow/Scripts/CommonConfig.cs

@@ -9,5 +9,8 @@ public class CommonConfig
     public static readonly int ringsPrecision = 1;
     /**箭的速度精度小数位 */
     public static readonly int arrowSpeedPrecision = 1;
+    //实体模具箭重,单位克
+    public static float arrowWeight = 75; 
+    //业务服务端访问地址
     public static string businessServerURI = "http://127.0.0.1:11332/SmartBowBusinessServer";
 }

+ 1 - 1
Assets/BowArrow/Scripts/Game/ArmBow.cs

@@ -107,7 +107,7 @@ public class ArmBow : MonoBehaviour
     {
         _ins = this;
         //initdata
-        int currentShootLevel = LoginMgr.myUserInfo.shootLevel;
+        int currentShootLevel = UserSettings.ins.shootLevel;
         shootBackTime = new int[]{0, 2, 5}[currentShootLevel];
         shootOffsetAngleScale = new float[]{0, 10f, 10f}[currentShootLevel];
     }

+ 1 - 1
Assets/BowArrow/Scripts/Game/CrossHair.cs

@@ -18,7 +18,7 @@ public class CrossHair : MonoBehaviour
     void Start()
     {
         this.image = this.GetComponent<Image>();
-        this.open = LoginMgr.myUserInfo.openCrossHair;
+        this.open = UserSettings.ins.openCrossHair;
         this.visiable = this.image.enabled;
         this.SetVisiable(false);
     }

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

@@ -332,9 +332,6 @@ public class UserInfo {
     public bool deviceCalibrateGuideFinish = false;
     public bool gameRule1GuideFinish = false;
     public bool gameRule2GuideFinish = false;
-    public bool openCrossHair = true;
-    public int shootLevel = 0;
-    public float actualArrowWeight = 20; //游戏里的箭重,单位克
     //闯关记录(索引0~2分别表示野兔、野鸡、野狼的通关数)
     public int[] challengeLevels = {0, 0, 0};
     public void Save()

+ 12 - 12
Assets/BowArrow/Scripts/View/SetUpView.cs

@@ -33,15 +33,15 @@ public class SetUpView : MonoBehaviour
     public void SelectCrossHairOption(bool on)
     {
         AudioMgr.ins.PlayBtn();
-        LoginMgr.myUserInfo.openCrossHair = on;
-        LoginMgr.myUserInfo.Save();
+        UserSettings.ins.openCrossHair = on;
+        UserSettings.ins.Save();
         RenderSelectCrossHairOption();
     }
 
     void RenderSelectCrossHairOption()
     {
-        crossHairOptionChecks[0].enabled = LoginMgr.myUserInfo.openCrossHair;
-        crossHairOptionChecks[1].enabled = !LoginMgr.myUserInfo.openCrossHair;
+        crossHairOptionChecks[0].enabled = UserSettings.ins.openCrossHair;
+        crossHairOptionChecks[1].enabled = !UserSettings.ins.openCrossHair;
     }
 
     public void ChangeLanguage()
@@ -59,20 +59,20 @@ public class SetUpView : MonoBehaviour
      public void ChangeShootLevel()
     {
         AudioMgr.ins.PlayBtn();
-        int currentShootLevel = LoginMgr.myUserInfo.shootLevel;
+        int currentShootLevel = UserSettings.ins.shootLevel;
         if (currentShootLevel < 2) {
             currentShootLevel++;
         } else {
             currentShootLevel = 0;
         }
-        LoginMgr.myUserInfo.shootLevel = currentShootLevel;
-        LoginMgr.myUserInfo.Save();
+        UserSettings.ins.shootLevel = currentShootLevel;
+        UserSettings.ins.Save();
         RenderShootLevel();
     }
 
     void RenderShootLevel()
     {   
-        int currentShootLevel = LoginMgr.myUserInfo.shootLevel;
+        int currentShootLevel = UserSettings.ins.shootLevel;
         int[] textID = {310, 311, 312};
         this.transform.Find("Items/ShootLevel/Value").GetComponent<TextAutoLanguage>().SetText(textID[currentShootLevel]);
     }
@@ -80,7 +80,7 @@ public class SetUpView : MonoBehaviour
     public void ChangeActualArrowWeight() {
         AudioMgr.ins.PlayBtn();
         float[] itemValues = {20f, 27f, 30.5f};
-        float actualArrowWeight = LoginMgr.myUserInfo.actualArrowWeight;
+        float actualArrowWeight = UserSettings.ins.actualArrowWeight;
         if (actualArrowWeight == itemValues[itemValues.Length - 1]) {
             actualArrowWeight = itemValues[0];
         } else {
@@ -91,15 +91,15 @@ public class SetUpView : MonoBehaviour
                 }
             }
         }
-        LoginMgr.myUserInfo.actualArrowWeight = actualArrowWeight;
-        LoginMgr.myUserInfo.Save();
+        UserSettings.ins.actualArrowWeight = actualArrowWeight;
+        UserSettings.ins.Save();
         RenderActualArrowWeight();
     }
 
     void RenderActualArrowWeight()
     {   
         TextAutoLanguage textAutoLanguage = this.transform.Find("Items/ActualArrowHeight/Value").GetComponent<TextAutoLanguage>();
-        textAutoLanguage.textFormatArgs = new string[]{LoginMgr.myUserInfo.actualArrowWeight.ToString()};
+        textAutoLanguage.textFormatArgs = new string[]{UserSettings.ins.actualArrowWeight.ToString()};
         textAutoLanguage.SetText(314);
     }