OldBlueWater/BlueWater/Assets/02.Scripts/HouseInfo.cs
NTG 13cfeb3315 closed #9 근거리 Ai 공격, 충돌 테스트
#7 근거리 무기(MeleeWeapon) 추가
#8 부대 제어 수정 필요(기획 변경)

- Ai 버벅이던 현상 수정(Rigidbody interpolate 문제)
- UnitController 상세화(인스펙터창)
- 오펜스 관련 Ai 기본 설정
- Props 레이어 추가, House 태그 추가
- Physic 충돌 레이어 변경
- Ai 전체 프리팹 수정
- 테스트용 오펜스 ai 타겟 건물 추가
- Swordman 애니메이션 이벤트 누락 수정
2023-08-22 03:08:11 +09:00

62 lines
1.4 KiB
C#

using System;
using UnityEngine;
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
public class HouseInfo : MonoBehaviour, IDamageable
{
#region Property and variable
public IslandInfo IslandInfo { get; set; }
#endregion
#region Unity built-in function
private void Awake()
{
SetCurrentHp(AiStat.maxHp);
}
private void OnDisable()
{
RemoveIslandInfo();
}
#endregion
#region Interface property and function
[field: SerializeField] public AiStat AiStat { get; set; }
public float GetCurrentHp() => AiStat.currentHp;
public void SetCurrentHp(float value) => AiStat.currentHp = value;
public void TakeDamage(AiStat attacker, AiStat defender, Vector3? attackPos = null)
{
var changeHp = Mathf.Max(defender.currentHp - attacker.atk, 0);
SetCurrentHp(changeHp);
// 건물 파괴
if (changeHp == 0f)
{
RemoveIslandInfo();
}
}
#endregion
#region Custom function
private void RemoveIslandInfo()
{
if (!IslandInfo) return;
IslandInfo.RemoveListElement(IslandInfo.HouseList, transform);
}
#endregion
}
}