OldBlueWater/BlueWater/Assets/02.Scripts/Weapon/CloseWeapon.cs
NTG 6438ca89a0 closed #27 AiView, AiStat, Unit, Card SO 추가
1.enum 변수들 NONE = 0 -> NONE = -1 변경
2.meleeWeapon -> closeWeapon 이름 변경
3.BaseCharacter(기본캐릭터) 조립형 프리팹 수정
2023-08-29 04:52:23 +09:00

64 lines
1.8 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, iDamageable.AiStat);
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
}
}