void OnCollisionEnter(Collision other) { if (other.gameObject.name == "Floor") { rigidbody.velocity = Vector3.zero; transform.localPosition = UnityEngine.Random.insideUnitSphere * 3f; playing = true; rigidbody.useGravity = false; return; } if (other.gameObject.layer == LayerMask.NameToLayer("Player")) { Player otherPlayer = other.gameObject.GetComponent <Player>(); if (otherPlayer.Team != Team) { //rigidbody.AddForce(other.relativeVelocity, ForceMode.Impulse); if (UnityEngine.Random.Range(0f, 1f) < Stats.TacklingProb) { otherPlayer.GotTackled(); } } } if (!playing) { return; } if (other.gameObject.layer == LayerMask.NameToLayer("Snitch")) { Snitch s = other.gameObject.GetComponent <Snitch>(); if (s) { PlayerScoredEvent(Stats.PlayerID, 1); transform.position = Team.StartingPoint.position; rigidbody.velocity = Vector3.zero; } } }
/** * Initialize game by spawning players * */ void Awake() { // Default team size to 5 if (!(teamSize >= 5 && teamSize <= 20)) { teamSize = 5; } team0.players = new List <GameObject>(); team1.players = new List <GameObject>(); for (int i = 0; i < teamSize; i++) { GameObject p1 = createPlayer(isTeam0: false); team1.players.Add(p1); GameObject p0 = createPlayer(isTeam0: true); team0.players.Add(p0); } textMeshGameOver.SetActive(false); snitchScript = snitch.GetComponent <Snitch>(); instance = this; updateUI(); }
private async Task SetRichPoints(Snitch snitch) { snitch.Rich.Points = (int)Math.Round(await snitch.SnitchPoll.Votes .AsQueryable() .AverageAsync(v => v.Points), 0); }
private void CompleteRich(Snitch snitch, AppUser user) { snitch.Rich.Completed = DateTime.UtcNow; snitch.Rich.Creator = user; }
private void Start() { snitch = GameObject.FindGameObjectWithTag("Snitch").GetComponent <Snitch>(); UILabel = GetComponentInChildren <Text>(); }
private void OnPoleSuccessAsync(Snitch snitch, bool targetIsGuilty) { snitch.Rich.Target = targetIsGuilty ? snitch.Target : snitch.Creator; }