示例#1
0
 protected void RemoveAgentFromFlock(FlockAgent agent)
 {
     if (agents.Contains(agent))
     {
         agents.Remove(agent);
         agent.SetFlock(null);
     }
 }
示例#2
0
    FlockAgent InstantiateSoldier()
    {
        float x = instantiatePlace.transform.position.x;
        float y = instantiatePlace.transform.position.y + 1.5f;

        if (currI % 2 == 0)
        {
            randomSquare = new Vector2(-transRad + x, transRad * (soldiersCount - currI) + y);
        }
        else
        {
            randomSquare = new Vector2(transRad + x, transRad * (soldiersCount - currI + 1) + y);
        }

        currI++;

        Quaternion rot      = new Quaternion();
        FlockAgent newAgent = Instantiate(
            agentPrefab,
            randomSquare,
            rot,
            transform
            );

        newAgent.name = agentPrefab.name + " " + currI;

        newAgent.SetFlock(this);
        agents.Add(newAgent);
        copyAgents.Add(newAgent);
        if (currI < soldiersCount)
        {
            InstantiateSoldier();
        }
        else
        {
            currI = 0;
        }
        return(newAgent);
    }