|
|
|
@ -6,17 +6,22 @@ using Random = UnityEngine.Random; |
|
|
|
|
|
|
|
|
|
namespace Game { |
|
|
|
|
public class Ball : NetworkBehaviour { |
|
|
|
|
|
|
|
|
|
public Rigidbody2D Rb { get; private set; } |
|
|
|
|
public Player LastContactPlayer { get; private set; } |
|
|
|
|
|
|
|
|
|
private CircleCollider2D Collider { get; set; } |
|
|
|
|
|
|
|
|
|
public Player LastContactPlayer { get; set; } |
|
|
|
|
|
|
|
|
|
public float Radius { |
|
|
|
|
get => transform.localScale.x * Collider.radius; |
|
|
|
|
set => transform.localScale = new Vector3(1, 1, 1) * value * 2; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void OnCollisionEnter2D(Collision2D other) { |
|
|
|
|
if (other.gameObject.TryGetComponent(out Player player)) |
|
|
|
|
LastContactPlayer = player; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void Awake() { |
|
|
|
|
Rb = GetComponent<Rigidbody2D>(); |
|
|
|
|
Collider = GetComponent<CircleCollider2D>(); |
|
|
|
|