my first level consists on three turrets what script should i write for when all three turrets are destroyed i automatically advance into the next level. Also please note how i should write it ex. if(...), function ..., var ..., etc. and what i should attach my script to ex. Character, turrets, etc.
Many ways to do it.
One is to create a script that will manage the turrets. When a turret is destroyed, it updates that script about it. That script then checks the status of the other turrets. If all are destroyed - it advances to the next level.
Technically speaking, simplest way is to have something like
public var arrIsTurretAlive: boolean[];
public function TurretDestroyed(nTurretID: int)
{
arrIsTurretAlive[nTurretID] = false;
var bWasLiveTurretFound: bool = false;
for (var nCurrTurret: int = 0 ; nCurrTurret < arrIsTurretAlive.Length ; nCurrTurret++)
{
if (arrIsTurretAlive[nCurrTurret])
{
bWasLiveTurretFound = true;
break;
}
}
if (!bWasLiveTurretFound)
Application.LoadLevel(Application.loadedLevel + 1);
}
And FYI - you won't get answers by asking others to do all the work for you. Read some tutorials. Play around and ask specific questions after trying to do it yourself first.