public static void NotifyTriggerEnter(Collider c, GameObject caller, _OnTriggerExit onTriggerExit)
    {
        ReliableOnTriggerExit thisComponent = null;

        ReliableOnTriggerExit[] ftncs = c.gameObject.GetComponents <ReliableOnTriggerExit>();
        foreach (ReliableOnTriggerExit ftnc in ftncs)
        {
            if (ftnc.thisCollider == c)
            {
                thisComponent = ftnc;
                break;
            }
        }
        if (thisComponent == null)
        {
            thisComponent = c.gameObject.AddComponent <ReliableOnTriggerExit>();
            thisComponent.thisCollider = c;
        }
        // Unity bug? (!!!!): Removing a Rigidbody while the collider is in contact will call OnTriggerEnter twice, so I need to check to make sure it isn't in the list twice
        // In addition, force a call to NotifyTriggerExit so the number of calls to OnTriggerEnter and OnTriggerExit match up
        if (thisComponent.waitingForOnTriggerExit.ContainsKey(caller) == false)
        {
            thisComponent.waitingForOnTriggerExit.Add(caller, onTriggerExit);
            thisComponent.enabled = true;
        }
        else
        {
            thisComponent.ignoreNotifyTriggerExit = true;
            thisComponent.waitingForOnTriggerExit[caller].Invoke(c);
            thisComponent.ignoreNotifyTriggerExit = false;
        }
    }
    public static void NotifyTriggerExit(Collider c, GameObject caller)
    {
        if (c == null)
        {
            return;
        }

        ReliableOnTriggerExit thisComponent = null;

        ReliableOnTriggerExit[] ftncs = c.gameObject.GetComponents <ReliableOnTriggerExit>();
        foreach (ReliableOnTriggerExit ftnc in ftncs)
        {
            if (ftnc.thisCollider == c)
            {
                thisComponent = ftnc;
                break;
            }
        }
        if (thisComponent != null && thisComponent.ignoreNotifyTriggerExit == false)
        {
            thisComponent.waitingForOnTriggerExit.Remove(caller);
            if (thisComponent.waitingForOnTriggerExit.Count == 0)
            {
                thisComponent.enabled = false;
            }
        }
    }
 /** Puts the pressure plate in a released state when the SwapCube exits the top area.
  *
  *  @param other
  */
 private void OnTriggerExit(Collider other)
 {
     ReliableOnTriggerExit.NotifyTriggerExit(other, gameObject);
     if (other.tag == "SwapCube")
     {
         animator.SetBool("isPressed", false);
         SwitchToggle.Invoke(false);
     }
 }
Exemple #4
0
    public void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "TowerElement")
        {
            //Notify that there is an object which enter on the trigger (Unity Bug Fix)
            ReliableOnTriggerExit.NotifyTriggerEnter(other, gameObject, OnTriggerExit);

            //Increment the number of tower elements in the last Floor
            LastFloorTowerElementsNumber++;
        }
    }
Exemple #5
0
 private void OnTriggerEnter(Collider other)
 {
     Debug.Log("enter:" + other);
     ReliableOnTriggerExit.NotifyTriggerEnter(other, gameObject, OnTriggerExit);
     if (other != GameObject.Find("Base").GetComponent <Collider>())
     {
         isTrigger = true;
         StartCoroutine(Press(tempo));
     }
     Debug.Log("enter:" + other);
 }
Exemple #6
0
    private void OnTriggerExit(Collider other)
    {
        // return if the collider does not get affected by wind
        if (!(other.TryGetComponent(out Tag tag) && tag.HasTag(TagType.AffectedByWind)))
        {
            return;
        }

        ReliableOnTriggerExit.NotifyTriggerExit(other, gameObject);
        rigidbodies.Remove(other.gameObject.GetComponent <Rigidbody>());
    }
    private void OnTriggerExit(Collider other)
    {
        ReliableOnTriggerExit.NotifyTriggerExit(other, gameObject);

        overlap--;

        if (!IsPressed())
        {
            transform.position = startPos;
            releaseEvent.Invoke();
        }
    }
    private void OnTriggerEnter(Collider other)
    {
        ReliableOnTriggerExit.NotifyTriggerEnter(other, gameObject, OnTriggerExit);

        overlap++;

        if (IsPressed())
        {
            pressEvent.Invoke();
        }

        transform.position = startPos - new Vector3(0, pressHeight, 0);
    }
