Răsfoiți Sursa

调整环数精度

lvjincheng 4 ani în urmă
părinte
comite
4b03a44d1d

+ 5 - 5
Assets/BowArrow/Resources/Prefabs/Views/TimeLimitGameView.prefab

@@ -110,7 +110,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0.5}
   m_AnchorMax: {x: 0, y: 0.5}
-  m_AnchoredPosition: {x: 296, y: -1}
+  m_AnchoredPosition: {x: 299, y: -1}
   m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!222 &1253463904091161056
@@ -143,8 +143,8 @@ MonoBehaviour:
       m_Calls: []
   m_FontData:
     m_Font: {fileID: 12800000, guid: 1ad2cf6c2f09744489d8c60b3fe3bab2, type: 3}
-    m_FontSize: 24
-    m_FontStyle: 1
+    m_FontSize: 22
+    m_FontStyle: 0
     m_BestFit: 0
     m_MinSize: 0
     m_MaxSize: 40
@@ -482,8 +482,8 @@ MonoBehaviour:
       m_Calls: []
   m_FontData:
     m_Font: {fileID: 12800000, guid: 1ad2cf6c2f09744489d8c60b3fe3bab2, type: 3}
-    m_FontSize: 24
-    m_FontStyle: 1
+    m_FontSize: 22
+    m_FontStyle: 0
     m_BestFit: 0
     m_MinSize: 0
     m_MaxSize: 40

+ 1 - 1
Assets/BowArrow/Scripts/Effect/HitTargetNumber.cs

@@ -27,7 +27,7 @@ public class HitTargetNumber : MonoBehaviour
         });
     }
 
