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)) { if (GameManager.PossessionManager.PossessingPlayer == otherPlayer && hitBall) { // Stun other player otherPlayer.StateManager.StunNetworked( otherPlayer.PlayerMovement.CurrentPosition, playerMovement.CurrentVelocity.normalized * stealKnockbackAmount, stealKnockbackLength, true); // Fill out info and transition states AudioManager.instance.StealSound.Play(.5f); PossessBallInformation info = stateManager.GetStateInformationForWriting <PossessBallInformation>(State.Possession); info.StoleBall = true; info.VictimPlayerNumber = otherPlayer.playerNumber; stateManager.TransitionToState(State.Possession, info); } } }
private void HandleCollision(GameObject thing) { Ball ball = thing.GetComponent <Ball>(); if (ball == null || ball.Owner != null || !ball.Ownable || isCoolingDown || ball.Owner == player) { return; } if (stateManager.CurrentState == State.NormalMovement || stateManager.CurrentState == State.Dash || stateManager.CurrentState == State.ChargeDash || stateManager.CurrentState == State.LayTronWall) { StunNearbyPlayers(); PossessBallInformation info = stateManager.GetStateInformationForWriting <PossessBallInformation>(State.Possession); info.StoleBall = false; stateManager.TransitionToState(State.Possession, info); } }