- 그룹 상호작용에 따른 하이라이트 효과 적용 1. 마우스 커서 올림 - 하얀색 외곽선 2. 그룹 선택 - 파란색 외곽선 - Arrow, Archer 코루틴 문제 구조 변경 - FieldOfView 인터페이스화 - new input system Unit Action 추가 - GameManager 슬로우모드(부대 선택시) 추가 - Ai 전체 프리팹 stat 수치 변경 - 원거리 이동 중에 공격시 멈추면서 공격하도록 변경 - Layer, ProjectSetting Physics 추가 및변경
67 lines
1.7 KiB
C#
67 lines
1.7 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 void MoveTarget(Vector3 targetPos)
|
|
{
|
|
isCommanded = true;
|
|
GetNavMeshAgent().SetDestination(targetPos);
|
|
}
|
|
public bool GetIsCommanded() => isCommanded;
|
|
private TargetInfo GetTargetInfo() => aiController.TargetInfo;
|
|
private NavMeshAgent GetNavMeshAgent() => aiController.GetNavMeshAgent();
|
|
|
|
#endregion
|
|
}
|
|
} |