-    public static void Create(int number) {
+    public static void Create(float number) {
         if (number <= 0) return;
         GameObject o = GameObject.Instantiate(
             Resources.Load<GameObject>("Prefabs/Effects/HitTargetNumber"),

+ 3 - 2
Assets/BowArrow/Scripts/Game/TargetBody.cs

@@ -36,8 +36,9 @@ public class TargetBody : MonoBehaviour
         if (arrow.armBow.validTargets.Contains(this)) {
             float maxSize = Vector3.Distance(this.transform.Find("CenterPoint").position, this.transform.Find("SidePoint").position);
             float radius = this.measureRadius(hitPosition);
-            int score = 10 - Mathf.FloorToInt(radius / maxSize * 10);
-            if (score > 0) {
+            float score = Mathf.Clamp(10f - radius / maxSize * 10f, 0, 9.9f);
+            if (score >= 0) {
+                score = (float)System.Math.Round((double)score + 1, 1);
                 GameMgr.ins.gameMode.HitTarget(score);
                 AudioMgr.ins.PlayCheer(true);
                 hitTarget = true;

+ 9 - 9
Assets/BowArrow/Scripts/Manager/GameMgr.cs

@@ -146,7 +146,7 @@ public abstract class GameMode
     public GameMode(GameMgr gameMgr) {
         this.gameMgr = gameMgr;
     }
-    public abstract void HitTarget(int score);
+    public abstract void HitTarget(float score);
     public abstract bool DoNextShoot();
     public abstract object[] Settle();
     public virtual void Start() {}
@@ -174,7 +174,7 @@ public class GameModeTest : GameMode {
         TargetBody targetBody = GameObject.Find("GameArea/010/TargetBody").GetComponent<TargetBody>();
         GameObject.Find("Main Camera/ArmBow").GetComponent<ArmBow>().validTargets.Add(targetBody);
     }
-    public override void HitTarget(int score) {
+    public override void HitTarget(float score) {
         HitTargetNumber.Create(score);
     }
     public override bool DoNextShoot() { return true; }
@@ -185,7 +185,7 @@ public class GameModeTest : GameMode {
 public class TimeLimitGameMode : GameMode {
     public static int[] distanceCanSelected = {10, 20, 30, 50, 70};
     public static int distance = 10;
-    public int score = 0;
+    public float score = 0;
     int oneStarScore = 10;
     float time = 60;
     TargetBody targetBody;
@@ -214,7 +214,7 @@ public class TimeLimitGameMode : GameMode {
         TargetView.ins.Show(true);
     }
 
-    public override void HitTarget(int score) {
+    public override void HitTarget(float score) {
         this.score += score;
         HitTargetNumber.Create(score);
     }
@@ -224,11 +224,11 @@ public class TimeLimitGameMode : GameMode {
     }
 
     public override object[] Settle() {
-        int starCount = this.score / this.oneStarScore;
-        int highestScore = 0;
+        int starCount = Mathf.FloorToInt(this.score / this.oneStarScore);
+        float highestScore = 0;
         string distanceStr = distance.ToString();
         System.Object highestScoreObj = LoginMgr.myUserInfo.timeLimitGameHighestScores[distanceStr];
-        if (highestScoreObj != null) highestScore = int.Parse(highestScoreObj.ToString()); 
+        if (highestScoreObj != null) highestScore = float.Parse(highestScoreObj.ToString()); 
         if (this.score > highestScore) {
             LoginMgr.myUserInfo.timeLimitGameHighestScores.Remove(distanceStr);
             LoginMgr.myUserInfo.timeLimitGameHighestScores.Add(distanceStr, this.score);
@@ -274,7 +274,7 @@ public class TimeLimitGameMode : GameMode {
 public class PKGameMode : GameMode {
     public int currentPlayerIndex = 0;
     public int[] totalScores = {0, 0};
-    public int[] currentScores = {0, 0};
+    public float[] currentScores = {0, 0};
     public int round = 1;
     public int showRoundValue = 0; //回合开始提示值,如果已经提示,则showRoundValue == round
     float[] targetDistancesOnRound = {10, 20, 30, 50, 70, 70};
@@ -337,7 +337,7 @@ public class PKGameMode : GameMode {
         GameObject.Instantiate(view);
     }
 
-    public override void HitTarget(int score) {
+    public override void HitTarget(float score) {
         currentScores[currentPlayerIndex] += score;
         shootCount[currentPlayerIndex]++;
         HitTargetNumber.Create(score);

+ 2 - 2
Assets/BowArrow/Scripts/View/TimeLimitGameSettleView.cs

@@ -17,7 +17,7 @@ public class TimeLimitGameSettleView : MonoBehaviour
         }
         object[] results = GameMgr.ins.gameMode.Settle();
         int starCount = (int) results[0];
-        int score = (int) results[1];
+        float score = (float) results[1];
 
         // if (starCount >= 3)
         //     this.transform.Find("Result1").gameObject.SetActive(true);
@@ -32,7 +32,7 @@ public class TimeLimitGameSettleView : MonoBehaviour
             });
         }
         DOTween.To(() => 0, value => {
-            this.transform.Find("ScoreBG/Layout/Score").GetComponent<Text>().text = value.ToString();
+            this.transform.Find("ScoreBG/Layout/Score").GetComponent<Text>().text = System.Math.Round((double)value, 1).ToString();
         }, score, 1);
 
         AudioMgr.ins.PlayWin();

+ 2 - 2
Assets/BowArrow/Scripts/View/TimeLimitGameView.cs

@@ -30,10 +30,10 @@ public class TimeLimitGameView : MonoBehaviour
 
     public void RenderHighestScoreByDistance(int distance)
     {
-        int highestScore = 0;
+        float highestScore = 0;
         string distanceStr = distance.ToString();
         System.Object highestScoreObj = LoginMgr.myUserInfo.timeLimitGameHighestScores[distanceStr];
-        if (highestScoreObj != null) highestScore = int.Parse(highestScoreObj.ToString()); 
+        if (highestScoreObj != null) highestScore = float.Parse(highestScoreObj.ToString()); 
         highestScoreTxt.text = highestScore.ToString();
     }
 }