Ejemplo n.º 1
0
        public T ParseJSON <T>(JSONNode eventNode, ref float beatsPerMinute, ref float shuffle, ref float shufflePeriod) where T : ChromaJSONBeatmapObject
        {
            JSONNode.Enumerator nodeEnum = eventNode.GetEnumerator();
            while (nodeEnum.MoveNext())
            {
                string   key  = nodeEnum.Current.Key;
                JSONNode node = nodeEnum.Current.Value;

                switch (key)
                {
                case "_time":
                    time = GetRealTimeFromBPMTime(node.AsFloat, ref beatsPerMinute, ref shuffle, ref shufflePeriod);
                    break;

                case "_type":
                    type = (BeatmapEventType)node.AsInt;
                    break;

                default:
                    ParseNode(key, node);
                    break;
                }
            }

            return(this as T);
        }
Ejemplo n.º 2
0
        internal static IList <Subject> OptionalListOf(JSONNode subjectsNode)
        {
            if (subjectsNode == null)
            {
                return(null);
            }

            List <Subject> list = new List <Subject>();

            JSONNode.Enumerator e = subjectsNode.GetEnumerator();
            while (e.MoveNext())
            {
                KeyValuePair <String, JSONNode> pair = e.Current;
                list.Add(new Subject(pair.Key, pair.Value.AsLong));
            }
            return(list.Count == 0 ? null : list);
        }
 public void Next()
 {
     if (opener.IsOpen())
     {
         JSONNode line = conversation.Current.Value;
         text.text   = line["text"];
         face.sprite = getSprite(line["speaker"]);
         if (conversation.MoveNext())
         {
             line        = conversation.Current.Value;
             text.text   = line["text"];
             face.sprite = getSprite(line["speaker"]);
         }
         else
         {
             opener.ClosePopup();
         }
     }
 }
 public void LoadConversation(string conversationKey)
 {
     if (faces.Count == 0)
     {
         foreach (NamedImage pic in pictures)
         {
             faces.Add(pic.name, pic.image);
         }
     }
     Debug.Log("Loading: " + conversationKey);
     conversation = engine.getConversationIter(conversationKey);
     if (conversation.MoveNext())
     {
         JSONNode line = conversation.Current.Value;
         text.text   = line["text"];
         face.sprite = getSprite(line["speaker"]);
         opener.OpenPopup();
     }
 }
