void OnGoalScored(Enums.Teams Team) { PV.RPC("updateScore", RpcTarget.AllBuffered, Team); ball.GetComponent <Rigidbody2D>().velocity = Vector2.zero; ball.position = ballStartPos; ball.rotation = ballStartRot; PV.RPC("respawnBall", RpcTarget.AllBuffered); PV.RPC("RPC_CountDown", RpcTarget.All); }
public void updateScore(Enums.Teams Team) { if (Team == Enums.Teams.Blue) { blueScore++; } else { orangeScore++; } blueScoreText.text = blueScore.ToString(); orangeScoreText.text = orangeScore.ToString(); }
// Get a specific object from array by tag and compare team public bool ContainsEnemyInSight() { Enums.Teams playerTeam = GetComponent <AgentController>()._Team; for (int i = 0; i < _visibleObjects.Length; i++) { if (_visibleObjects[i].gameObject.GetComponent <Soldier>() != null) { if (_visibleObjects[i].gameObject.GetComponent <AgentController>()._Team != playerTeam) { return(true); } } } return(false); }
// Count all enemy agent soldiers in area public int CountEnemySoldiersInSight() { Enums.Teams playerTeam = GetComponent <AgentController>()._Team; int count = 0; for (int i = 0; i < _visibleObjects.Length; i++) { if (_visibleObjects[i].gameObject.GetComponent <Soldier>() != null) { if (_visibleObjects[i].gameObject.GetComponent <Soldier>()._AgentController._Team != playerTeam) { count++; } } } return(count); }
// Return closest enemy public GameObject GetClosestEnemy() { Enums.Teams playerTeam = GetComponent <AgentController>()._Team; for (int i = 0; i < _visibleObjects.Length; i++) { if (_visibleObjects[i].gameObject.GetComponent <Soldier>() != null) { if (_visibleObjects[i].gameObject.GetComponent <Soldier>()._AgentController._Team != playerTeam) { closestObjCol = _visibleObjects[i]; } } } closestObj = closestObjCol.gameObject; return(closestObj); }
private void Goal_OnGoalScored(Enums.Teams obj) { shipRB.velocity = new Vector2(0f, 0f); PV.RPC("RPC_RespawnPlayer", RpcTarget.AllBuffered); }
void Start() { _PlayerTeam = _PlayerOwner._PlayerTeam; }
private void OnTriggerStay(Collider other) { if (other.GetComponent <Soldier>()) { // Get the current team that captures the CP _CurrentCapturerTeam = other.GetComponent <Soldier>()._AgentController._Team; // Don't capture again if CP is already captured by the team that's standing in the CP if (isCaptured && _CurrentCapturerTeam == _TeamOwner._PlayerTeam) { return; } // Check if only one team is capturing CP if (agentsInTrigger.Count > 1) { for (int i = 0; i < agentsInTrigger.Count; i++) { // Check if opposite team is trying to capture flag while staying at CP if (agentsInTrigger[i].GetComponent <AgentController>()._Team != _CurrentCapturerTeam) { isContested = true; lineRenderer.material.color = Color.yellow; return; } } } isContested = false; // Show progress bar and set line to green ProgressBar.SetActive(true); lineRenderer.material.color = Color.green; // Capturing progress while (captureProgress < captureLimit) { captureProgress += Time.deltaTime; return; } captureProgress = 0f; isCaptured = true; // Set flag color switch (_CurrentCapturerTeam) { case Enums.Teams.BLUE: flagRenderer.material.color = Color.blue; lineRenderer.material.color = Color.blue; break; case Enums.Teams.RED: flagRenderer.material.color = Color.red; lineRenderer.material.color = Color.red; break; } ProgressBar.SetActive(false); if (other.GetComponent <Soldier>() == null) { return; } // Remove flag from the possession of the previous player if (_TeamOwner != null) { _TeamOwner._CapturedCPs.Remove(this.gameObject); } // Save player that captured the flag _TeamOwner = other.GetComponent <Soldier>()._AgentController._PlayerOwner; _TeamOwner._CapturedCPs.Add(this.gameObject); } }