latest
This commit is contained in:
@ -9,6 +9,7 @@ public class CharacterCondition
|
||||
public event Action<int> OnChangeAmmunitionEvent;
|
||||
|
||||
private int health;
|
||||
|
||||
public int HealthPoints
|
||||
{
|
||||
get
|
||||
|
@ -7,13 +7,28 @@ using UnityEngine.AI;
|
||||
public class MovementController : MonoBehaviour
|
||||
{
|
||||
public NavPoint currentPosition { get; set; }
|
||||
private Dictionary<int, NavPoint> navPoints = new Dictionary<int, NavPoint>();
|
||||
|
||||
[SerializeField] private NavMeshAgent navMeshAgent;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
navMeshAgent.speed = SettingsReader.Instance.GetSettings.movementSpeed;
|
||||
navMeshAgent.speed = SettingsReader.Instance.GetSettings.movementSpeed;
|
||||
foreach (var np in MapManager.navPoints) {
|
||||
navPoints[np.PointId] = np;
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveToPointById(int id)
|
||||
{
|
||||
if (!navPoints.ContainsKey(id))
|
||||
{
|
||||
Debug.LogWarning("PIDOR");
|
||||
return;
|
||||
}
|
||||
goToNextNavPoint(navPoints[id]);
|
||||
}
|
||||
|
||||
public void MoveToRandomPoint()
|
||||
{
|
||||
Debug.Log(MapManager.navPoints == null);
|
||||
@ -23,7 +38,7 @@ public class MovementController : MonoBehaviour
|
||||
public List<NavPoint> getPointsCandidate()
|
||||
{
|
||||
return MapManager.navPoints
|
||||
.Where(point => (currentPosition.position - point.position).magnitude < SettingsReader.Instance.GetSettings.movementSpeed)
|
||||
.Where(point => (currentPosition.position - point.position).magnitude < SettingsReader.Instance.GetSettings.movementDistance)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
@ -54,24 +54,29 @@ public class NPC : Agent, ICharacter
|
||||
sensor.AddObservation(Condition.HealthPoints);
|
||||
sensor.AddObservation(Condition.ArmourPoints);
|
||||
sensor.AddObservation(Condition.Ammunition);
|
||||
sensor.AddObservation((int)NPC_State.State);
|
||||
sensor.AddObservation((int) NPC_State.State);
|
||||
|
||||
var candidates = moveController.getPointsCandidate();
|
||||
foreach (var point in candidates)
|
||||
{
|
||||
bufferSensor.AppendObservation(new float[] {
|
||||
var parray = new float[]
|
||||
{
|
||||
//1 position in navpointId
|
||||
(float)moveController.currentPosition.PointId,
|
||||
(float) moveController.currentPosition.PointId,
|
||||
//2 distance to flag
|
||||
moveController.currentPosition.FlagDistance,
|
||||
//3 death count in point
|
||||
moveController.currentPosition.DeathAttr,
|
||||
//4 flagEnemyDistance
|
||||
GameManager.IsCloserToFlagFromNextNavPoint(point, transform.position)==true?1:0,
|
||||
GameManager.IsCloserToFlagFromNextNavPoint(point, transform.position) == true ? 1 : 0,
|
||||
//5 EnemyVsNavPointDistance
|
||||
GameManager.IsCloserToEnemyThanToNextNavPoint(point,transform.position, AgentCharacter.Team)==true?1:0
|
||||
});
|
||||
|
||||
GameManager.IsCloserToEnemyThanToNextNavPoint(point, transform.position, AgentCharacter.Team) == true
|
||||
? 1
|
||||
: 0
|
||||
};
|
||||
var _parray = string.Join(" ", parray);
|
||||
Debug.Log("OBS: " + _parray);
|
||||
bufferSensor.AppendObservation(parray);
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,6 +95,9 @@ public class NPC : Agent, ICharacter
|
||||
{
|
||||
moveController.MoveToRandomPoint();
|
||||
NPC_State = RunningState;
|
||||
} else if (actions.DiscreteActions[0] == 2)
|
||||
{
|
||||
moveController.MoveToPointById(actions.DiscreteActions[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user