Example #1
0
    //-------------------------------------------------------------------------
    /// <summary>
    /// sets up the leader
    /// </summary>
    /// <param name="msg"></param>
    public void SetUpSwarmForLeader(TOLMessage msg)
    {
        //this is the leader , it sets up the group for the leader
        List<TOLEnemyController> fb = (List<TOLEnemyController>)msg.data;
        int count = fb.Count;
        for (int i = 0; i < count; i++)
        {
            flyingBoids.Add(fb[i].GetComponent<TOLEnemyFlying>());

        }
        GroupLeader = this;
        BoidInfo.setUpBoid = true;
        int flockSize = flyingBoids.Count;
        for (int i = 0; i < flockSize; i++)
        {
            flyingBoids[i].SetUpSwarmFollowers(flyingBoids,this);
        }
    }
Example #2
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// initial Boid setup
 /// </summary>
 protected void DoBoidSetup()
 {
     TOLEnemyFlying[] AllFlyingEnemies = GameObject.FindObjectsOfType<TOLEnemyFlying>();
     foreach (TOLEnemyFlying enemy in AllFlyingEnemies)
     {
         if (enemy.BoidInfo.m_groupId == BoidInfo.m_groupId)
         {
             if (!enemy.BoidInfo.m_isGroupLeader)
             {
                 flyingBoids.Add(enemy);
                 enemy.BoidInfo.isSwarmingEnemy = true;
             }
             else
                 GroupLeader = enemy;
         }
     }
     if (BoidInfo.m_isGroupLeader)
     {
         GroupLeader = this;
         //set destination for each boid as group leader
         foreach (TOLEnemyFlying enemy in flyingBoids)
         {
             enemy.SetDestination(GroupLeader.transform);
         }
     }
 }
Example #3
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// sets up the swarm followers
 /// called by the leader
 /// </summary>
 /// <param name="swarm"></param>
 /// <param name="Leader"></param>
 public void SetUpSwarmFollowers(List<TOLEnemyFlying> swarm , TOLEnemyFlying Leader)
 {
     flyingBoids = swarm;
     BoidInfo.isSwarmingEnemy = true;
     GroupLeader = Leader;
     maxVelocity = GroupLeader.maxVelocity;
     minVelocity = GroupLeader.minVelocity;
     SetDestination(Leader.transform);
     BoidInfo.setUpBoid = true;
 }