|
@@ -1,12 +1,29 @@
|
|
|
using System.Collections;
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
using UnityEngine;
|
|
using UnityEngine;
|
|
|
|
|
+using DG.Tweening;
|
|
|
|
|
|
|
|
public class WolfHuntGameMode_LocalPK : WolfHuntGameMode
|
|
public class WolfHuntGameMode_LocalPK : WolfHuntGameMode
|
|
|
{
|
|
{
|
|
|
int currentPlayerIndex = 0; // 双人0和1
|
|
int currentPlayerIndex = 0; // 双人0和1
|
|
|
|
|
+ int[] playerHpList = {20, 20};
|
|
|
|
|
+
|
|
|
public WolfHuntGameMode_LocalPK(GameMgr gameMgr) : base(gameMgr) {
|
|
public WolfHuntGameMode_LocalPK(GameMgr gameMgr) : base(gameMgr) {
|
|
|
-
|
|
|
|
|
|
|
+ InitByCurPlayerIndex();
|
|
|
|
|
+ GameEventCenter.ins.onBowArrowShootOut += (a, b) => {
|
|
|
|
|
+ hasShootOut = true;
|
|
|
|
|
+ };
|
|
|
|
|
+ onHpZero += () => {//监听到当前玩家死亡
|
|
|
|
|
+ if (hasShootOut) return; //此时箭已射出,避免重复处理下面的逻辑,等NextShoot来处理
|
|
|
|
|
+ //切换到下一个玩家
|
|
|
|
|
+ if (IsOtherPlayerNotDie()) {
|
|
|
|
|
+ ArmBow.ins.readyShoot();
|
|
|
|
|
+ NextPlayerFinal();
|
|
|
|
|
+ } else { //游戏结束
|
|
|
|
|
+ AnnounceGameOver();
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ // QuicklyCreateAnimalForDebug();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public override void Start()
|
|
public override void Start()
|
|
@@ -17,12 +34,16 @@ public class WolfHuntGameMode_LocalPK : WolfHuntGameMode
|
|
|
AddReadyView();
|
|
AddReadyView();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ bool hasShootOut;
|
|
|
public override bool DoNextShoot() {
|
|
public override bool DoNextShoot() {
|
|
|
|
|
+ hasShootOut = false;
|
|
|
|
|
+ if (IsAllPlayerDie()) {
|
|
|
|
|
+ AnnounceGameOver();
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
bool canDo = base.DoNextShoot();
|
|
bool canDo = base.DoNextShoot();
|
|
|
- if (canDo) {
|
|
|
|
|
- NextPlayer();
|
|
|
|
|
- BanBowReady();
|
|
|
|
|
- AddReadyView();
|
|
|
|
|
|
|
+ if (canDo && IsOtherPlayerNotDie()) {
|
|
|
|
|
+ NextPlayerFinal();
|
|
|
}
|
|
}
|
|
|
return canDo;
|
|
return canDo;
|
|
|
}
|
|
}
|
|
@@ -35,8 +56,35 @@ public class WolfHuntGameMode_LocalPK : WolfHuntGameMode
|
|
|
script.currentPlayerIndex = currentPlayerIndex;
|
|
script.currentPlayerIndex = currentPlayerIndex;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //切换到下一个玩家
|
|
|
|
|
+ void NextPlayerFinal() {
|
|
|
|
|
+ NextPlayer();
|
|
|
|
|
+ BanBowReady();
|
|
|
|
|
+ AddReadyView();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
void NextPlayer() {
|
|
void NextPlayer() {
|
|
|
- currentPlayerIndex++;
|
|
|
|
|
- currentPlayerIndex %= 2;
|
|
|
|
|
|
|
+ RecordByCurPlayerIndex();
|
|
|
|
|
+ currentPlayerIndex = GetNextPlayerIndex();
|
|
|
|
|
+ InitByCurPlayerIndex();
|
|
|
|
|
+ }
|
|
|
|
|
+ int GetNextPlayerIndex() {
|
|
|
|
|
+ return (currentPlayerIndex + 1) % 2;
|
|
|
|
|
+ }
|
|
|
|
|
+ bool IsAllPlayerDie() {
|
|
|
|
|
+ return playerHpList[GetNextPlayerIndex()] <= 0 && hp <= 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ bool IsOtherPlayerNotDie() {
|
|
|
|
|
+ return playerHpList[GetNextPlayerIndex()] > 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ void InitByCurPlayerIndex() {
|
|
|
|
|
+ hp = playerHpList[currentPlayerIndex];
|
|
|
|
|
+ HunterGameView v = GameObject.FindObjectOfType<HunterGameView>();
|
|
|
|
|
+ if (v) v.RenderHPImmediate();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ void RecordByCurPlayerIndex() {
|
|
|
|
|
+ playerHpList[currentPlayerIndex] = hp;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|