final commit

This commit is contained in:
2022-04-29 21:55:55 +07:00
parent 4172fc94ba
commit e90826e5bb
10 changed files with 247 additions and 20 deletions

View File

@ -4,16 +4,23 @@ using UnityEngine;
public class DumbAI : MonoBehaviour
{
public Transform feetTransform;
// Start is called before the first frame update
[SerializeField]
private List<NavPoint> _aiPathRaw;
private Queue<NavPoint> _aiPath;
private int _nextPointId;
void Start()
{
var current_position = feetTransform.transform.position;
_aiPath = new Queue<NavPoint>(_aiPathRaw);
StepOnNavPoint();
}
// Update is called once per frame
void Update()
private void StepOnNavPoint()
{
if (_aiPath.Count != 0)
{
_nextPointId = _aiPath.Peek().PointId;
_aiPath.Dequeue();
}
}
}

View File

@ -4,7 +4,7 @@ MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
executionOrder: 200
icon: {instanceID: 0}
userData:
assetBundleName:

View File

@ -16,13 +16,13 @@ public class MovementController : MonoBehaviour
public void MoveToRandomPoint()
{
Debug.Log(MapManager.navPoints == null);
goToNextNavPoint(MapManager.navPoints[Random.Range(0, MapManager.navPoints.Count)]);
Debug.Log(MapManager.NavPoints == null);
goToNextNavPoint(MapManager.NavPoints[Random.Range(0, MapManager.NavPoints.Count)]);
}
public List<NavPoint> getPointsCandidate()
{
return MapManager.navPoints
return MapManager.NavPoints
.Where(point => (currentPosition.position - point.position).magnitude <= SettingsReader.Instance.GetSettings.movementSpeed)
.ToList();
}

View File

@ -8,10 +8,8 @@ using System.Collections.Generic;
[RequireComponent(typeof(MovementController))]
public class NPC : Agent, ICharacter
{
[HideInInspector]
public Character AgentCharacter;
public CharacterCondition Condition;
private Character AgentCharacter;
private CharacterCondition Condition;
public NPC_BaseState NPC_State { get; private set; }
public Character GetCharacter => AgentCharacter;