Esempio n. 1
0
    /// <summary>
    /// 存账号信息
    /// </summary>
    /// <param name="account"></param>
    void SaveLoginData(string account)
    {
        StringBuilder sb = new StringBuilder("{");

        sb.Append("\"account\":\"" + account + "\"}");
        MiscUtils.CreateTextFile(ConstantUtils.loginConfigPath, sb.ToString());
    }
Esempio n. 2
0
    /// <summary>
    /// 保存token信息到本地
    /// </summary>
    static void SaveToken(string token)
    {
        StringBuilder sb = new StringBuilder();

        sb.Append("{\"token\":\"" + token);
        sb.Append("\",\"time\":\"" + DateTime.Now);
        sb.Append("\"}");
        MiscUtils.CreateTextFile(ConstantUtils.tonkenConfigPath, sb.ToString());
    }
Esempio n. 3
0
    public static void SaveSet()
    {
        StringBuilder sb = new StringBuilder("{");

        sb.Append("\"off\":\"" + off);
        sb.Append("\",\"read\":\"" + read);
        sb.Append("\",\"chat\":\"" + chat);
        sb.Append("\",\"shock\":\"" + shock);
        sb.Append("\",\"fudong\":\"" + fudong);
        sb.Append("\",\"muisc\":\"" + musicSource);
        sb.Append("\",\"effect\":\"" + soundSource + "\"}");
        MiscUtils.CreateTextFile(ConstantUtils.setConfigPath, sb.ToString());
    }
Esempio n. 4
0
 /// <summary>
 /// 清除聊天记录
 /// </summary>
 /// <param name="chatWithId"></param>
 public void ClearChatLog(string chatWithId)
 {
     if (File.Exists(ConstantUtils.chatConfigPath))
     {
         string   text   = File.ReadAllText(ConstantUtils.chatConfigPath);
         JsonData json   = JsonMapper.ToObject(text);
         string   userId = json.TryGetString(chatWithId);
         if (!string.IsNullOrEmpty(userId))
         {
             string deleteStr1 = string.Format("\"{0}\":", chatWithId) + json[chatWithId].ToJson() + ","; //清一次后面加逗号的
             text = text.Replace(deleteStr1, "");
             string deleteStr2 = "," + string.Format("\"{0}\":", chatWithId) + json[chatWithId].ToJson(); //清一次前面加逗号的
             text = text.Replace(deleteStr2, "");
             string deleteStr3 = string.Format("\"{0}\":", chatWithId) + json[chatWithId].ToJson();       //清一次不加逗号的
             text = text.Replace(deleteStr3, "");
             MiscUtils.CreateTextFile(ConstantUtils.chatConfigPath, text);
         }
     }
 }
Esempio n. 5
0
    void ChatLog(ChatInfo info)
    {
        string contents;

        if (File.Exists(ConstantUtils.chatConfigPath))
        {
            string   text   = File.ReadAllText(ConstantUtils.chatConfigPath);
            JsonData json   = JsonMapper.ToObject(text);
            string   userId = json.TryGetString(info.chatWithId.ToString());
            if (string.IsNullOrEmpty(userId))
            {
                json[info.chatWithId.ToString()]             = new JsonData();
                json[info.chatWithId.ToString()]["name"]     = info.chatWithName;
                json[info.chatWithId.ToString()]["headIcon"] = info.playerBaseInfo.icon;
                json[info.chatWithId.ToString()]["six"]      = info.playerBaseInfo.six == Six.boy ? "0" : "1";

                json[info.chatWithId.ToString()]["history"] = new JsonData();
                json[info.chatWithId.ToString()]["history"].Add(GetChatJson(info));
            }
            else
            {
                json[info.chatWithId.ToString()]["history"].Add(GetChatJson(info));
            }
            contents = json.ToJson();
        }
        else
        {
            JsonData json = new JsonData();

            json[info.chatWithId.ToString()]             = new JsonData();
            json[info.chatWithId.ToString()]["name"]     = info.chatWithName;
            json[info.chatWithId.ToString()]["headIcon"] = info.playerBaseInfo.icon;
            json[info.chatWithId.ToString()]["six"]      = info.playerBaseInfo.six == Six.boy ? "0" : "1";
            json[info.chatWithId.ToString()]["history"]  = new JsonData();

            json[info.chatWithId.ToString()]["history"].Add(GetChatJson(info));
            contents = json.ToJson();
        }


        MiscUtils.CreateTextFile(ConstantUtils.chatConfigPath, contents);
    }
Esempio n. 6
0
 static void CreateJson()
 {
     MiscUtils.CreateTextFile(Application.dataPath + "/Editor Default Resources/AssetBundle/config/CityConfig.json", jsonStr);
     AssetDatabase.Refresh();
 }