Example #1
0
    public bool IsLocked(EnumTattooPart part, int playerLevel, out int unlockLevel)
    {
        TattooUnlockData data = dataList.Find(delegate(TattooUnlockData tud) { return(tud.part == part); });

        unlockLevel = data.playerLevel;

        return(unlockLevel > playerLevel);
    }
Example #2
0
    public static void Read()
    {
        bool newFile = false;

        TattooUnlockDataList dataList = null;

        UnityEngine.Object oldFile = AssetDatabase.LoadAssetAtPath(outFileName, typeof(TattooUnlockDataList));
        if (oldFile == null)
        {
            newFile  = true;
            dataList = ScriptableObject.CreateInstance(typeof(TattooUnlockDataList)) as TattooUnlockDataList;
        }
        else
        {
            dataList = oldFile as TattooUnlockDataList;
        }

        dataList.dataList.Clear();

        string jsonStr = File.ReadAllText(fileName);

        JsonHashtable ht = FCJson.jsonDecode(jsonStr) as JsonHashtable;

        foreach (System.Object obj in ht.ValueList)
        {
            Hashtable ht2 = obj as Hashtable;

            TattooUnlockData newData = new TattooUnlockData();

            newData.part        = (EnumTattooPart)(int)ht2["tattooPart"];
            newData.playerLevel = (int)ht2["unlockLevel"];

            dataList.dataList.Add(newData);
        }

        if (newFile)
        {
            AssetDatabase.CreateAsset(dataList, outFileName);
        }
        else
        {
            EditorUtility.SetDirty(dataList);
        }

        dataList.dataList.Sort(new MyComparer());

        Debug.Log(string.Format("Tattoo unlock data imported OK. {0} records.", dataList.dataList.Count));
    }