using LitJson; using UnityEngine; using UnityEngine.UI; using UnityEngine.Events; using System; using System.Net; using System.Text; using System.Net.Mail; using System.Collections; public class MyCredentials : ICredentialsByHost { public NetworkCredential NetworkCredential; public NetworkCredential GetCredential(string host, int port, string authType) { return NetworkCredential.GetCredential(new Uri("http://" + host + ":" + port), authType); } public MyCredentials(string username, string password) { NetworkCredential = new NetworkCredential(username, password); } } public class ManaServer : Regist { #region 变量 public static bool Connect { get { if (Connect_) { return true; } else { if (ManaTutorial.ConnectExemptAmt > 0) { ManaTutorial.ConnectExemptAmt--; return true; } else { return false; } } } set { Connect_ = value; } } public static bool Connect_; public static int Counter; public static float Timer; public static bool Complete; public static bool FirstConnect = true; public static string ID = "Default"; public static string ReportContent; public static JsonData JsonData; public static DateTime Time; #endregion public void Update() { if (!ManaCenter.Complete && !Complete) { Timer += UnityEngine.Time.fixedDeltaTime; if (Timer >= 2f) { Timer = 0; Counter++; if (Counter > 4) { Complete = true; ManaCenter.LoginCallbackInitial(new JsonData()); } else { Login(ManaCenter.LoginCallbackInitial); } } } } public override bool RegistImmed() { if (base.RegistImmed()) { return true; } enabled = true; return false; } public static void Login(URLRequest.URLRequestJsonCallBackDelegate callback = null) { URLRequestData urlData = new URLRequestData(); urlData.Add("u", SystemInfo.deviceUniqueIdentifier); URLRequest.CreateURLRequest("https://garden.dashgame.com/index.php/home/user/login", urlData, LoginCallback + callback, URLRequest.Method.POST); } private static void LoginCallback(JsonData jsonData) { Complete = true; if (jsonData.Inst_Object.ContainsKey("c")) { Connect = true; JsonData = jsonData; Time = DateUtil.GetTime(jsonData["time"].ToJson()); if (ManaData.DamageLock) { ID = jsonData["o"].ToString(); } else if (ManaData.PlayerDoc_ != null) { if (ManaData.GetPlayerString("ID") == "Default") { ID = jsonData["o"].ToString(); if (Initializer.Complete) { ManaReso.SetText("L_UserLab", ID); } } } if (FirstConnect) { FirstConnect = false; StaticsManager.GetInstance().ActOrReg(ID, DataEyeGA.AccountType.Official); } ManaDebug.Log("连接成功"); } else { Connect = false; ManaDebug.Log("连接失败"); } } public static void Save() { ManaCenter.SaveTimer = 0; URLRequestData urlData = new URLRequestData(); urlData.Add("u", ID); ManaData.SavePlayerConfig(); urlData.Add("l", ManaData.PlayerDoc.OuterXml); URLRequest.CreateURLRequest("https://garden.dashgame.com/index.php/home/user/save", urlData, SaveCallback, URLRequest.Method.POST); } private static void SaveCallback(JsonData jsonData) { ManaDebug.Log("发送存档成功"); } public static void Download(string id, URLRequest.URLRequestJsonCallBackDelegate callback) { URLRequestData urlData = new URLRequestData(); urlData.Add("u", id); URLRequest.CreateURLRequest("https://garden.dashgame.com/index.php/home/user/load", urlData, callback, URLRequest.Method.POST); } public static void RandomLoad(URLRequest.URLRequestJsonCallBackDelegate callback) { URLRequestData urlData = new URLRequestData(); urlData.Add("i", ""); URLRequest.CreateURLRequest("https://garden.dashgame.com/index.php/home/user/rand", urlData, callback, URLRequest.Method.POST); } public static void Report() { ManaReso.Get("Lb_Info").TweenBacCG(); string str = ManaReso.Get("Lb_InputLab").text; if (string.IsNullOrEmpty(str)) { Bubble.Show(null, Language.GetStr("UI", "Lb_Send2")); } else if(ReportContent == str) { Bubble.Show(null, Language.GetStr("UI", "Lb_Send1")); } else { MailMessage mailMessage = new MailMessage(); mailMessage.To.Add(new MailAddress("bug@dashgame.com")); mailMessage.From = new MailAddress("dashgamegarden@163.com"); ReportContent = str; mailMessage.Body = ReportContent + '\n' + GetSystemInfo(); mailMessage.Subject = ID + " MyLovelyGargen Issue"; SmtpClient smtpClient = new SmtpClient("smtp.163.com"); smtpClient.Credentials = new MyCredentials("dashgamegarden@163.com", "cs670cs"); smtpClient.SendAsync(mailMessage, "Async"); Bubble.Show(null, Language.GetStr("UI", "Lb_Send0")); } } public static string GetSystemInfo() { StringBuilder sb = new StringBuilder(); sb.AppendLine("deviceType :" + SystemInfo.deviceType.ToString()); sb.AppendLine("deviceName :" + SystemInfo.deviceName.ToString()); sb.AppendLine("deviceModel :" + SystemInfo.deviceModel.ToString()); sb.AppendLine("deviceUniqueIdentifier :" + SystemInfo.deviceUniqueIdentifier.ToString()); sb.AppendLine("graphicsDeviceID :" + SystemInfo.graphicsDeviceID.ToString()); sb.AppendLine("graphicsDeviceType :" + SystemInfo.graphicsDeviceType.ToString()); sb.AppendLine("graphicsDeviceName :" + SystemInfo.graphicsDeviceName.ToString()); sb.AppendLine("graphicsShaderLevel :" + SystemInfo.graphicsShaderLevel.ToString()); sb.AppendLine("graphicsMemorySize :" + SystemInfo.graphicsMemorySize.ToString()); sb.AppendLine("graphicsDeviceVersion :" + SystemInfo.graphicsDeviceVersion.ToString()); sb.AppendLine("graphicsMultiThreaded :" + SystemInfo.graphicsMultiThreaded.ToString()); sb.AppendLine("graphicsDeviceVendor :" + SystemInfo.graphicsDeviceVendor.ToString()); sb.AppendLine("graphicsDeviceVendorID :" + SystemInfo.graphicsDeviceVendorID.ToString()); sb.AppendLine("npotSupport :" + SystemInfo.npotSupport.ToString()); sb.AppendLine("maxTextureSize :" + SystemInfo.maxTextureSize.ToString()); sb.AppendLine("operatingSystem :" + SystemInfo.operatingSystem.ToString()); sb.AppendLine("operatingSystemFamily :" + SystemInfo.operatingSystemFamily.ToString()); sb.AppendLine("processorType :" + SystemInfo.processorType.ToString()); sb.AppendLine("processorCount :" + SystemInfo.processorCount.ToString()); sb.AppendLine("processorFrequency :" + SystemInfo.processorFrequency.ToString()); sb.AppendLine("copyTextureSupport :" + SystemInfo.copyTextureSupport.ToString()); sb.AppendLine("graphicsMultiThreaded :" + SystemInfo.graphicsMultiThreaded.ToString()); sb.AppendLine("supportedRenderTargetCount :" + SystemInfo.supportedRenderTargetCount.ToString()); sb.AppendLine("supports3DTextures :" + SystemInfo.supports3DTextures.ToString()); sb.AppendLine("supports2DArrayTextures :" + SystemInfo.supports2DArrayTextures.ToString()); sb.AppendLine("supportsAccelerometer :" + SystemInfo.supportsAccelerometer.ToString()); sb.AppendLine("supportsAudio :" + SystemInfo.supportsAudio.ToString()); sb.AppendLine("supportsComputeShaders :" + SystemInfo.supportsComputeShaders.ToString()); sb.AppendLine("supportsCubemapArrayTextures :" + SystemInfo.supportsCubemapArrayTextures.ToString()); sb.AppendLine("supportsGyroscope :" + SystemInfo.supportsGyroscope.ToString()); sb.AppendLine("supportsImageEffects :" + SystemInfo.supportsImageEffects.ToString()); sb.AppendLine("supportsInstancing :" + SystemInfo.supportsInstancing.ToString()); sb.AppendLine("supportsLocationService :" + SystemInfo.supportsLocationService.ToString()); sb.AppendLine("supportsMotionVectors :" + SystemInfo.supportsMotionVectors.ToString()); sb.AppendLine("supportsRawShadowDepthSampling :" + SystemInfo.supportsRawShadowDepthSampling.ToString()); sb.AppendLine("supportsRenderToCubemap :" + SystemInfo.supportsRenderToCubemap.ToString()); sb.AppendLine("supportsShadows :" + SystemInfo.supportsShadows.ToString()); sb.AppendLine("supportsSparseTextures :" + SystemInfo.supportsSparseTextures.ToString()); sb.AppendLine("supportsVibration :" + SystemInfo.supportsVibration.ToString()); sb.AppendLine("systemMemorySize :" + SystemInfo.systemMemorySize.ToString()); sb.AppendLine("usesReversedZBuffer :" + SystemInfo.usesReversedZBuffer.ToString()); return sb.ToString(); } }