32 lines
782 B
C#
32 lines
782 B
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class game : MonoBehaviour
|
|
{
|
|
public Button[] buttons;
|
|
|
|
private void Awake()
|
|
{
|
|
int userId = GlobalUser.Instance.userId;
|
|
string key = $"UnlockedLevel_{userId}";
|
|
int unlockedLevel = PlayerPrefs.GetInt(key, 1); // Default buka Level 0 (1 tombol)
|
|
|
|
Debug.Log($"User ID: {userId} - Unlocked Level: {unlockedLevel}");
|
|
|
|
for (int i = 0; i < buttons.Length; i++)
|
|
{
|
|
buttons[i].interactable = (i < unlockedLevel);
|
|
}
|
|
}
|
|
|
|
public void OpenLevel(int levelId)
|
|
{
|
|
int firstSceneIndex = levelId * 10;
|
|
string levelSceneName = "game" + firstSceneIndex;
|
|
SceneManager.LoadScene(levelSceneName);
|
|
}
|
|
|
|
|
|
}
|