123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- using LitJson;
- using UnityEngine;
- using UnityEngine.Events;
- using System;
- using System.Collections;
- using System.Net;
- using System.Net.Mail;
- using System.Security.Cryptography.X509Certificates;
- using UnityEngine.UI;
- 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 float Timer;
- public static bool LoginComplete;
- public static string ReportStr;
- public static string ID = "Default";
- public static JsonData JsonData;
- public static DateTime Time;
- #endregion
- private void Update()
- {
- if (!LoginComplete)
- {
- Timer += UnityEngine.Time.fixedDeltaTime;
- if (Timer >= 5)
- {
- ManaData.LoginCallbackInitial(new JsonData());
- }
- }
- }
- 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)
- {
- LoginComplete = true;
- if (jsonData.Inst_Object.ContainsKey("c") && jsonData["c"].ToJson() == "0")
- {
- Connect = true;
- JsonData = jsonData;
- Time = DateUtil.GetTime(jsonData["time"].ToJson());
- if (Data._PlayerDoc != null)
- {
- if (Data.GetPlayerString("ID") == "Default")
- {
- ID = jsonData["o"].ToString();
- if (Initializer.LoadComplete)
- {
- ManaReso.SetText("L_UserLab", ID);
- }
- }
- }
- ManaDebug.Log("<color=red>连接成功</color>");
- }
- else
- {
- Connect = false;
- ManaDebug.Log("<color=red>连接失败</color>");
- }
- }
- public static void Save()
- {
- URLRequestData urlData = new URLRequestData();
-
- urlData.Add("u", ID);
- Data.SavePlayerConfig();
- urlData.Add("l", Data.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("<color=red>发送存档成功</color>");
- }
- public static void Load(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 Report()
- {
- ManaReso.Get("Lb_Info").TweenBacCG();
- string str = ManaReso.Get<Text>("Lb_InputLab").text;
- if (string.IsNullOrEmpty(str))
- {
- Bubble.Show(null, Language.GetStr("UI", "Lb_Send2"));
- }
- else if(ReportStr == 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");
- ReportStr = str;
- mailMessage.Body = ReportStr;
- 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"));
- }
- }
- }
|