Exemple #9
0
    public void OnTriggerExit(Collider other)
    {
        //Notify that there is an object which exits the trigger(Unity Bug Fix : unable to detect Disabled Object with Ontrigger Exit)
        ReliableOnTriggerExit.NotifyTriggerExit(other, gameObject);

        //Decrement the number of tower elements in the last Floor
        LastFloorTowerElementsNumber--;

        //Verify the floor Number
        TowerColorGameManager.Instance.VerifyFloorNumber();

        //Disable the Tower Element Component
        other.gameObject.GetComponent <TowerElement>().enabled = false;
    }
Exemple #10
0
    private void OnTriggerExit(Collider other)
    {
        GolfBall gb = other.GetComponent <GolfBall>();

        if (gb)
        {
            ReliableOnTriggerExit.NotifyTriggerExit(other, gameObject);

            if (gb is AbilityBall ab)
            {
                ab.StartCooldown();
            }

            nearbyBalls.Remove(gb);
        }
    }
Exemple #11
0
    private void OnTriggerEnter(Collider other)
    {
        GolfBall gb = other.GetComponent <GolfBall>();

        if (gb)
        {
            if (gb is AbilityBall ability)
            {
                if (!ability.CheckInUse())
                {
                    return;
                }
            }
            nearbyBalls.Add(gb);
            ReliableOnTriggerExit.NotifyTriggerEnter(other, gameObject, OnTriggerExit);
        }
    }
Exemple #12
0
 private void OnTriggerExit(Collider other)
 {
     ReliableOnTriggerExit.NotifyTriggerExit(other, gameObject);
     isTrigger = false;
     if (other != GameObject.Find("Base").GetComponent <Collider>())
     {
         tempo     = 0.1f;
         isTrigger = false;
         if (other == GameObject.Find("Player").GetComponent <Collider>())
         {
             StartCoroutine(Press(tempo));
         }
         else
         {
             tempo = 5f;
             StartCoroutine(Press(tempo));
         }
     }
 }
Exemple #13
0
    private void OnTriggerExit2D(Collider2D other)
    {
        try
        {
            ReliableOnTriggerExit.NotifyTriggerExit(other, gameObject);

            if (other.gameObject.tag == "Marie")
            {
                triggering     = false;
                continueE.text = " ";
                continueE.gameObject.SetActive(false);
                textDisplay.gameObject.SetActive(false);
                SpeechBox.enabled   = false;
                blackScreen.enabled = false;
            }
        }
        catch (System.Exception e)
        {
            Debug.Log("meow");
        }
    }
Exemple #14
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        ReliableOnTriggerExit.NotifyTriggerEnter(other, gameObject, OnTriggerExit2D);
        if (other.gameObject.tag == "Marie")
        {
            triggering = true;
            continueE.gameObject.SetActive(true);
            continueE.text = "Press E to continue...";
            textDisplay.gameObject.SetActive(true);
            SpeechBox.enabled   = true;
            blackScreen.enabled = true;

            NPCsound.Play();

            if (Marie.GetComponent <MarieController>().equipSpray)
            {
                Marie.GetComponent <MarieController>().equipSpray = false;
                Marie.GetComponent <MarieController>().canAttack  = true;
            }
        }
    }
Exemple #15
0
 void OnTriggerExit2D(Collider2D encounter)
 {
     ReliableOnTriggerExit.NotifyTriggerExit(encounter, gameObject);
     if (encounter.name == "Chest")
     {
         anim = encounter.GetComponent <Animator>();
         anim.SetBool("Encountered", false);
     }
     else if (encounter.tag == "Entrance")
     {
         Destination    = null;
         storyHead.text = GameModel.currentLocale.Name;
     }
     else
     {
         storyHead.text      = GameModel.currentLocale.Name;
         storyNarrative.text = GameModel.currentLocale.Story;
     }
     GameModel.pickUpAble    = false;
     GameModel.currentIntObj = null;
     failsafe = false;
 }
