1.enum 변수들 NONE = 0 -> NONE = -1 변경 2.meleeWeapon -> closeWeapon 이름 변경 3.BaseCharacter(기본캐릭터) 조립형 프리팹 수정
64 lines
1.8 KiB
C#
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
|
|
}
|
|
} |