Final commit
This commit is contained in:
@ -36,7 +36,7 @@ public class NPC : Agent, ICharacter
|
||||
|
||||
public bool IsFiring => _assistant.fireAnimation;
|
||||
|
||||
public void ChangeBaseState(NpcEnumState state)
|
||||
public void ChangePointState(NpcEnumState state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
@ -51,6 +51,19 @@ public class NPC : Agent, ICharacter
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeBodyState(NpcBodyState state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case global::NpcBodyState.Crouching:
|
||||
NpcBodyState = _crouchingState;
|
||||
break;
|
||||
case global::NpcBodyState.Standing:
|
||||
NpcBodyState = _standingState;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#region UnityEvents and ML
|
||||
private void Awake()
|
||||
@ -96,7 +109,6 @@ public class NPC : Agent, ICharacter
|
||||
if (_navPointIdDict is null)
|
||||
Debug.LogError("Cant Find Nav Point Dictionary");
|
||||
|
||||
NpcState = _directState;
|
||||
_flagZone = GameObject.FindObjectOfType<FlagZone>();
|
||||
}
|
||||
|
||||
@ -143,35 +155,41 @@ public class NPC : Agent, ICharacter
|
||||
} ;
|
||||
}
|
||||
|
||||
public override void WriteDiscreteActionMask(IDiscreteActionMask actionMask)
|
||||
{
|
||||
if (!NpcState.InCover)
|
||||
actionMask.SetActionEnabled(0,0,false);
|
||||
if (!NpcState.InDirectPoint)
|
||||
actionMask.SetActionEnabled(0,1,false);
|
||||
if (!NpcState.IsRunning)
|
||||
actionMask.SetActionEnabled(0,2,false);
|
||||
base.WriteDiscreteActionMask(actionMask);
|
||||
}
|
||||
|
||||
|
||||
public override void OnActionReceived(ActionBuffers actions)
|
||||
{
|
||||
var result = actions.DiscreteActions;
|
||||
if (result[0] == 0)
|
||||
{
|
||||
if (_navPointIdDict[_moveController.PointStartID].navType != NavPointType.Cover)
|
||||
return;
|
||||
NpcState = _coverState;
|
||||
switch (result[1])
|
||||
{
|
||||
case 0: Peek(); break;
|
||||
case 1: Cover(); break;
|
||||
case 2: Peek(); _moveController.GoToNextNavPoint(_navPointIdDict[result[2]]); break;
|
||||
case 2: Peek();
|
||||
_moveController.GoToNextNavPoint(_navPointIdDict[result[2]]);
|
||||
break;
|
||||
case 3: break;
|
||||
default: throw new ArgumentException("Undefined Action received");
|
||||
}
|
||||
}
|
||||
if (result[0] == 1)
|
||||
{
|
||||
if (_navPointIdDict[_moveController.PointStartID].navType != NavPointType.Direction)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (result[1])
|
||||
{
|
||||
case 0: _moveController.GoToNextNavPoint(_navPointIdDict[result[2]]);
|
||||
NpcState = _runningState; break;
|
||||
case 1: NpcState = _directState; break;
|
||||
case 0:
|
||||
_moveController.GoToNextNavPoint(_navPointIdDict[result[2]]);break;
|
||||
case 1: break;
|
||||
case 2: break;
|
||||
case 3: break;
|
||||
default: throw new ArgumentException("Undefined Action received");
|
||||
@ -179,13 +197,11 @@ public class NPC : Agent, ICharacter
|
||||
}
|
||||
|
||||
if (result[0] == 2)
|
||||
{
|
||||
if (_moveController.PointStartID == _moveController.PointEndID && _moveController.PointEndID != -1)
|
||||
return;
|
||||
{
|
||||
switch (result[1])
|
||||
{
|
||||
case 0: _moveController.StopOnPath(); NpcState = _directState; break;
|
||||
case 1: _moveController.ReturnToStartPoint(); NpcState = _runningState; break;
|
||||
case 0: _moveController.StopOnPath(); break;
|
||||
case 1: _moveController.ReturnToStartPoint(); break;
|
||||
case 2: break;
|
||||
case 3: break;
|
||||
default: throw new ArgumentException("Undefined Action received");
|
||||
|
Reference in New Issue
Block a user