private void Timer() { timer -= Time.deltaTime / Time.timeScale; timerText.text = ((int)timer).ToString(); if (timer < 0) { SnakeController.EatSelf(); ResetTimer(); } }
private void OnTriggerEnter2D(Collider2D other) { // Debug.Log("有东西撞上来" + other.name); var parent = gameObject.transform.parent.gameObject; if (gameObject == parent.transform.GetChild(parent.transform.childCount - 1).gameObject) { return; } if (other.gameObject.CompareTag("Head")) { SnakeController.EatSelf(); GameManager.SetMessage("吃到尾巴,长度和速度减少"); GameManager.SpeedDown(); } }