Пример #1
0
    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);
        }
    }
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Player"))
     {
         FindObjectOfType <FoodManager>().RemoveSize(value);
         SumoWeight sumoWeight = other.gameObject.GetComponent <SumoWeight>();
         if (sumoWeight != null)
         {
             sumoWeight.RemoveHealthFromPlayer(value);
         }
         Destroy(gameObject);
     }
 }