c1_unity/Assets/Scripts/Component/Battle/BattleControlWarningCollider.cs
2023-04-03 11:04:31 +08:00

86 lines
2.6 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BF
{
public class BattleControlWarningCollider : MonoBehaviour
{
public BattleControlWarning parentWarning;
public BoxCollider boxCollider;
public SphereCollider sphereCollider;
protected int warningType; // 预警形状
protected bool colliderEnable; // 是否有效
public void InitWarningType(BattleControlWarning parentWarning, int warningType)
{
this.parentWarning = parentWarning;
this.warningType = warningType;
}
public void SetColliderEnable()
{
colliderEnable = true;
if (warningType == 1)
{
if (!ReferenceEquals(boxCollider, null))
{
boxCollider.enabled = true;
}
}
else if (warningType == 2)
{
if (!ReferenceEquals(sphereCollider, null))
{
sphereCollider.enabled = true;
}
}
}
public void SetColliderDisable()
{
colliderEnable = false;
if (warningType == 1)
{
if (!ReferenceEquals(boxCollider, null))
{
boxCollider.enabled = false;
}
}
else if (warningType == 2)
{
if (!ReferenceEquals(sphereCollider, null))
{
sphereCollider.enabled = false;
}
}
}
private void OnTriggerEnter(Collider other)
{
// if (!ReferenceEquals(parentWarning, null) && parentWarning.GetIsEnable() && !parentWarning.GetIsRecycle() && colliderEnable)
{
BFMain.Instance.BattleMgr.AddEffectHeroWarning(parentWarning.GetUniqueId());
}
}
private void OnTriggerStay(Collider other)
{
// if (!ReferenceEquals(parentWarning, null) && parentWarning.GetIsEnable() && !parentWarning.GetIsRecycle() && colliderEnable)
{
BFMain.Instance.BattleMgr.AddEffectHeroWarning(parentWarning.GetUniqueId());
}
}
private void OnTriggerExit(Collider other)
{
// if (!ReferenceEquals(parentWarning, null) && parentWarning.GetIsEnable() && !parentWarning.GetIsRecycle() && colliderEnable)
{
BFMain.Instance.BattleMgr.RemoveEffectHeroWarning(parentWarning.GetUniqueId());
}
}
}
}