The Application.levelCount doesn’t work in unity 2017. If you want to get the level count you will have to add ScreneManger to your Project
using UnityEngine.ScreneManager
Then replace Application.levelCount with SceneManager.sceneCountInBuildSettings . If you try using SceneManager.SceneCount you will get a total of 1 Scene. SceneCount only counts the current number of loaded scenes where sceneCountInBuildSettings counts all scenes listed in the BuildSettings.