Fixed many things.
This commit is contained in:
@ -77,6 +77,7 @@ public class CharacterFactory : MonoBehaviour
|
||||
{
|
||||
GameManager._defendersTeam.RegisterAgent(npc);
|
||||
}
|
||||
|
||||
npc.GetCharacter.Team = team;
|
||||
npc.SetModel(team.ToString(), null, InferenceDevice.Default );
|
||||
gameobject.GetComponent<MovementController>().PointStartID = spawnPoint.PointId;
|
||||
|
@ -52,7 +52,7 @@ public class MovementController : MonoBehaviour
|
||||
{
|
||||
return MapManager.Instance.NavPoints
|
||||
.Where(point =>
|
||||
(_idNavPointDict[PointStartID].Position - point.Position).magnitude < SettingsReader.Instance.GetSettings.MovementDistance)
|
||||
(transform.position - point.Position).magnitude < SettingsReader.Instance.GetSettings.MovementDistance)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
@ -69,15 +69,12 @@ public class MovementController : MonoBehaviour
|
||||
{
|
||||
if (navMeshAgent.isStopped == true) navMeshAgent.isStopped = false;
|
||||
navMeshAgent.SetDestination(_idNavPointDict[PointStartID].Position);
|
||||
PointEndID = PointStartID;
|
||||
PointStartID = -1;
|
||||
(PointEndID, PointStartID) = (PointStartID, PointEndID);
|
||||
}
|
||||
|
||||
public void StopOnPath()
|
||||
{
|
||||
navMeshAgent.isStopped = true;
|
||||
PointStartID = -1;
|
||||
PointEndID = -1;
|
||||
}
|
||||
|
||||
public void ReachedDestination()
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Animators.Leonid_Animator;
|
||||
using Animators.Leonid_Animator.Bot;
|
||||
using Unity.MLAgents;
|
||||
@ -74,7 +75,6 @@ public class NPC : Agent, ICharacter
|
||||
|
||||
private void Update()
|
||||
{
|
||||
print(IsFiring);
|
||||
_botLocomotion.UpdateAnimatorValues();
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ public class NPC : Agent, ICharacter
|
||||
|
||||
public override void CollectObservations(VectorSensor sensor)
|
||||
{
|
||||
// Debug.Log("Collect observations called!");
|
||||
Debug.Log("Collect observations called!");
|
||||
_navPointIdDict = MapManager.Instance.IDToNavPoint;
|
||||
if (_navPointIdDict is null)
|
||||
Debug.LogError("Cant Find Nav Point Dictionary");
|
||||
@ -105,7 +105,6 @@ public class NPC : Agent, ICharacter
|
||||
sensor.AddObservation(candidates.Count);
|
||||
sensor.AddObservation(_moveController.PointStartID);
|
||||
sensor.AddObservation(_moveController.PointEndID);
|
||||
// Debug.Log("Done common!");
|
||||
//state sensors
|
||||
sensor.AddObservation((int)NpcState.State);
|
||||
sensor.AddObservation((int)NpcBodyState.State);
|
||||
@ -113,7 +112,6 @@ public class NPC : Agent, ICharacter
|
||||
sensor.AddObservation(_navPointIdDict[_moveController.PointStartID].DeathAttr);
|
||||
sensor.AddObservation(_navPointIdDict[_moveController.PointEndID].DeathAttr);
|
||||
sensor.AddObservation(_moveController.FlagDistance);
|
||||
// Debug.Log("Done state sensors!");
|
||||
|
||||
//point sensors
|
||||
foreach (var point in candidates)
|
||||
@ -130,26 +128,25 @@ public class NPC : Agent, ICharacter
|
||||
GameManager.IsHaveSeenByEnemy(GetCharacter.Team.GetOppositeTeam(),
|
||||
point.Position).ToInt()
|
||||
});
|
||||
}
|
||||
// Debug.Log("Done collect observations!");
|
||||
} ;
|
||||
}
|
||||
|
||||
public override void OnActionReceived(ActionBuffers actions)
|
||||
{
|
||||
{
|
||||
var result = actions.DiscreteActions;
|
||||
print(result[0]);
|
||||
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 3: Peek(); _moveController.GoToNextNavPoint(_navPointIdDict[result[2]]); break;
|
||||
case 4: NpcState = _directState; break;
|
||||
default: throw new ArgumentException("Undefined Action recieved");
|
||||
case 2: Peek(); _moveController.GoToNextNavPoint(_navPointIdDict[result[2]]); break;
|
||||
case 3: break;
|
||||
default: throw new ArgumentException("Undefined Action received");
|
||||
}
|
||||
}
|
||||
if (result[0] == 1)
|
||||
@ -164,7 +161,9 @@ public class NPC : Agent, ICharacter
|
||||
case 0: _moveController.GoToNextNavPoint(_navPointIdDict[result[2]]);
|
||||
NpcState = _runningState; Debug.Log("Go to point " + result[2]);break;
|
||||
case 1: NpcState = _directState; break;
|
||||
default: throw new ArgumentException("Undefined Action recieved");
|
||||
case 2: break;
|
||||
case 3: break;
|
||||
default: throw new ArgumentException("Undefined Action received");
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,7 +175,9 @@ public class NPC : Agent, ICharacter
|
||||
{
|
||||
case 0: _moveController.StopOnPath(); NpcState = _directState; break;
|
||||
case 1: _moveController.ReturnToStartPoint(); NpcState = _runningState; break;
|
||||
default: throw new ArgumentException("Undefined Action recieved");
|
||||
case 2: break;
|
||||
case 3: break;
|
||||
default: throw new ArgumentException("Undefined Action received");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,9 +45,6 @@ public class FlagZone : MonoBehaviour
|
||||
case "Attacker":
|
||||
occupAttackers--;
|
||||
break;
|
||||
default:
|
||||
Debug.LogWarning("Exited non-team entity");
|
||||
break;
|
||||
}
|
||||
}
|
||||
private void Update()
|
||||
|
@ -79,7 +79,6 @@ public class AimAssistant : MonoBehaviour
|
||||
|
||||
private void StopShooting()
|
||||
{
|
||||
print("stop shooting");
|
||||
_firelock = false;
|
||||
isFiring = false;
|
||||
fireAnimation = false;
|
||||
@ -89,7 +88,6 @@ public class AimAssistant : MonoBehaviour
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
print("in Shooting");
|
||||
_shooting.Shoot();
|
||||
yield return new WaitForSeconds(_fireCountdown);
|
||||
}
|
||||
|
Reference in New Issue
Block a user