Exemplo n.º 1
0
    void EnforceUniqueIDs()
    {
        EnemyInfo currentEnemy  = null;
        EnemyInfo previousEnemy = null;

        for (int i = 1; i < enemies.Count; i++)
        {
            currentEnemy  = enemies[i];
            previousEnemy = enemies[i - 1];

            if (currentEnemy.Equals(previousEnemy))
            {
                string messageFormat = "{0} and {1} have the same id. Please make sure ";
                messageFormat += "all enemies in the database have unique IDs.";
                throw new System.ApplicationException(string.Format(messageFormat,
                                                                    currentEnemy.name,
                                                                    previousEnemy.name));
            }
        }
    }