using System.Collections; using System.Collections.Generic; using UnityEngine; public class Dot : MonoBehaviour { public float Score; public bool SuperDot;//超级豆子 private void Awake() { } private void OnTriggerEnter2D(Collider2D collision) { if(collision.gameObject.layer == LayerMask.NameToLayer("PacMan")) { if (SuperDot && !collision.gameObject.GetComponent().invincible) { collision.gameObject.GetComponent().invincible = true;//设置主角无敌 } else if(SuperDot) { collision.gameObject.GetComponent().timer = 0; //重置无敌时间 } GameManager.instance.AddScore(Score); Destroy(this.gameObject); } } }