MainScript.CheckIfAllMonkeysAreConvicts C# (CSharp) Method

CheckIfAllMonkeysAreConvicts() public method

Check if we all our monkeys are not under prison. If so, we lost the game. Usually, this function is called when a drone delivers a monkey to a prison
public CheckIfAllMonkeysAreConvicts ( ) : void
return void
    public void CheckIfAllMonkeysAreConvicts()
    {
        // Let's assume that all monkeys are "inside"
        bool rv = true;

        foreach(Transform tMonkey in alliedMonkeys) {

            CMonkey scriptMonkey = tMonkey.GetComponent<CMonkey>();

            if(!scriptMonkey.IsInsideAPrison()) {

                // Monkey is free!!!!
                rv = false;
            }
        }

        // Ok, we have checked the status of all monkeys. What is the veredict?
        if(rv) {

            // Start the victory sequence
            GameOverStartJailedSequence();
        }
    }