OldBlueWater/BlueWater/Assets/02.Scripts/Weapon/CloseWeapon.cs
NTG_Lenovo dc00036723 #29 유닛 이동 방식 수정 중
1. IDamageable 인터페이스 수정
2. Ai 프리팹 크기 변경, 깃발 LookAt 추가
3. Boat 공격 선택 매개변수 제거
2023-08-31 16:38:08 +09:00

64 lines
1.9 KiB
C#

using System;
using UnityEngine;
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
public class CloseWeapon : MonoBehaviour
{
#region Property and variable
private bool isAttacked;
private AttackerType attackerType;
private AiStat attackerStat;
#endregion
#region Unity built-in function
private void OnTriggerEnter(Collider other)
{
if (isAttacked) return;
if (other.gameObject.layer == LayerMask.NameToLayer("HitBox"))
{
switch (attackerType)
{
case AttackerType.NONE:
break;
case AttackerType.OFFENSE:
if (!other.gameObject.CompareTag("Enemy") && !other.gameObject.CompareTag("House"))
{
return;
}
break;
case AttackerType.DEFENSE:
if (!other.gameObject.CompareTag("Player") && !other.gameObject.CompareTag("Pirate"))
{
return;
}
break;
default:
throw new ArgumentOutOfRangeException();
}
var iDamageable = other.GetComponentInParent<IDamageable>();
iDamageable.TakeDamage(attackerStat.Atk, attackerStat.ShieldPenetrationRate);
isAttacked = true;
}
}
#endregion
#region Custom function
public void SetIsAttacked(bool value) => isAttacked = value;
public void SetAttackerType(AttackerType value) => attackerType = value;
public void SetAttackerStat(AiStat value) => attackerStat = value;
#endregion
}
}