bool CheckEndGame() { bool may_end = false; for (int i = 0; i < players_in_match.Count; i++) { PlayerInMatch p = players_in_match[i]; //If the player is not out yet //Count its silos and compare to which are not destroyed //If all is destroyed kill it. //Check if all the players but one is dead int players_playing = players_in_match.Count; int players_dead = 0; if (!p.is_dead) { int total_silos = p.silos.Count; int destroyed_silos = 0; for (int o = 0; o < p.silos.Count; o++) { if (p.silos[o].is_nuked) { destroyed_silos++; } } if (destroyed_silos >= total_silos) { p.is_dead = true; } } else { players_dead++; } if (players_dead >= players_playing - 1) { may_end = true; } players_in_match[i] = p; } return(may_end); }
public IEnumerator SharedLoop(int player_quantity) { //SET PLAYERS PLAYING data.is_match_over = false; for (int i = 0; i < player_quantity; i++) { if (GameManager.instance.listOfPlayersPlaying[i] != null) { PlayerManager p = GameManager.instance.listOfPlayersPlaying[i]; p.data.is_playing = true; PlayerInMatch pm = new PlayerInMatch(); pm.player_id = i; pm.is_dead = false; pm.silos = new List <MapCellData>(); players_in_match.Add(pm); } } while (!data.is_match_over) { if (!data.is_war_on) { //SILO PLACEMENT RPC_ToggleSiloPlacement(BitConverter.GetBytes(true), BitConverter.GetBytes(5)); yield return(new WaitForSeconds(10)); RPC_ToggleSiloPlacement(BitConverter.GetBytes(false), BitConverter.GetBytes(0)); data.is_war_on = true; data.can_match_end = true; } //MISSILE GAIN if (data.is_war_on) { yield return(new WaitForSeconds(5)); AddMissileAll(5); yield return(null); } yield return(null); } Debug.Log("Match loop ended."); yield break; }