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