latest changes
This commit is contained in:
@ -1,14 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditorInternal;
|
||||
using Unity.MLAgents;
|
||||
using UnityEngine;
|
||||
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
|
||||
private static GameManager instance;
|
||||
public static GameManager Instance { get { return instance; } }
|
||||
|
||||
private static SimpleMultiAgentGroup DefendersTeam = new SimpleMultiAgentGroup();
|
||||
private static SimpleMultiAgentGroup AttackersTeam = new SimpleMultiAgentGroup();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
@ -21,13 +21,36 @@ public class GameManager : MonoBehaviour
|
||||
{
|
||||
GlobalEventManager.onCaptureFlag += flagCaptured;
|
||||
GlobalEventManager.onTimeLeft += timeOut;
|
||||
|
||||
var agents = GameObject.FindObjectsOfType<Agent>();
|
||||
foreach (var item in agents)
|
||||
{
|
||||
var agent = item as NPC;
|
||||
if (agent.GetCharacter.Team == Team.Attackers)
|
||||
AttackersTeam.RegisterAgent(agent);
|
||||
else
|
||||
DefendersTeam.RegisterAgent(agent);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
public static bool IsCloserToEnemyThanToNextNavPoint(NavPoint navPoint, Vector3 currentTransform, Team team)
|
||||
{
|
||||
|
||||
SimpleMultiAgentGroup agentGroup;
|
||||
if (team == Team.Attackers)
|
||||
agentGroup = AttackersTeam;
|
||||
else
|
||||
agentGroup = DefendersTeam;
|
||||
|
||||
var distToNavPoint = (currentTransform - navPoint.position).magnitude;
|
||||
foreach (var agent in agentGroup.GetRegisteredAgents())
|
||||
if (distToNavPoint > (currentTransform - agent.transform.position).magnitude)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsCloserToFlagFromNextNavPoint(NavPoint navPoint, Vector3 currentTransform)
|
||||
=> navPoint.FlagDistance < (currentTransform - GameObject.FindGameObjectWithTag("Flag").transform.position).magnitude;
|
||||
|
||||
private void flagCaptured(Team team)
|
||||
{
|
||||
switch(team)
|
||||
|
Reference in New Issue
Block a user