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.
|
|
|
using System.Collections;
|
|
|
|
using Unity.Netcode;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace Game {
|
|
|
|
public abstract class Collectable : NetworkBehaviour {
|
|
|
|
|
|
|
|
private void OnTriggerEnter2D(Collider2D other) {
|
|
|
|
var player = other.GetComponent<Ball>().LastContactPlayer;
|
|
|
|
if (player != null) {
|
|
|
|
Destroy(gameObject);
|
|
|
|
OnCollect(player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private IEnumerator Start() {
|
|
|
|
Setup();
|
|
|
|
yield return new WaitForSeconds(Duration());
|
|
|
|
Destroy(gameObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected abstract void Setup();
|
|
|
|
protected abstract float Duration();
|
|
|
|
protected abstract void OnCollect(Player collector);
|
|
|
|
}
|
|
|
|
}
|