Final commit

This commit is contained in:
2022-05-18 00:21:35 +07:00
parent ebddcadc38
commit 4132787ef8
1671 changed files with 697308 additions and 714 deletions

View File

@ -23,10 +23,12 @@ public class MovementController : MonoBehaviour
public Vector3 Velocity => navMeshAgent.velocity;
private Dictionary<int, NavPoint> _idNavPointDict;
private NPC _myNpc;
private Settings _settings;
private void Awake()
{
navMeshAgent.speed = SettingsReader.Instance.GetSettings.MovementSpeed;
_settings = SettingsReader.Instance.GetSettings;
navMeshAgent.speed = _settings.MovementSpeed;
_idNavPointDict = MapManager.Instance.IDToNavPoint;
_myNpc = GetComponent<NPC>();
_firePointTransform = transform.GetChild(0);
@ -42,15 +44,23 @@ public class MovementController : MonoBehaviour
private void Update()
{
print($"{_myNpc.NpcState.ToString()}, {_myNpc.GetCharacter.Team}");
if (Velocity.magnitude > 0)
_myNpc.ChangeBaseState(NpcEnumState.InRunning);
else
if (ReachedDestination())
{
_myNpc.ChangeBaseState(_idNavPointDict[PointStartID].navType == NavPointType.Cover
_myNpc.ChangePointState(_idNavPointDict[PointStartID].navType == NavPointType.Cover
? NpcEnumState.InCover
: NpcEnumState.InDirectPoint);
}
else
{
_myNpc.ChangeBodyState(NpcBodyState.Standing);
_myNpc.ChangePointState(NpcEnumState.InRunning);
}
if (_myNpc.NpcBodyState.State == NpcBodyState.Crouching)
navMeshAgent.speed = _settings.MovementSpeed / 2;
else
navMeshAgent.speed = _settings.MovementSpeed;
}
private void UpdateFlagPosition()
@ -68,7 +78,7 @@ public class MovementController : MonoBehaviour
{
return MapManager.Instance.NavPoints
.Where(point =>
(transform.position - point.Position).magnitude < SettingsReader.Instance.GetSettings.MovementDistance)
(transform.position - point.Position).magnitude < _settings.MovementDistance)
.ToList();
}
@ -93,11 +103,13 @@ public class MovementController : MonoBehaviour
navMeshAgent.isStopped = true;
}
public void ReachedDestination()
public bool ReachedDestination()
{
if (navMeshAgent.remainingDistance < float.Epsilon)
if (navMeshAgent.remainingDistance < 0.1f)
{
PointStartID = PointEndID;
return true;
}
return false;
}
}