lvjincheng 4 лет назад
Родитель
Сommit
828090a6f6

+ 2 - 2
Assets/BowArrow/Scripts/CommonConfig.cs

@@ -6,7 +6,7 @@ using UnityEngine;
 public class CommonConfig
 public class CommonConfig
 {
 {
     /**环数精度小数位 */
     /**环数精度小数位 */
-    public static int ringsPrecision = 1;
+    public static readonly int ringsPrecision = 1;
     /**箭的速度精度小数位 */
     /**箭的速度精度小数位 */
-    public static int arrowSpeedPrecision = 1;
+    public static readonly int arrowSpeedPrecision = 1;
 }
 }

+ 3 - 1
Assets/BowArrow/Scripts/GlobalData.cs

@@ -2,7 +2,9 @@ using System.Collections;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine;
 
 
+/** 全局游戏数据 */
 public class GlobalData
 public class GlobalData
 {
 {
-    
+    //本地双人PK,双方选择的角色ID
+    public static int[] localPK_playerRoleIDs = new int[] {1, 2};
 }
 }

+ 1 - 0
Assets/BowArrow/Scripts/Manager/GameMgr.cs

@@ -303,6 +303,7 @@ public class PKGameMode : GameMode {
     TargetBody targetBody;
     TargetBody targetBody;
 
 
     public PKGameMode(GameMgr gameMgr) : base(gameMgr) {
     public PKGameMode(GameMgr gameMgr) : base(gameMgr) {
+        playerRoleIDs = GlobalData.localPK_playerRoleIDs;
         InitAppearPlayerIndexes();
         InitAppearPlayerIndexes();
         currentPlayerIndex = appearPlayerIndexes.Dequeue();
         currentPlayerIndex = appearPlayerIndexes.Dequeue();
         //记录可射击的靶子
         //记录可射击的靶子

+ 7 - 7
Assets/BowArrow/Scripts/View/RoleSelectView.cs

@@ -16,7 +16,7 @@ public class RoleSelectView : MonoBehaviour
 
 
     void RenderPlayer(int playerIndex) {
     void RenderPlayer(int playerIndex) {
         Transform root = this.transform.Find("Player" + (playerIndex + 1));
         Transform root = this.transform.Find("Player" + (playerIndex + 1));
-        int roleID = PKGameMode.playerRoleIDs[playerIndex];
+        int roleID = GlobalData.localPK_playerRoleIDs[playerIndex];
         if (!inited[playerIndex]) {
         if (!inited[playerIndex]) {
             inited[playerIndex] = true;
             inited[playerIndex] = true;
             Button left = root.Find("Left").GetComponent<Button>();
             Button left = root.Find("Left").GetComponent<Button>();
@@ -38,13 +38,13 @@ public class RoleSelectView : MonoBehaviour
     }
     }
 
 
     void NextRole(int playerIndex, int variety) {
     void NextRole(int playerIndex, int variety) {
-        PKGameMode.playerRoleIDs[playerIndex] += variety;
-        if (PKGameMode.playerRoleIDs[playerIndex] < 1) {
-            PKGameMode.playerRoleIDs[playerIndex] = RoleMgr.roleCount;
-        } else if (PKGameMode.playerRoleIDs[playerIndex] > RoleMgr.roleCount) {
-            PKGameMode.playerRoleIDs[playerIndex] = 1;
+        GlobalData.localPK_playerRoleIDs[playerIndex] += variety;
+        if (GlobalData.localPK_playerRoleIDs[playerIndex] < 1) {
+            GlobalData.localPK_playerRoleIDs[playerIndex] = RoleMgr.roleCount;
+        } else if (GlobalData.localPK_playerRoleIDs[playerIndex] > RoleMgr.roleCount) {
+            GlobalData.localPK_playerRoleIDs[playerIndex] = 1;
         }
         }
-        if (PKGameMode.playerRoleIDs[playerIndex] == PKGameMode.playerRoleIDs[1 - playerIndex]) {
+        if (GlobalData.localPK_playerRoleIDs[playerIndex] == GlobalData.localPK_playerRoleIDs[1 - playerIndex]) {
             NextRole(playerIndex, variety);
             NextRole(playerIndex, variety);
         }
         }
     }
     }