using System; using UnityEngine; /* 用于检测在交互场景开始时候狗向玩家走过来时候,玩家与狗的碰撞检测 * 待删除,因为狗可以用距离控制 */ public class PlayerColliderController : MonoBehaviour { private GameObject thisObject; // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { thisObject = this.gameObject; } // Update is called once per frame //void Update() //{ //} private void OnTriggerEnter(Collider other) { foreach (var dogInScene in HomeController.dogsInScene) { if (dogInScene.gameObject == other.gameObject) { // 检测哪一只doginScene发生碰撞 if (thisObject.name == "Bowl_water") { dogInScene.isMovingToBowl = false; dogInScene.drinkStartTime = DateTime.Now; dogInScene.animator.SetTrigger("drink"); dogInScene.animator.SetBool("isDrinking", true); StartCoroutine(dogInScene.DrinkAnimation()); //dogInScene.DrinkAnimation(); } if (thisObject.name == "Bowl_food") { dogInScene.isMovingToBowl = false; dogInScene.eatStartTime = DateTime.Now; dogInScene.animator.SetTrigger("eat"); dogInScene.animator.SetBool("isEating", true); StartCoroutine(dogInScene.EatAnimation()); } } } } }