Ejemplo n.º 5
0
    public static BeatSaberSong GetSongFromFolder(string directory)
    {
        try {
            JSONNode mainNode = GetNodeFromFile(directory + "/info.dat");
            if (mainNode == null)
            {
                return(null);
            }

            BeatSaberSong song = new BeatSaberSong(directory, mainNode);

            List <DifficultyBeatmapSet> difficultyDataList = new List <DifficultyBeatmapSet>();

            JSONNode.Enumerator nodeEnum = mainNode.GetEnumerator();
            while (nodeEnum.MoveNext())
            {
                string   key  = nodeEnum.Current.Key;
                JSONNode node = nodeEnum.Current.Value;

                switch (key)
                {
                case "_songName": song.songName = node.Value; break;

                case "_songSubName": song.songSubName = node.Value; break;

                case "_songAuthorName": song.songAuthorName = node.Value; break;

                case "_levelAuthorName": song.levelAuthorName = node.Value; break;

                case "_beatsPerMinute": song.beatsPerMinute = node.AsFloat; break;

                case "_songTimeOffset": song.songTimeOffset = node.AsFloat; break;

                case "_previewStartTime": song.previewStartTime = node.AsFloat; break;

                case "_previewDuration": song.previewDuration = node.AsFloat; break;

                case "_shuffle": song.shuffle = node.AsFloat; break;

                case "_shufflePeriod": song.shufflePeriod = node.AsFloat; break;

                case "_coverImageFilename": song.coverImageFilename = node.Value; break;

                case "_songFilename": song.songFilename = node.Value; break;

                case "_environmentName": song.environmentName = node.Value; break;

                case "_customData": song.customData = node; break;

                case "_difficultyBeatmapSets":
                    foreach (JSONNode n in node)
                    {
                        DifficultyBeatmapSet set = new DifficultyBeatmapSet();
                        set.beatmapCharacteristicName = n["_beatmapCharacteristicName"];
                        foreach (JSONNode d in n["_difficultyBeatmaps"])
                        {
                            DifficultyBeatmap beatmap = new DifficultyBeatmap(set)
                            {
                                difficulty              = d["_difficulty"].Value,
                                difficultyRank          = d["_difficultyRank"].AsInt,
                                noteJumpMovementSpeed   = d["_noteJumpMovementSpeed"].AsFloat,
                                noteJumpStartBeatOffset = d["_noteJumpStartBeatOffset"].AsFloat,
                                customData              = d["_customData"],
                            };
                            if (d["_customData"]["_colorLeft"] != null)
                            {
                                beatmap.colorLeft = GetColorFromJSONNode(d["_customData"]["_colorLeft"]);
                            }
                            if (d["_customData"]["_colorRight"] != null)
                            {
                                beatmap.colorRight = GetColorFromJSONNode(d["_customData"]["_colorRight"]);
                            }
                            beatmap.UpdateName(d["_beatmapFilename"]);
                            set.difficultyBeatmaps.Add(beatmap);
                        }
                        //Debug.Log("Found difficulty data for " + difficultyData.jsonPath);
                        difficultyDataList.Add(set);
                    }

                    break;
                }
            }

            song.difficultyBeatmapSets = difficultyDataList;

            return(song);
        } catch (Exception e) {
            Debug.LogError(e);
            return(null);
        }
    }
    private IEnumerator Start()
    {
        string clientId     = "client_id";
        string clientSecret = "client_secret";
        string code         = "AIzaSyCMvDz1MWInfV2iZC7gG4t-TFaLLGMZ6iA";

        LocalServer(delegate(string c)
        {
            code = c;
        });
        Application.OpenURL("https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id=" + clientId + "&redirect_uri=http://localhost:8080&scope=https://www.googleapis.com/auth/youtube.readonly&access_type=offline");
        yield return(new WaitUntil(() => code != ""));

        Debug.Log(code);
        string uri = "https://www.googleapis.com/oauth2/v4/token";
        Dictionary <string, string> formFields = new Dictionary <string, string>
        {
            {
                "code",
                code
            },
            {
                "client_id",
                clientId
            },
            {
                "client_secret",
                clientSecret
            },
            {
                "redirect_uri",
                "http://localhost:8080"
            },
            {
                "grant_type",
                "authorization_code"
            },
            {
                "access_type",
                "offline"
            }
        };
        UnityWebRequest request = UnityWebRequest.Post(uri, formFields);

        yield return(request.SendWebRequest());

        JSONNode jSONNode = JSON.Parse(request.downloadHandler.text);
        string   token    = jSONNode["access_token"].Value;

        Debug.Log(token);
        string str = "https://www.googleapis.com/youtube/v3/liveBroadcasts?part=snippet";

        str += "&id=xxxxxxxxxxx";
        UnityWebRequest req2 = UnityWebRequest.Get(str);

        req2.SetRequestHeader("Authorization", "Bearer " + token);
        yield return(req2.SendWebRequest());

        jSONNode = JSON.Parse(req2.downloadHandler.text);
        string text = jSONNode["items"][0]["snippet"]["liveChatId"].Value;

        Debug.Log(text);
        str  = "https://www.googleapis.com/youtube/v3/liveChat/messages?part=snippet,authorDetails";
        str  = str + "&liveChatId=" + text;
        req2 = UnityWebRequest.Get(str);
        req2.SetRequestHeader("Authorization", "Bearer " + token);
        yield return(req2.SendWebRequest());

        jSONNode = JSON.Parse(req2.downloadHandler.text);
        JSONNode.Enumerator enumerator = jSONNode["items"].GetEnumerator();
        while (enumerator.MoveNext())
        {
            KeyValuePair <string, JSONNode> current = enumerator.Current;
            JSONNode jSONNode2 = current.Value["snippet"];
            Debug.Log(current.Value["authorDetails"]["displayName"].Value + ": " + jSONNode2["displayMessage"].Value);
        }
        Debug.Log(jSONNode["nextPageToken"]);
    }