예제 #1
0
    public static void SaveSlotsList(string path, SlotsList list)
    {
        string json = JsonUtility.ToJson(list);

        StreamWriter sw = File.CreateText(path);

        sw.Close();

        File.WriteAllText(path, json);
    }
예제 #2
0
    /// <summary>
    /// Checa se o número n está dentro da lista dada, caso esteja, retorna true
    /// </summary>
    /// <param name="n"></param>
    /// <param name="list"></param>
    /// <returns></returns>
    public static bool CheckSameNumber(int n, SlotsList list)
    {
        foreach (int p in list.slotsList)
        {
            if (n == p)
            {
                return(true);
            }
        }

        return(false);
    }
예제 #3
0
    /// <summary>
    /// Verifica se existe algum número disponível na lista, caso exista, devolve o primeiro número da lista
    /// </summary>
    /// <param name="list"></param>
    /// <returns></returns>
    public static int SlotGiver(SlotsList list)
    {
        if (list.slotsList.Count == 0)
        {
            return(-1);
        }

        else
        {
            list.slotsList.Sort();
            return(list.slotsList[0]);
        }
    }
예제 #4
0
    public void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (this != instance)
        {
            Destroy(gameObject);
        }
        DontDestroyOnLoad(gameObject);

        dataPath      = Application.persistentDataPath;
        slotsDataPath = System.IO.Path.Combine(dataPath, "listaDeSlots.json");
        list          = SlotsListManager.StartList(slotsDataPath);
    }
예제 #5
0
    /// <summary>
    /// Verifica se há o arquivo das lista de slots na pasta destino, caso não exista, cria um de acordo com o tamanho definido no slotsListSize.
    /// </summary>
    /// <param name="path"></param>
    /// <returns>Retorna a lista de slots que será utilizada</returns>
    public static SlotsList StartList(string path)
    {
        SlotsList list = new SlotsList();

        if (System.IO.File.Exists(path))
        {
            list = SlotsListManager.LoadSlotsList(path);
            return(list);
        }

        else
        {
            for (int i = 0; i < SaveManager.slotsListSize; i++)
            {
                list.slotsList.Add(i);
            }

            SaveSlotsList(path, list);

            return(list);
        }
    }
예제 #6
0
 private void Awake()
 {
     list     = SaveManager.instance.list;
     listSize = SaveManager.slotsListSize;
 }
예제 #7
0
 public void Awake()
 {
     dataPath      = Application.persistentDataPath;
     slotsDataPath = System.IO.Path.Combine(dataPath, "listaDeSlots.json");
     list          = SlotsListManager.StartList(slotsDataPath);
 }