private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            SumoWeight sumoWeight = other.gameObject.GetComponent <SumoWeight>();
            if (sumoWeight != null)
            {
                switch (_foodType)
                {
                case FoodType.healthy:
                    sumoWeight.AddHealthToPlayer(value);
                    FindObjectOfType <FoodManager>().AddSize(value);
                    break;

                case FoodType.spoiled:
                    sumoWeight.RemoveHealthFromPlayer(value);
                    FindObjectOfType <FoodManager>().RemoveSize(value);
                    break;

                case FoodType.deadly:
                    sumoWeight.KillPlayer();
                    break;

                default:
                    break;
                }
            }
            Destroy(gameObject);
        }
    }
Example #2
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         SumoWeight sumoWeight = other.gameObject.GetComponent <SumoWeight>();
         if (sumoWeight != null)
         {
             sumoWeight.KillPlayer();
             Destroy(gameObject);
         }
     }
 }