kirill loh

This commit is contained in:
2022-04-18 10:53:21 +07:00
parent 5fb554f098
commit e1d0bbc1eb
12 changed files with 88 additions and 31 deletions

View File

@ -7,13 +7,9 @@ public class Character
public Character()
{
Debug.Log("init");
Condition = new CharacterCondition();
}
public void ResetCharacter()
{
}
}
public interface ICharacter

View File

@ -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();
}

View File

@ -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,

View File

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

View File

@ -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;