- Home /
This question was
closed Aug 07, 2017 at 08:19 AM by
hexagonius for the following reason:
Question is off-topic or not relevant https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs0029
Question by
Chappo935 · Aug 07, 2017 at 07:59 AM ·
error message
Assets/Scripts/GameManager.cs(24,33): error CS0029: Cannot implicitly convert type `bool' to `int'
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour {
public int currentScore;
public int highScore;
public static int currentLevel = 0;
public int unlockedLevel;
public Color warningColorTimer;
public Color defaultColorTimer;
public Rect timerRect;
public GUISkin skin;
public float startTime;
private string currentTime;
void Start() {
//DontDestroyOnLoad(gameObject);
if(currentLevel = PlayerPrefs.GetInt("Level Completed") > 0) {
PlayerPrefs.GetInt("Level Completed");
} else {
currentLevel = 0;
}
}
void Update(){
startTime -= Time.deltaTime;
currentTime = string.Format("{0:0.00}", startTime);
if(startTime <= 0) {
startTime = 0;
SceneManager.LoadScene(3);
}
}
public void CompleteLevel() {
if(currentLevel < 2) {
currentLevel += 1;
PlayerPrefs.SetInt("Level Completed", currentLevel);
PlayerPrefs.SetInt("Level " + currentLevel.ToString() + " score", currentScore);
SceneManager.LoadScene(currentLevel);
} else {
print("You won");
}
}
void OnGUI() {
GUI.skin = skin;
if(startTime < 5f) {
skin.GetStyle("Timer").normal.textColor = warningColorTimer;
} else {
skin.GetStyle("Timer").normal.textColor = defaultColorTimer;
}
GUI.Label(timerRect, currentTime, skin.GetStyle("Timer"));
}
}
Comment
I can't understand what you mean by " if (currentLevel = PlayerPrefs.GetInt("Level Completed") > 0)". Do you want to check if currentLevel is equals PlayerPrefs.GetInt("Level Completed") and PlayerPrefs.GetInt("Level Completed") is greater than 0?