Beispiel #1
0
 void OnDestroy()
 {
     EdibleManager.GetInstance().Remove(this);
     if (LevelEndTrigger != null)
     {
         LevelEndTrigger.Trigger();
     }
 }
Beispiel #2
0
 // Start is called before the first frame update
 void Start()
 {
     EdibleManager.GetInstance().Add(this);
     if (IsCake)
     {
         EdibleManager.GetInstance().AddCake();
     }
     if (IsSausage)
     {
         EdibleManager.GetInstance().AddSausage();
     }
 }
Beispiel #3
0
    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);
    }
Beispiel #4
0
    public void Eat()
    {
        if (IsCake)
        {
            EdibleManager.GetInstance().AddCakeEaten();
        }
        if (IsSausage)
        {
            EdibleManager.GetInstance().AddSausageEaten();
        }

        if (DestroyOnEat)
        {
            Destroy(gameObject);
        }
    }