using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// 进入式触发器,当玩家进入触发器范围触发内含的Event.内部的Oncall也可以不用触发器,而用其他东西主动触发 /// public class EntryTrigger : Event { [Header("玩家进入后需要执行的事件")] public Event next; /// /// 可重复执行的次数 /// [Header("可重复执行的次数")] public int count; public override void OnCall(){ next.OnCall(); } void OnTriggerEnter2D(Collider2D other){ //如果 ❗被玩家触发❗ 并且 ❗还剩下可触发次数❗ 才会触发 if(other.TryGetComponent(out MyPlayer player) && count-- > 0) OnCall(); } }