Exemple #1
0
        /// <summary>
        /// Creates a new swarm agent.
        /// </summary>
        /// <returns>The agent.</returns>
        public SwarmAgent NewAgent()
        {
            // Instantiate the prefab
            var agentObj = (Transform)Object.Instantiate(this.AgentPrefab);

            agentObj.transform.parent        = this.transform;
            agentObj.transform.localPosition = Random.insideUnitCircle * this.InitialRadius;

            // Set the parent
            SwarmAgent agent = agentObj.GetComponent <SwarmAgent>();

            agent.Swarm = this;

            return(agent);
        }
Exemple #2
0
 /// <summary>
 /// Removes the given agent.
 /// </summary>
 /// <param name="agent">The agent.</param>
 public void RemoveAgent(SwarmAgent agent)
 {
     this.agents.Remove(agent);
 }