kirill loh
This commit is contained in:
@ -7,13 +7,9 @@ public class Character
|
||||
|
||||
public Character()
|
||||
{
|
||||
Debug.Log("init");
|
||||
Condition = new CharacterCondition();
|
||||
}
|
||||
|
||||
public void ResetCharacter()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public interface ICharacter
|
||||
|
@ -6,12 +6,12 @@ using UnityEngine.AI;
|
||||
[RequireComponent(typeof(NavMeshAgent))]
|
||||
public class MovementController : MonoBehaviour
|
||||
{
|
||||
public NavPoint currentPosition { get; private set; }
|
||||
public NavPoint currentPosition { get; set; }
|
||||
[SerializeField] private NavMeshAgent navMeshAgent;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
navMeshAgent.speed = SettingsReader.Instance.GetSettings.movementSpeed;
|
||||
navMeshAgent.speed = SettingsReader.Instance.GetSettings.movementSpeed;
|
||||
}
|
||||
|
||||
public void MoveToRandomPoint()
|
||||
@ -23,7 +23,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.movementSpeed)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
@ -32,21 +32,21 @@ public class NPC : Agent, ICharacter
|
||||
|
||||
AgentCharacter = new Character();
|
||||
Condition = AgentCharacter.Condition;
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
AgentCharacter = new Character();
|
||||
Condition = AgentCharacter.Condition;
|
||||
|
||||
moveController = gameObject.GetComponent<MovementController>();
|
||||
bufferSensor = gameObject.GetComponent<BufferSensorComponent>();
|
||||
}
|
||||
|
||||
|
||||
GameManager.OnResetScene += AgentCharacter.ResetCharacter;
|
||||
public void ResetCharacter()
|
||||
{
|
||||
Condition = new CharacterCondition();
|
||||
EndEpisode();
|
||||
}
|
||||
|
||||
public override void OnEpisodeBegin()
|
||||
{
|
||||
|
||||
{
|
||||
NPC_State = DirectState;
|
||||
}
|
||||
|
||||
public override void CollectObservations(VectorSensor sensor)
|
||||
@ -56,12 +56,9 @@ public class NPC : Agent, ICharacter
|
||||
sensor.AddObservation(Condition.Ammunition);
|
||||
sensor.AddObservation((int)NPC_State.State);
|
||||
|
||||
|
||||
|
||||
var candidates = moveController.getPointsCandidate();
|
||||
foreach (var point in candidates)
|
||||
{
|
||||
|
||||
bufferSensor.AppendObservation(new float[] {
|
||||
//1 position in navpointId
|
||||
(float)moveController.currentPosition.PointId,
|
||||
|
2
Assets/Scripts/Character/NPC.cs.meta
generated
2
Assets/Scripts/Character/NPC.cs.meta
generated
@ -4,7 +4,7 @@ MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
executionOrder: 200
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
|
@ -9,11 +9,15 @@ public class Player : MonoBehaviour, ICharacter
|
||||
|
||||
public Character GetCharacter => PlayerCharacter;
|
||||
|
||||
private void Start()
|
||||
private void Awake()
|
||||
{
|
||||
PlayerCharacter = new Character();
|
||||
Condition = PlayerCharacter.Condition;
|
||||
GameManager.OnResetScene += PlayerCharacter.ResetCharacter;
|
||||
}
|
||||
|
||||
public void ResetCharacter()
|
||||
{
|
||||
Condition = new CharacterCondition();
|
||||
}
|
||||
|
||||
public event Action<object> OnKilledEvent;
|
||||
|
Reference in New Issue
Block a user