Ejemplo n.º 1
0
 public void ClearFood()
 {
     if (pickFood != null)
     {
         pickFood.BeEat();
     }
 }
Ejemplo n.º 2
0
 void OnTriggerEnter2D(Collider2D collision)
 {
     if (boxcollider.enabled == false)// 防止夹取多个食物
     {
         return;
     }
     pickFood = collision.gameObject.GetComponent <Food>();
     if (pickFood != null)
     {
         pickFood.transform.SetParent(this.transform);
         fetchFoodSeq.Kill();
         // Tweener back = transform.DOScaleY(1.48f, timer).SetEase(Ease.Linear);
         Tweener back = DOTween.To(() => spriteRenderer.size, x => spriteRenderer.size = x, new Vector2(2f, spriteRenderer.size.y), 1.1f).SetEase(Ease.Linear);
         back.OnUpdate(() =>
         {
             pickFood.Follow(spriteRenderer.size.x);
         });
         boxcollider.enabled = false; // 防止夹取多个食物
         back.OnComplete(() =>
         {
             isIdle = true;
             boxcollider.enabled = true;
             if (transform.childCount > 0)
             {
                 if (OnEat != null)
                 {
                     OnEat.Invoke(pickFood.foodType);
                 }
                 pickFood.BeEat();
                 //  Destroy(food.gameObject); // 或添加食用动作?
                 //Debug.Log("饱食度++");
             }
         });
     }
 }