private IEnumerator Capturing() { for (progress = 0; progress < CaptureTime;) { yield return(new WaitForSeconds(0.1f)); if (currentState == CaptureState.capturing) { progress += 0.1f; } else { progress = CaptureTime; } } if (currentState == CaptureState.capturing) { progress = 0; _hasBeenCaptured = true; owningTeam = currentTeam; currentState = CaptureState.captured; if (_teams[(int)currentTeam] >= PlayersForBoosted) { currentState = CaptureState.boosted; } } }
public void SwitchTeam(int team) { switch (team) { case 0: currentSelectedTeam = PlayerController.Teams.noTeam; break; case 1: currentSelectedTeam = PlayerController.Teams.TeamRed; break; case 2: currentSelectedTeam = PlayerController.Teams.TeamBlue; break; } EnableCharacterSelection(); }
public Vector3 FindSpawnPosition(PlayerController.Teams team) { switch (NationSelect.instance.gameMode) { case GameModeEnum.freeForAll: return(_spawnPointsFFA[Random.Range(0, _spawnPointsFFA.Count)].position); case GameModeEnum.teamDeathMatch: case GameModeEnum.controlPoint: switch (team) { case PlayerController.Teams.TeamRed: return(_spawnPointsTB1[Random.Range(0, _spawnPointsTB1.Count)].position); case PlayerController.Teams.TeamBlue: return(_spawnPointsTB2[Random.Range(0, _spawnPointsTB2.Count)].position); } break; } return(Vector3.zero); }
private void CalculateState(PlayerController player, int point) { int teamsOnPoint = 0; _teams[(int)player.currentTeam] += point; for (int i = 0; i < _teams.Count; i++) { if (_teams[i] != 0) { teamsOnPoint++; } } for (int i = 0; i < _onPointPlayers.Count; i++) { if (_onPointPlayers[i] == null) { _onPointPlayers.Remove(_onPointPlayers[i]); for (int j = 0; j < _teams.Count; j++) { _teams[j] = 0; for (int k = 0; k < _onPointPlayers.Count; k++) { if ((int)_onPointPlayers[k].currentTeam == j) { j++; } } } } } if (teamsOnPoint > 1) { currentState = CaptureState.contested; return; } for (int i = 0; i < _teams.Count; i++) { if (_teams[i] != 0) { if ((int)currentTeam != i) { PlayerController.Teams temp = (PlayerController.Teams)i; currentTeam = temp; if (currentState != CaptureState.capturing) { currentState = CaptureState.capturing; StartCoroutine(Capturing()); } return; } if (_teams[i] >= PlayersForBoosted && currentState == CaptureState.captured) { currentState = CaptureState.boosted; return; } if (_teams[i] < PlayersForBoosted && currentState == CaptureState.boosted) { currentState = CaptureState.captured; return; } } else { if (((int)currentTeam == i && currentState == CaptureState.capturing) || currentState == CaptureState.contested) { if (_hasBeenCaptured) { currentState = CaptureState.captured; currentTeam = owningTeam; } else { currentState = CaptureState.neutral; currentTeam = PlayerController.Teams.noTeam; } } if ((int)currentTeam == i && _teams[i] < PlayersForBoosted && currentState == CaptureState.boosted) { currentState = CaptureState.captured; return; } } } }