//TODO utility function, this needs to be moved to default config void InitGame() { IemGameBase.IemTeam team1 = AddTeam( new IemGameBase.IemTeam("team_1", "blue", 1, 20, "Blue Bandits")); team1.Location = new Vector3(27, 34, 36); IemGameBase.IemTeam team2 = AddTeam( new IemGameBase.IemTeam("team_2", "red", 1, 20, "Red Devils")); team2.Location = new Vector3(21, 41, -14); }
public int GetCountOfLivingPlayers(IemGameBase.IemTeam iemTeam) { int count = 0; foreach (IemGameBase.IemPlayer iemPlayer in iemTeam.Players.Values) { BasePlayer player = IemUtils.FindPlayerByID(iemPlayer.PlayerId); if (iemPlayer.PlayerState == IemUtils.PlayerState.Alive) { count++; } } return(count); }
public bool CheckGameState() { bool someoneWon = false; foreach (IemGameBase.IemTeam iemTeam in Teams.Values) { if (iemTeam.State != IemUtils.TeamState.Empty) { int count = 0; foreach (IemGameBase.IemPlayer iemPlayer in iemTeam.Players.Values) { BasePlayer player = IemUtils.FindPlayerByID(iemPlayer.PlayerId); if (iemPlayer.PlayerState == IemUtils.PlayerState.Alive) { count++; } } if (count == 0) { iemTeam.State = IemUtils.TeamState.Lost; } } } int teamsNotLost = 0; IemGameBase.IemTeam winTeam = null; foreach (IemGameBase.IemTeam iemTeam in Teams.Values) { if (iemTeam.State != IemUtils.TeamState.Empty && iemTeam.State != IemUtils.TeamState.Lost) { teamsNotLost++; winTeam = iemTeam; } } if (teamsNotLost == 1) { someoneWon = true; winTeam.State = IemUtils.TeamState.Won; } if (someoneWon) { gsm.ChangeState(EmbankStateManager.GameComplete.Instance); } return(someoneWon); }