formation script

hi,

I have worked on the logic of the script a litle more and this is what i want

how formation ai will work

bool haveleader;

if (haveleader)
{

if ( no enemy detected follow formation)
{
if ( formation == circle  )
{
keep formation circle around leader
}

else if ( formation == front)

{
troops at front; infront of leader
}

else if ( formation == pincer)

{
troops at front and split into two groups forming trangle in front of leader
}

else if ( formation = all behind )
{
troop at behind

}
else if ( formation square )
{
troops form sqare around leader and move in formation
}

}

else {
{ attack nearest enemy
}

}
else if ( !haveleader)
{

if ( no enemy detected )
{ stay
}

else attack nearest

}

}
}

I need help turning this into unity script. CAN SOMEONE HELP ? I am working on this alone on my spare time. It could be in c# or javascript.

thanks in advance

how to make a dynamic formation to environment using unity 3d???