Ejemplo n.º 1
0
 public void GetMessages()
 {
     StartCoroutine(Get(
                        String.Format(urltemplate, "message", ""),
                        (UnityWebRequest webRequest) => {
         if (webRequest.isNetworkError)
         {
             //txtLeaderboard.text = "<color=red>There was a network error! Please try again.</color>";
             Debug.Log("Failed to fetch chat history! " + webRequest.error);
             chat.AddLine("<color=red>Failed to fetch chat history!</color>");
             return(false);
         }
         Messages result = JsonConvert.DeserializeObject <Messages>(webRequest.downloadHandler.text);
         if (result.success)
         {
             Array.Reverse(result.messages);
             for (int i = 0; i < result.messages.Length; i++)
             {
                 if (messages.Count == 0 || result.messages[i].id > messages[messages.Count - 1].id)
                 {
                     chat.AddLine(result.messages[i]);
                     messages.Add(result.messages[i]);
                 }
             }
             return(true);
         }
         else
         {
             chat.AddLine("<color=red>" + result.msg + "</color>");
             return(false);
         }
     }
                        ));
 }
        /// <summary>
        /// Opens help content from the ScriptLibrary.
        /// </summary>
        /// <param name="subClass">The subClass used in @help().</param>
        private static void DoHelp(string subClass)
        {
            if (subClass.EndsWith(")") == true)
            {
                subClass = subClass.Remove(subClass.Length - 1, 1);
            }
            Chat.AddLine(new Chat.ChatMessage("[HELP]", ScriptLibrary.GetHelpContent(subClass, 20), "0", Chat.ChatMessage.MessageTypes.CommandMessage));

            IsReady = true;
        }