|
|
@@ -259,23 +259,27 @@ public class TimeLimitGameMode : GameMode {
|
|
|
}
|
|
|
/**双人PK模式 */
|
|
|
public class PKGameMode : GameMode {
|
|
|
- public int currentPlayerID = 1;
|
|
|
+ public int currentPlayerIndex = 0;
|
|
|
public int[] totalScores = {0, 0};
|
|
|
public int[] currentScores = {0, 0};
|
|
|
public int round = 1;
|
|
|
float[] targetDistancesOnRound = {10, 20, 30, 50, 70, 70};
|
|
|
int maxRound = 5;
|
|
|
int shootCount = 0;
|
|
|
- int maxShootCount = 3;
|
|
|
+ int maxShootCount = 1;
|
|
|
public float singleShootReadyTime = 20;
|
|
|
public float singleShootReadyMaxTime = 20;
|
|
|
bool singleShootTimeRunning = false;
|
|
|
public static int[] playerRoleIDs = {1, 2};
|
|
|
string[] gameRes = {"平局", "平局"};
|
|
|
+ //本回合玩家先后顺序
|
|
|
+ Queue<int> playerIndexSequence = new Queue<int>();
|
|
|
//记录可射击的靶子
|
|
|
TargetBody targetBody;
|
|
|
|
|
|
public PKGameMode(GameMgr gameMgr) : base(gameMgr) {
|
|
|
+ InitPlayerIndexSequence();
|
|
|
+ currentPlayerIndex = playerIndexSequence.Dequeue();
|
|
|
//记录可射击的靶子
|
|
|
targetBody = GameObject.Find("GameArea/010/TargetBody").GetComponent<TargetBody>();
|
|
|
GameObject.Find("Main Camera/ArmBow").GetComponent<ArmBow>().validTargets.Add(targetBody);
|
|
|
@@ -292,6 +296,26 @@ public class PKGameMode : GameMode {
|
|
|
AddReadyView();
|
|
|
}
|
|
|
|
|
|
+ int[] playerIndexSequenceRecord = {0, 1};
|
|
|
+ void InitPlayerIndexSequence()
|
|
|
+ {
|
|
|
+ if (round >= 3)
|
|
|
+ {
|
|
|
+ if (totalScores[0] < totalScores[1])
|
|
|
+ {
|
|
|
+ playerIndexSequenceRecord = new int[]{0, 1};
|
|
|
+ }
|
|
|
+ else if (totalScores[1] < totalScores[0])
|
|
|
+ {
|
|
|
+ playerIndexSequenceRecord = new int[]{1, 0};
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ playerIndexSequenceRecord = new int[]{0, 1};
|
|
|
+ }
|
|
|
+ playerIndexSequence.Enqueue(playerIndexSequenceRecord[0]);
|
|
|
+ playerIndexSequence.Enqueue(playerIndexSequenceRecord[1]);
|
|
|
+ }
|
|
|
+
|
|
|
void AddReadyView()
|
|
|
{
|
|
|
GameObject view = Resources.Load<GameObject>("Prefabs/Views/PKGameReadyView");
|
|
|
@@ -299,7 +323,7 @@ public class PKGameMode : GameMode {
|
|
|
}
|
|
|
|
|
|
public override void HitTarget(int score) {
|
|
|
- currentScores[currentPlayerID - 1] += score;
|
|
|
+ currentScores[currentPlayerIndex] += score;
|
|
|
shootCount++;
|
|
|
HitTargetNumber.Create(score);
|
|
|
}
|
|
|
@@ -312,8 +336,7 @@ public class PKGameMode : GameMode {
|
|
|
if (shootCount == maxShootCount) {
|
|
|
shootCount = 0;
|
|
|
//当局是否结束
|
|
|
- if (currentPlayerID == 2) {
|
|
|
- currentPlayerID = 1;
|
|
|
+ if (playerIndexSequence.Count == 0) {
|
|
|
nextRound = true;
|
|
|
//更新总比分
|
|
|
if (currentScores[0] == currentScores[1]) {
|
|
|
@@ -340,8 +363,6 @@ public class PKGameMode : GameMode {
|
|
|
gameEnd = true;
|
|
|
gameRes = new string[]{"失败", "胜利"};
|
|
|
}
|
|
|
- } else {
|
|
|
- currentPlayerID = 2;
|
|
|
}
|
|
|
nextPlayer = true;
|
|
|
}
|
|
|
@@ -356,8 +377,11 @@ public class PKGameMode : GameMode {
|
|
|
if (nextRound) {
|
|
|
round++;
|
|
|
currentScores[0] = currentScores[1] = 0;
|
|
|
+ InitPlayerIndexSequence();
|
|
|
targetBody.SetDistance(targetDistancesOnRound[round - 1]);
|
|
|
}
|
|
|
+ //本轮玩家登记
|
|
|
+ currentPlayerIndex = playerIndexSequence.Dequeue();
|
|
|
//准备切换玩家
|
|
|
BanBowReady();
|
|
|
AddReadyView();
|