Exemple #16
0
 // Start is called before the first frame update
 void OnTriggerEnter2D(Collider2D encounter)
 {
     ReliableOnTriggerExit.NotifyTriggerEnter(encounter, gameObject, OnTriggerExit2D);
     if (encounter.tag == "Trap")
     {
         Debug.Log("Got go " + encounter.name);
         GameModel.nextLocale = GameModel.currentLocale.getLocation(encounter.name);
         if (GameModel.nextLocale == null)
         {
             storyHead.text      = (GameModel.currentLocale.Name);
             storyNarrative.text = ($"Sorry can't go {encounter.name}");
         }
         else
         {
             GameModel.loadLevel.LoadLocation();
         }
         failsafe = true;
     }
     else if (encounter.tag == "Entrance")
     {
         GameModel.currentIntObj = encounter.gameObject;
         if (encounter.name != "house")
         {
             GameModel.nextLocale   = GameModel.currentLocale.getLocation(encounter.name);
             GameModel.nextLocation = encounter.name;
             storyHead.text         = "Type to 'enter' to go to " + GameModel.currentLocale.getLocation(GameModel.currentIntObj.name).Name;
         }
         else
         {
             storyHead.text      = "House";
             storyNarrative.text = encounter.GetComponent <Text>().text;
         }
     }
     else if (encounter.tag == "Respawn")
     {
         if (encounter.name == "RespawnerCave")
         {
             Vector3 temp = new Vector3(2.4f, 1.47f, 0);
             playerObj.transform.position = temp;
             playerObj.GetComponent <PlayerMovement>().horizontalMove = 0f;
         }
         else if (encounter.name == "RespawnerCave2")
         {
             Vector3 temp = new Vector3(1.503098f, -1.618875f, 0);
             playerObj.transform.position = temp;
             playerObj.GetComponent <PlayerMovement>().horizontalMove = 0f;
         }
     }
     else if (encounter.tag == "Sign")
     {
         GameModel.currentIntObj = encounter.gameObject;
         storyHead.text          = GameModel.currentIntObj.name;
         storyNarrative.text     = GameModel.currentIntObj.GetComponent <Text>().text;
     }
     else if (encounter.tag != "Entrance")
     {
         if (encounter.name == "Chest")
         {
             anim = encounter.GetComponent <Animator>();
             anim.SetBool("Encountered", true);
             GameModel.pickUpAble = false;
         }
         else
         {
             GameModel.pickUpAble = true;
         }
         GameModel.currentIntObj = encounter.gameObject;
         storyHead.text          = GameModel.currentIntObj.tag;
         storyNarrative.text     = GameModel.currentIntObj.GetComponent <Text>().text;
         playerObj.GetComponent <PlayerMovement>().horizontalMove = 0f;
         playerObj.GetComponent <PlayerMovement>().locked         = true;
         playerObj.GetComponent <PlayerMovement>().enabled        = false;
         if (encounter.name == "Coin")
         {
             GameModel.itemToAdd = 0;
         }
         else if (encounter.name == "Rune")
         {
             GameModel.itemToAdd = 1;
         }
         else if (encounter.name == "Key")
         {
             GameModel.itemToAdd = 2;
         }
         inputManager.GetComponent <MenuController>().openText();
         failsafe = true;
     }
 }
    //when the food is moved off the plate
    private void OnTriggerExit2D(Collider2D collision)
    {
        //my attempt again to fix bug
        ReliableOnTriggerExit.NotifyTriggerExit(collision, gameObject);


        //same as above but subtraction
        if (collision.gameObject.name == "banana")
        {
            calories = calories - 105;
            carbs = carbs - 27;
            fiber = fiber - 3;
            sugar = sugar - 14;
            fat = fat - 0;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);


        }
        if (collision.gameObject.name == "broccoli")
        {
            calories = calories - 34;
            carbs = carbs - 7;
            fiber = fiber - 0;
            sugar = sugar - 2;
            fat = fat - 0;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "burger")
        {
            calories = calories - 300;
            carbs = carbs - 33;
            fiber = fiber - 2;
            sugar = sugar - 7;
            fat = fat - 12;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "candy")
        {
            calories = calories - 280;
            carbs = carbs - 35;
            fiber = fiber - 0;
            sugar = sugar - 29;
            fat = fat - 14;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "carrot")
        {
            calories = calories - 41;
            carbs = carbs - 10;
            fiber = fiber - 3;
            sugar = sugar - 5;
            fat = fat - 0;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "cheese")
        {
            calories = calories - 62;
            carbs = carbs - 2;
            fiber = fiber - 0;
            sugar = sugar - 1;
            fat = fat - 5;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "chicken")
        {
            calories = calories - 220;
            carbs = carbs - 0;
            fiber = fiber - 0;
            sugar = sugar - 0;
            fat = fat - 24;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "chickenNuggets")
        {
            calories = calories - 480;
            carbs = carbs - 24;
            fiber = fiber - 0;
            sugar = sugar - 0;
            fat = fat - 32;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }

        if (collision.gameObject.name == "beansAndRice")
        {
            calories = calories - 221;
            carbs = carbs - 86;
            fiber = fiber - 9;
            sugar = sugar - 2;
            fat = fat - 3;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }

        if (collision.gameObject.name == "chips")
        {
            calories = calories - 274;
            carbs = carbs - 25;
            fiber = fiber - 0;
            sugar = sugar - 0;
            fat = fat - 19;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "cookie")
        {
            calories = calories - 120;
            carbs = carbs - 23;
            fiber = fiber - 0;
            sugar = sugar - 14;
            fat = fat - 4;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "cupcake")
        {
            calories = calories - 240;
            carbs = carbs - 35;
            fiber = fiber - 0;
            sugar = sugar - 26;
            fat = fat - 10;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "donut")
        {
            calories = calories - 280;
            carbs = carbs - 31;
            fiber = fiber - 1;
            sugar = sugar - 13;
            fat = fat - 15;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "egg")
        {
            calories = calories - 78;
            carbs = carbs - 0;
            fiber = fiber - 0;
            sugar = sugar - 0;
            fat = fat - 5;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "frappucino")
        {
            calories = calories - 420;
            carbs = carbs - 67;
            fiber = fiber - 0;
            sugar = sugar - 66;
            fat = fat - 15;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "fries")
        {
            calories = calories - 378;
            carbs = carbs - 50;
            fiber = fiber - 5;
            sugar = sugar - 0;
            fat = fat - 18;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "hotdog")
        {
            calories = calories - 316;
            carbs = carbs - 31;
            fiber = fiber - 0;
            sugar = sugar - 7;
            fat = fat - 16;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "ice_cream")
        {
            calories = calories - 590;
            carbs = carbs - 79;
            fiber = fiber - 0;
            sugar = sugar - 61;
            fat = fat - 26;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "pasta")
        {
            calories = calories - 131;
            carbs = carbs - 25;
            fiber = fiber - 0;
            sugar = sugar - 0;
            fat = fat - 1;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "pizza")
        {
            calories = calories - 272;
            carbs = carbs - 34;
            fiber = fiber - 0;
            sugar = sugar - 0;
            fat = fat - 10;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "potatoes")
        {
            calories = calories - 180;
            carbs = carbs - 23;
            fiber = fiber - 2;
            sugar = sugar - 2;
            fat = fat - 9;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "salad")
        {
            calories = calories - 148;
            carbs = carbs - 7;
            fiber = fiber - 0;
            sugar = sugar - 3;
            fat = fat - 13;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "soda")
        {
            calories = calories - 150;
            carbs = carbs - 39;
            fiber = fiber - 0;
            sugar = sugar - 39;
            fat = fat - 0;


            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }

        if (collision.gameObject.name == "steak")
        {
            calories = calories - 207;
            carbs = carbs - 0;
            fiber = fiber - 0;
            sugar = sugar - 0;
            fat = fat - 12;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "sandwhich")
        {
            calories = calories - 419;
            carbs = carbs - 42;
            fiber = fiber - 0;
            sugar = sugar - 5;
            fat = fat - 21;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "sweetpotato")
        {
            calories = calories - 112;
            carbs = carbs - 26;
            fiber = fiber - 4;
            sugar = sugar - 5;
            fat = fat - 0;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "taco")
        {
            calories = calories - 157;
            carbs = carbs - 14;
            fiber = fiber - 3;
            sugar = sugar - 0;
            fat = fat - 9;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "tamale")
        {
            calories = calories - 284;
            carbs = carbs - 34;
            fiber = fiber - 3;
            sugar = sugar - 0;
            fat = fat - 9;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "whitebread")
        {
            calories = calories - 79;
            carbs = carbs - 15;
            fiber = fiber - 0;
            sugar = sugar - 2;
            fat = fat - 0;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);

        }
        if (collision.gameObject.name == "wholegrainbread")
        {
            calories = calories - 69;
            carbs = carbs - 12;
            fiber = fiber - 2;
            sugar = sugar - 2;
            fat = fat - 1;

            nutrientControl.subCalories(calories);
            nutrientControl.subCarbs(carbs);
            nutrientControl.subFiber(fiber);
            nutrientControl.subSugar(sugar);
            nutrientControl.subFat(fat);


        }
        //checks if they were subtracted in log
        Debug.Log("These are the calories: " + calories);
        //setCountText();

    }

    //doesnt destroy
    private void Awake()
    {
        DontDestroyOnLoad(transform.gameObject);
    }

   // public void setCountText()
    //{
    //    sugarText.text = "Sugar: " + sugar.ToString() + "g";
    //    carbText.text = "Carb: " + carbs.ToString() + "g";
    //    caloriesText.text = "Calories: " + calories.ToString() + "g";
    //    fiberText.text = "Fiber: " + fiber.ToString() + "g";
   // }


        //if there is a collision of 2d colliders - ie when the food is moved onto the plate
    private void OnTriggerEnter2D(Collider2D collision)
    {
        //my attempt to fix the issue see Reliable on trigger exit script
        ReliableOnTriggerExit.NotifyTriggerEnter2D(collision, gameObject, OnTriggerExit2D);

        //same for each food below - just adds the correct number to the corresponding varialbe and then adds it to the nutrient control GameControl object
        if (collision.gameObject.name == "banana")
        {
            calories = calories + 105;
            carbs = carbs + 27;
            fiber = fiber + 3;
            sugar = sugar + 14;
            fat = fat + 0;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);


            //Debug.Log(calories);
        }
        if (collision.gameObject.name == "broccoli")
        {
            calories = calories + 34;
            carbs = carbs + 7;
            fiber = fiber + 0;
            sugar = sugar + 2;
            fat = fat + 0;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }


        if (collision.gameObject.name == "beansAndRice")
        {
            calories = calories + 221;
            carbs = carbs + 86;
            fiber = fiber + 9;
            sugar = sugar + 2;
            fat = fat + 3;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "burger")
        {
            calories = calories + 300;
            carbs = carbs + 33;
            fiber = fiber + 2;
            sugar = sugar + 7;
            fat = fat + 12;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "candy")
        {
            calories = calories + 280;
            carbs = carbs + 35;
            fiber = fiber + 0;
            sugar = sugar + 29;
            fat = fat + 14;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "carrot")
        {
            calories = calories + 41;
            carbs = carbs + 10;
            fiber = fiber + 3;
            sugar = sugar + 5;
            fat = fat + 0;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "cheese")
        {
            calories = calories + 62;
            carbs = carbs + 2;
            fiber = fiber + 0;
            sugar = sugar + 1;
            fat = fat + 5;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "chicken")
        {
            calories = calories + 220;
            carbs = carbs + 0;
            fiber = fiber + 0;
            sugar = sugar + 0;
            fat = fat + 24;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "chickenNuggets")
        {
            calories = calories + 480;
            carbs = carbs + 24;
            fiber = fiber + 0;
            sugar = sugar + 0;
            fat = fat + 32;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "chips")
        {
            calories = calories + 274;
            carbs = carbs + 25;
            fiber = fiber + 0;
            sugar = sugar + 0;
            fat = fat + 19;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "cookie")
        {
            calories = calories + 120;
            carbs = carbs + 23;
            fiber = fiber + 0;
            sugar = sugar + 14;
            fat = fat + 4;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);
            Debug.Log("These are the calories: " + calories);

        }
        if (collision.gameObject.name == "cupcake")
        {
            calories = calories + 240;
            carbs = carbs + 35;
            fiber = fiber + 0;
            sugar = sugar + 26;
            fat = fat + 10;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "donut")
        {
            calories = calories + 280;
            carbs = carbs + 31;
            fiber = fiber + 1;
            sugar = sugar + 13;
            fat = fat + 15;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "egg")
        {
            calories = calories + 78;
            carbs = carbs + 0;
            fiber = fiber + 0;
            sugar = sugar + 0;
            fat = fat + 5;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "frappucino")
        {
            calories = calories + 420;
            carbs = carbs + 67;
            fiber = fiber + 0;
            sugar = sugar + 66;
            fat = fat + 15;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "fries")
        {
            calories = calories + 378;
            carbs = carbs + 50;
            fiber = fiber + 5;
            sugar = sugar + 0;
            fat = fat + 18;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "hotdog")
        {
            calories = calories + 316;
            carbs = carbs + 31;
            fiber = fiber + 0;
            sugar = sugar + 7;
            fat = fat + 16;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "ice_cream")
        {
            calories = calories + 590;
            carbs = carbs + 79;
            fiber = fiber + 0;
            sugar = sugar + 61;
            fat = fat + 26;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "pasta")
        {
            calories = calories + 131;
            carbs = carbs + 25;
            fiber = fiber + 0;
            sugar = sugar + 0;
            fat = fat + 1;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "pizza")
        {
            calories = calories + 272;
            carbs = carbs + 34;
            fiber = fiber + 0;
            sugar = sugar + 0;
            fat = fat + 10;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "potatoes")
        {
            calories = calories + 180;
            carbs = carbs + 23;
            fiber = fiber + 2;
            sugar = sugar + 2;
            fat = fat + 9;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "salad")
        {
            calories = calories + 148;
            carbs = carbs + 7;
            fiber = fiber + 0;
            sugar = sugar + 3;
            fat = fat + 13;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "soda")
        {
            calories = calories + 150;
            carbs = carbs + 39;
            fiber = fiber + 0;
            sugar = sugar + 39;
            fat = fat + 0;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "steak")
        {
            calories = calories + 207;
            carbs = carbs + 0;
            fiber = fiber + 0;
            sugar = sugar + 0;
            fat = fat + 12;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "sandwhich")
        {
            calories = calories + 419;
            carbs = carbs + 42;
            fiber = fiber + 0;
            sugar = sugar + 5;
            fat = fat + 21;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "sweetpotato")
        {
            calories = calories + 112;
            carbs = carbs + 26;
            fiber = fiber + 4;
            sugar = sugar + 5;
            fat = fat + 0;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }

        if (collision.gameObject.name == "taco")
        {
            calories = calories + 157;
            carbs = carbs + 14;
            fiber = fiber + 3;
            sugar = sugar + 0;
            fat = fat + 9;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "tamale")
        {
            calories = calories + 284;
            carbs = carbs + 34;
            fiber = fiber + 3;
            sugar = sugar + 0;
            fat = fat + 9;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "whitebread")
        {
            calories = calories + 79;
            carbs = carbs + 15;
            fiber = fiber + 0;
            sugar = sugar + 2;
            fat = fat + 0;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }
        if (collision.gameObject.name == "wholegrainbread")
        {
            calories = calories + 69;
            carbs = carbs + 12;
            fiber = fiber + 2;
            sugar = sugar + 2;
            fat = fat + 1;

            nutrientControl.AddCalories(calories);
            nutrientControl.AddCarbs(carbs);
            nutrientControl.AddFiber(fiber);
            nutrientControl.AddSugar(sugar);
            nutrientControl.AddFat(fat);

        }

        //debug to check calories were added
        Debug.Log("These are the calories: " + calories);
       //setCountText();
    }