Files
gold_dolphin/unity/Assets/Scenes/DoorPortal.cs
T
ksh999000 c06a8abad0 增加传送门逻辑
增加无敌时间
2026-07-05 22:50:58 +08:00

33 lines
934 B
C#

using UnityEngine;
using GameFramework;
using IndianOceanAssets.Engine2_5D;
/// <summary>
/// 传送门/出口 Door —— 玩家碰触后触发胜利流程。
/// 挂载在 Door 预制体根对象上,Collider 设为 Trigger。
/// </summary>
public class DoorPortal : MonoBehaviour
{
void Awake()
{
var col = GetComponent<Collider>();
if (col != null) col.isTrigger = true;
}
void OnTriggerEnter(Collider other)
{
if (!other.CompareTag("Player")) return;
// 玩家进入传送门后永久无敌,胜利流程中不再掉血
var health = other.GetComponent<HealthSystem>();
if (health != null)
{
health.MakeInvincible(); // duration<=0 即永久无敌
Debug.Log("[DoorPortal] 玩家已进入无敌状态");
}
Debug.Log("[DoorPortal] 玩家进入传送门,触发胜利!");
GameManager.Win();
}
}