OldBlueWater/BlueWater/Assets/02.Scripts/Ai/AiMover.cs
NTG_Lenovo 86065e52a9 #10 Testing long range ai (arrow attack system)
Additional commit content
1. Modified ObjectPool Function(OnReleaseArrow and naming).
2. Modified hitBox tag in aiPrefab.
3. Modified Physics layer.
4. Modified TargetInfo variable from TargetTransform variable in FieldOfView script.
5. Added GetCurrentHp() in IAiStat script.
2023-08-09 16:44:09 +09:00

62 lines
1.6 KiB
C#

using System;
using UnityEngine;
using UnityEngine.AI;
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
public class AiMover : MonoBehaviour
{
private enum MoveType
{
NONE, // 미설정
FIXED, // 자리를 지키는 AI
MOVE // 자리를 움직이는 AI
}
#region Property and variable
[SerializeField] private MoveType moveType;
private bool isCommanded;
private Vector3 movePos;
private AiController aiController;
#endregion
#region Unity built-in function
private void Awake()
{
aiController = Utils.GetComponentAndAssert<AiController>(transform);
}
private void LateUpdate()
{
aiController.GetAnimator().SetFloat(AiController.SpeedHash, aiController.GetNavMeshAgent().velocity.normalized.magnitude);
if (isCommanded || aiController.GetIsAttacking())
{
}
else
{
if (!GetTargetInfo().transform || moveType is MoveType.NONE or MoveType.FIXED) return;
GetNavMeshAgent().SetDestination(GetTargetInfo().transform.position);
}
}
#endregion
#region Custom function
public bool GetIsCommanded() => isCommanded;
private TargetInfo GetTargetInfo() => aiController.GetFieldOfView().GetTargetInfo();
private NavMeshAgent GetNavMeshAgent() => aiController.GetNavMeshAgent();
#endregion
}
}