feat(): 大量更新
This commit is contained in:
49
Assets/Script/Gameplay/Combat/CombatTrigger.cs
Normal file
49
Assets/Script/Gameplay/Combat/CombatTrigger.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Gameplay;
|
||||
using Share;
|
||||
using Gameplay.Enemy;
|
||||
using Gameplay.Player;
|
||||
|
||||
namespace Gameplay.Combat
|
||||
{
|
||||
[RequireComponent(typeof(Collider))]
|
||||
public class CombatTrigger : MonoBehaviour
|
||||
{
|
||||
//[Tooltip("战斗管理器引用(场景中单例/对象)")]
|
||||
private CombatFlowManager combatManager;
|
||||
|
||||
[Tooltip("触发时指定的玩家 Combatant(可为空,manager 使用已配置的)")]
|
||||
public PlayerController player;
|
||||
|
||||
[Tooltip("触发时指定的敌人 Combatant(可为空,manager 使用已配置的)")]
|
||||
public EnemyController enemy;
|
||||
|
||||
[Tooltip("被触发后是否自动禁用触发器,避免重复触发")]
|
||||
public bool disableAfterTrigger = true;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
combatManager = CombatFlowManager.Instance;
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
// Collider 需要 isTrigger
|
||||
var col = GetComponent<Collider>();
|
||||
col.isTrigger = true;
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
// 简单检测:玩家层或带有 "Player" 标签的物体
|
||||
if (combatManager == null) return;
|
||||
|
||||
if (other.CompareTag("Player") || other.gameObject.layer == LayerMask.NameToLayer("Player"))
|
||||
{
|
||||
combatManager.StartCombat(player, enemy);
|
||||
if (disableAfterTrigger) gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user