예제 #1
0
 void InitializeAgents(GameObject agentPrefab, List <AIRobot> list, int amountChanged)
 {
     if (amountChanged < 0)
     {
         Debug.Log("Amount of new agents: " + amountChanged);
         throw new Exception("Cannot remove Agents. Not implemented yet");
     }
     for (int i = 0; i < amountChanged; i++)
     {
         var randomRotY    = UnityEngine.Random.Range(-180f, 180f);
         var randomRotQuat = Quaternion.Euler(new Vector3(0, randomRotY, 0));
         var agentGO       = GameObject.Instantiate(agentPrefab, GetRandomSpawnPosInArena(), randomRotQuat, transform);
         var agent         = new AIRobot()
         {
             robotGO = agentGO, robotScript = agentGO.GetComponent <AIRobotAgent>()
         };
         list.Add(agent);
     }
 }
예제 #2
0
 void Awake()
 {
     if (m_AssignRobotsManually)
     {
         foreach (var agent in m_Agents)
         {
             var aiRobot = new AIRobot()
             {
                 robotGO = agent, robotScript = agent.GetComponent <AIRobotAgent>()
             };
             if (agent.gameObject.CompareTag("red_agent"))
             {
                 m_RedAgents.Add(aiRobot);
             }
             else if (agent.gameObject.CompareTag("blue_agent"))
             {
                 m_BlueAgents.Add(aiRobot);
             }
         }
     }
 }