添加随机拼刺刀2.0(可以切换状态,目标,但切换轮次时会发生敌人生成混乱)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using BehaviorDesigner.Runtime;
|
||||
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines;
|
||||
using Common;
|
||||
using DarkTonic.MasterAudio;
|
||||
@@ -172,7 +173,7 @@ public class GameManager : NetworkBehaviour
|
||||
[SyncVar]
|
||||
public long vistEnd = 0;
|
||||
// 总游玩时长
|
||||
private int vistAllTime = (int)(60*12);//开启最后拼刺刀模式
|
||||
private int vistAllTime = (int)(60*2);//开启最后拼刺刀模式
|
||||
[SyncVar]
|
||||
public string settleData = "";
|
||||
|
||||
@@ -446,6 +447,12 @@ public class GameManager : NetworkBehaviour
|
||||
PlaySound2DRPC("1.61");
|
||||
OpenDoor();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果是PK事件,设置游戏状态
|
||||
gameState = GameState.PKEvent;
|
||||
isPkEvent = true;
|
||||
}
|
||||
GivePistol(GunType.MeleeWeapon);
|
||||
foreach (var item in PlayerAiList.Values)
|
||||
{
|
||||
@@ -589,7 +596,27 @@ public class GameManager : NetworkBehaviour
|
||||
PlayerAiList.Add(i + 2, playerAI);
|
||||
}
|
||||
}
|
||||
|
||||
// 对于现有的敌人,更新它们的目标
|
||||
foreach (var enemy in EnemyList.Values)
|
||||
{
|
||||
if (enemy.behaviorTree != null)
|
||||
{
|
||||
// 如果isPkEvent为true,更新敌人的目标为玩家
|
||||
if (isPkEvent)
|
||||
{
|
||||
GameObject player = GetPlayer(enemy.transform);
|
||||
if (player != null)
|
||||
{
|
||||
enemy.target = player;
|
||||
var sharedTarget = enemy.behaviorTree.GetVariable("target") as SharedGameObject;
|
||||
if (sharedTarget != null)
|
||||
{
|
||||
sharedTarget.Value = player;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
curRoundEnemyCount = EnemyList.Count;
|
||||
|
||||
// 可选:在指定场地时添加调试可视化
|
||||
@@ -649,7 +676,16 @@ public class GameManager : NetworkBehaviour
|
||||
if(!isStart|| gameState== GameState.EndEvent)
|
||||
return;
|
||||
GetRoundEnemy();
|
||||
SetGameState(GameState.Playing);
|
||||
if(isPkEvent ==true )
|
||||
{
|
||||
SetGameState(GameState.PKEvent );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetGameState(GameState.Playing );
|
||||
|
||||
}
|
||||
|
||||
}, roundWaveTime);
|
||||
|
||||
}
|
||||
@@ -802,7 +838,8 @@ public class GameManager : NetworkBehaviour
|
||||
if (isPk)
|
||||
{
|
||||
isPkEvent = true;
|
||||
PlayEndEvent(false);
|
||||
gameState = GameState.PKEvent;
|
||||
PlayEndEvent(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1132,17 +1169,24 @@ public class GameManager : NetworkBehaviour
|
||||
ChangePlayerAiCountdownTime();
|
||||
if (curRoundEnemyCount<=0)
|
||||
{
|
||||
// 如果是PK事件结束,重置PK事件标志
|
||||
if (gameState == GameState.PKEvent)
|
||||
{
|
||||
isPkEvent = false;
|
||||
gameState = GameState.Playing;
|
||||
|
||||
// 创建下一波敌人
|
||||
CreateNextRound();
|
||||
//if (gameState == GameState.PKEvent )
|
||||
//{
|
||||
// gameState = GameState.Playing;
|
||||
// CreateNextRound();
|
||||
//}
|
||||
if (gameState == GameState.EndEvent)
|
||||
{
|
||||
gameState = GameState.Victory;
|
||||
GameOver();
|
||||
}
|
||||
}
|
||||
else if (gameState == GameState.EndEvent)
|
||||
{
|
||||
gameState = GameState.Victory;
|
||||
GameOver();
|
||||
}
|
||||
else
|
||||
{
|
||||
CreateNextRound();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1881,5 +1925,6 @@ public class GameManager : NetworkBehaviour
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user