private void StunAndSteal(GameObject otherGameObject) { bool hitBall = otherGameObject.GetComponent <Ball>() != null; Player otherPlayer = GetAssociatedPlayer(otherGameObject); if (otherPlayer != null && (otherPlayer.team?.teamColor != player.team?.teamColor || otherPlayer.team == null || player.team == null)) { Ball ball = TrySteal(otherPlayer); bool shouldSteal = ball != null && (!onlyStealOnBallHit || hitBall); if (shouldSteal || (ball == null && !onlyStunBallCarriers)) { Stun(otherPlayer); } if (shouldSteal) { GameManager.instance.notificationManager.NotifyMessage(Message.StolenFrom, otherPlayer.gameObject); AudioManager.instance.StealSound.Play(.5f); stateManager.AttemptPossession( () => carrier.StartCarryingBall(ball), carrier.DropBall); } } }
private void HandleCollision(GameObject thing) { Ball ball = thing.GetComponent <Ball>(); if (ball == null || ball.Owner != null || !ball.Ownable || isCoolingDown) { return; } if (stateManager != null) { TeamManager last_team = ball.LastOwner?.GetComponent <Player>().team; TeamManager this_team = GetComponent <Player>().team; stateManager.AttemptPossession(() => StartCarryingBall(ball), DropBall); } else { StartCoroutine(CoroutineUtility.RunThenCallback(CarryBall(ball), DropBall)); } }