86 lines
2.3 KiB
C#
86 lines
2.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine.UI;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using System;
|
|
using UnityEditor;
|
|
|
|
public class WorldEditor : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private GameObject[] buttonList;
|
|
[SerializeField]
|
|
private Sprite _unlockedIcon;
|
|
[SerializeField]
|
|
private Sprite _lockedIcon;
|
|
[SerializeField]
|
|
private Sprite _savedIcon;
|
|
[SerializeField]
|
|
private LevelSaveClass saveClass;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
//TODO: getMajorSaveFile() //Call et obtiens le chemin du fichier de sauvegarde;
|
|
UnlockLevels();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
/**
|
|
* Debloque les niveaux deja debloquer dans le fichier de sauvegarde majeur.
|
|
*/
|
|
public void UnlockLevels()
|
|
{
|
|
int counterIndex = 0;
|
|
foreach(GameObject CurrentLevelButton in buttonList)
|
|
{
|
|
if (saveClass.GetLevelState(counterIndex) == LevelSaveClass.LevelState.UNLOCKED)
|
|
{
|
|
CurrentLevelButton.SetActive(true);
|
|
ShowUnlockedIcon(CurrentLevelButton);
|
|
}
|
|
else if (saveClass.GetLevelState(counterIndex) == LevelSaveClass.LevelState.LOCKED)
|
|
{
|
|
//CurrentLevelButton.SetActive(false);
|
|
ShowLockedIcon(CurrentLevelButton);
|
|
}
|
|
else
|
|
{
|
|
CurrentLevelButton.SetActive(true);
|
|
ShowSavedIcon(CurrentLevelButton);
|
|
}
|
|
counterIndex++;
|
|
}
|
|
}
|
|
|
|
private void ShowLockedIcon(GameObject currentLevelButton)
|
|
{
|
|
currentLevelButton.GetComponent<Image>().sprite = _lockedIcon;
|
|
}
|
|
|
|
private void ShowUnlockedIcon(GameObject currentLevelButton)
|
|
{
|
|
currentLevelButton.GetComponent<Image>().sprite = _unlockedIcon;
|
|
}
|
|
private void ShowSavedIcon(GameObject currentLevelButton)
|
|
{
|
|
currentLevelButton.GetComponent<Image>().sprite = _savedIcon;
|
|
}
|
|
|
|
public void CallLevelWorld1(int levelToCall)
|
|
{
|
|
string levelToGet = "1-" + levelToCall;
|
|
if (buttonList[levelToCall - 1].GetComponent<Image>().sprite.name != "worldmap_level_locked")
|
|
{
|
|
LevelManager.Instance.LoadLevel(levelToGet, true);
|
|
}
|
|
|
|
}
|
|
}
|