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
704 B
34 lines
704 B
using UnityEngine;
|
|
|
|
namespace Game {
|
|
public class DeathGate : MonoBehaviour {
|
|
|
|
public Side side;
|
|
|
|
private Player thisPlayer, otherPlayer;
|
|
|
|
private void Start() {
|
|
var p1 = GameManager.Singleton.Player1;
|
|
var p2 = GameManager.Singleton.Player2;
|
|
if (p1.Side == side) {
|
|
thisPlayer = p1;
|
|
otherPlayer = p2;
|
|
} else {
|
|
thisPlayer = p2;
|
|
otherPlayer = p1;
|
|
}
|
|
}
|
|
|
|
private void OnTriggerEnter2D(Collider2D ballCollider2D) {
|
|
var ball = ballCollider2D.GetComponent<Ball>();
|
|
|
|
if (ball.LastContactPlayer != null)
|
|
otherPlayer.GainScore();
|
|
|
|
GameManager.Singleton.RemoveBall(ball);
|
|
|
|
if (ball.IsPermanent)
|
|
GameManager.Singleton.SpawnBall(thisPlayer, true);
|
|
}
|
|
}
|
|
}
|
|
|