Esempio n. 1
0
    // Calculate the current quorum total within this nest (the total number of ants within the nest)
    public int GetQuorum()
    {
        int id    = simulation.GetNestID(this);
        int total = GameObject.Find("P" + id).transform.childCount;

        Transform a = GameObject.Find("A" + id).transform;

        for (int i = 0; i < a.childCount; i++)
        {
            AntManager assessor = a.GetChild(i).GetComponent <AntManager>();
            // If the assessor is currently in this nest count them towards the total
            if (assessor.currentNest == this)
            {
                total += 1;
            }
        }

        Transform r = GameObject.Find("R" + id).transform;

        for (int i = 0; i < r.childCount; i++)
        {
            AntManager recruiter = r.GetChild(i).GetComponent <AntManager>();
            // If the recruiter is currently waiting in this nest count them towards the total
            if (recruiter.currentNest == this)
            {
                total += 1;
            }
        }

        // The ant doesn't count itself towards the total
        return(total - 1);
    }
Esempio n. 2
0
 private void AssignParentFromNest(NestManager nest, string prefix, Color?colour)
 {
     if (nest != null)
     {
         prefix += simulation.GetNestID(nest);
     }
     if (transform.parent.name != prefix)
     {
         transform.parent = GameObject.Find(prefix).transform;
     }
     if (colour.HasValue)
     {
         SetPrimaryColour(colour.Value);
     }
 }