You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
734 B

1 year ago
using System;
using Unity.Netcode;
using UnityEngine;
namespace Game {
public class Ball : NetworkBehaviour {
1 year ago
public Rigidbody2D Rb { get; private set; }
1 year ago
1 year ago
private CircleCollider2D Collider { get; set; }
public float Radius {
get => transform.localScale.x * Collider.radius;
set => transform.localScale = new Vector3(1, 1, 1) * value * 2;
}
1 year ago
public bool IsAlive {
get {
float y = transform.position.y;
float y1 = BorderSize.Singleton.y1;
float y2 = BorderSize.Singleton.y2;
return y > y1 && y < y2;
}
}
private void OnEnable() {
1 year ago
Rb = GetComponent<Rigidbody2D>();
Collider = GetComponent<CircleCollider2D>();
1 year ago
}
private void Start() {
1 year ago
Rb.velocity = new Vector2(0, 20);
1 year ago
}
}
}