I'm trying to make BDMode like counter-strike, I wanna make round end on bdround when all enemy players/teammates are dead.
I've tried this code, round winning works fine but it cause strange problem.
Code Part:
Code: Select all
void Update()
{
if (BombDone)
return;
if (!CanUseThis)
{
CanPlant = false;
Active = false;
return;
}
if (!RoundFinish && GetPlayerInDeltaCount != 0 && GetPlayerInReconCount != 0)
CheckPlayerDead ();
if (CanPlant)
{
PlantLogic();
}
if (CanDesactive)
{
DesactiveLogic();
}
if (Active)
{
ActiveCountDown();
}
LightControll();
}
void CheckPlayerDead(){
if (DeltaDead >= GetPlayerInDeltaCount) {
StartCoroutine (AllDeadWon (0));
}
if (ReconDead >= GetPlayerInReconCount) {
StartCoroutine (AllDeadWon (1));
}
}
IEnumerator AllDeadWon(int team)
{
RoundFinish = true;
if (PhotonNetwork.isMasterClient) { WonDoneByAllDead(team); } else { GetWinnerDead(team); }
StartCoroutine(GameManager.GetComponent<bl_RoomMenu>().FadeIn());
yield return new WaitForSeconds(TimeForNextRound);
//If still missing rounds
if (SettingsPropierties.CheckForBDRound)
{
for (int i = 0; i < AllBombs.Length; i++)
{
bl_BombDefuse bd = AllBombs[i];
bd.Reset();
}
GameManager.SpawnPlayer(PhotonNetwork.player.GetPlayerTeam());
}
else//if rached max rounds
{
PhotonNetwork.LeaveRoom();
bl_UtilityHelper.LockCursor(false);
}
}
void GetWinnerDead(int team)
{
if (team == 0) {
bl_EventHandler.OnKillEvent ("Round Won", 1000f);
bl_AnnouncerManager.GetManager.NewKill (7);
PhotonNetwork.player.PostScore (1500);
} else {
bl_EventHandler.OnKillEvent ("Round Won", 1000f);
PhotonNetwork.player.PostScore(1000);
bl_AnnouncerManager.GetManager.NewKill (6);
}
}
public int GetPlayerInDeltaCount
{
get
{
int count = 0;
for (int i = 0; i < PhotonNetwork.playerList.Length; i++)
{
PhotonPlayer players = PhotonNetwork.playerList[i];
if ((string)players.CustomProperties[PropertiesKeys.TeamKey] == Team.Delta.ToString())
{
count++;
}
}
return count;
}
}
public int DeltaDead
{
get
{
int count = 0;
for (int i = 0; i < GetDeltaPlayerList.Count; i++)
{
PhotonPlayer players = GetDeltaPlayerList[i];
bl_PlayerDamageManager pdm = GameObject.Find (players.NickName).GetComponent<bl_PlayerDamageManager> ();
if (pdm != null && pdm.dead) {
count++;
} else if (FindObjectOfType<bl_Ragdoll>() != null) {
count++;
}
}
return count;
}
}
public int ReconDead
{
get
{
int count = 0;
for (int i = 0; i < GetReconPlayerList.Count; i++)
{
PhotonPlayer players = GetReconPlayerList[i];
bl_PlayerDamageManager pdm = GameObject.Find (players.NickName).GetComponent<bl_PlayerDamageManager> ();
if (pdm != null && pdm.dead) {
count++;
} else if (FindObjectOfType<bl_Ragdoll>() != null) {
count++;
}
}
return count;
}
}
public int GetPlayerInReconCount
{
get
{
int count = 0;
for (int i = 0; i < PhotonNetwork.playerList.Length; i++)
{
PhotonPlayer players = PhotonNetwork.playerList[i];
if ((string)players.CustomProperties[PropertiesKeys.TeamKey] == Team.Recon.ToString())
{
count++;
}
}
return count;
}
}
}