void OnDestroy() { EdibleManager.GetInstance().Remove(this); if (LevelEndTrigger != null) { LevelEndTrigger.Trigger(); } }
// Start is called before the first frame update void Start() { EdibleManager.GetInstance().Add(this); if (IsCake) { EdibleManager.GetInstance().AddCake(); } if (IsSausage) { EdibleManager.GetInstance().AddSausage(); } }
private Edible GetClosestEdible() { List <Edible> edibles = EdibleManager.GetInstance().GetAll(); Edible closestEdible = null; foreach (var edible in edibles) { if (closestEdible == null || DistanceTo(edible) < DistanceTo(closestEdible)) { closestEdible = edible; } } return(closestEdible); }
public void Eat() { if (IsCake) { EdibleManager.GetInstance().AddCakeEaten(); } if (IsSausage) { EdibleManager.GetInstance().AddSausageEaten(); } if (DestroyOnEat) { Destroy(gameObject); } }