View Single Post
  #1  
Old 12-18-2011, 12:09 AM
41Sqn_Banks 41Sqn_Banks is offline
Approved Member
 
Join Date: Oct 2007
Posts: 644
Default Destroy all aircaft

Edit: Even better code to destroy all aircraft
Code:
if (GamePlay.gpArmies() != null && GamePlay.gpArmies().Length > 0)
{
    foreach (int armyIndex in GamePlay.gpArmies())
    {
        if (GamePlay.gpAirGroups(armyIndex) != null && GamePlay.gpAirGroups(armyIndex).Length > 0)
        {
            foreach (AiAirGroup airGroup in GamePlay.gpAirGroups(armyIndex))
            {
                if (airGroup.GetItems() != null && airGroup.GetItems().Length > 0)
                {
                    foreach (AiActor actor in airGroup.GetItems())
                    {
                        if (actor is AiAircraft)
                        {
                            AiAircraft aircraft = actor as AiAircraft;
                            aircraft.Destroy();
                        }
                    }
                }
            }
        }
    }
}

Last edited by 41Sqn_Banks; 12-18-2011 at 11:43 AM.
Reply With Quote