ManaServer.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  1. using LitJson;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. using UnityEngine.Events;
  5. using System;
  6. using System.IO;
  7. using System.Net;
  8. using System.Xml;
  9. using System.Text;
  10. using System.Linq;
  11. using System.Net.Mail;
  12. using System.Collections;
  13. using System.Collections.Generic;
  14. using Random = UnityEngine.Random;
  15. public class MyCredentials : ICredentialsByHost
  16. {
  17. public NetworkCredential NetworkCredential;
  18. public NetworkCredential GetCredential(string host, int port, string authType)
  19. {
  20. return NetworkCredential.GetCredential(new Uri("http://" + host + ":" + port), authType);
  21. }
  22. public MyCredentials(string username, string password)
  23. {
  24. NetworkCredential = new NetworkCredential(username, password);
  25. }
  26. }
  27. public enum CommentType
  28. {
  29. Garden = 0,
  30. }
  31. public class ManaServer : Regist
  32. {
  33. public class MailReward
  34. {
  35. public string Id;
  36. public string Key;
  37. public string Value;
  38. public MailReward(string id, string key, string value)
  39. {
  40. Id = id;
  41. Key = key;
  42. Value = value;
  43. }
  44. }
  45. #region 变量
  46. public static bool Connect
  47. {
  48. get
  49. {
  50. if (Connect_)
  51. {
  52. return true;
  53. }
  54. else
  55. {
  56. if (ManaTutorial.ConnectExemptAmt > 0)
  57. {
  58. ManaTutorial.ConnectExemptAmt--;
  59. return true;
  60. }
  61. else
  62. {
  63. return false;
  64. }
  65. }
  66. }
  67. set { Connect_ = value; }
  68. }
  69. public static bool PackLock
  70. {
  71. get { return PackLock_; }
  72. set
  73. {
  74. PackLock_ = value;
  75. foreach (var kv in ManaCenter.SkillDic)
  76. {
  77. if (kv.Value is Pack)
  78. {
  79. ((Pack) kv.Value).SetActive(!PackLock_);
  80. }
  81. }
  82. }
  83. }
  84. public static bool Connect_;
  85. public static bool PackLock_;
  86. public static int Counter;
  87. public static int PraiseAmt;
  88. public static int NotificationIndex = -1;
  89. public static bool NotificationReady;
  90. public static string NotificationStr;
  91. public static Sprite NotificationSprite;
  92. public static float Timer;
  93. public static bool Complete;
  94. public static bool FirstConnect = true;
  95. public static string ID = "Default";
  96. public static string SerialNumber = "Default";
  97. public static string ReportContent;
  98. public static JsonData JsonData;
  99. public static DateTime Time;
  100. public static string MailXml;
  101. public static List<MailReward> MailRewardList = new List<MailReward>();
  102. public static string BaseURL = "https://garden.dashgame.com/index.php/home";
  103. public static string NewBaseURL = "https://garden.dashgame.com/index.php/newhome";
  104. #endregion
  105. public void Awake()
  106. {
  107. //URLRequestData urlData = new URLRequestData();
  108. //urlData.Add("u", "1704189794672324513");
  109. //URLRequest.CreateStrURLRequest("https://garden.dashgame.com/index.php/home/user/other", urlData, Debug.Log, URLRequest.Method.POST);
  110. //URLRequestData urlData = new URLRequestData();
  111. //urlData.Add("i", "");
  112. //URLRequest.CreateStrURLRequest("https://garden.dashgame.com/index.php/home/user/rand", urlData, Debug.Log, URLRequest.Method.POST);
  113. //URLRequestData urlData = new URLRequestData();
  114. //urlData.Add("u", "hsoiv1");
  115. //URLRequest.CreateStrURLRequest("https://garden.dashgame.com/index.php/home/user/load", urlData, Debug.Log, URLRequest.Method.POST);
  116. //Login((data => print(data.ToJson())));
  117. //Download("ytcy9g",(data)=> { print(data.ToJson()); });
  118. //Other("1704189794672324513", (data) => { print(data.ToJson()); });
  119. //for (int i = 0; i < 10; i++)
  120. //{
  121. // string str = "";
  122. // for (int j = 0; j < 80; j++)
  123. // {
  124. // str += Random.Range(0, 100);
  125. // }
  126. // AddComment("1704189794672324513", "1706142186026389627", 1, CommentType.Garden);
  127. //}
  128. //GetComment("123", "0", CommentType.Garden);
  129. //Praise("123", "1704189794672324513");
  130. //Target("", "1704189794672324513",null);
  131. //URLRequestData urlData = new URLRequestData();
  132. //URLRequest.CreateStrURLRequest("https://garden.dashgame.com/index.php/home/user/look", urlData, Debug.Log, URLRequest.Method.GET);
  133. }
  134. public void Update()
  135. {
  136. if (!ManaCenter.Complete && !Complete)
  137. {
  138. Timer += UnityEngine.Time.deltaTime;
  139. if (Timer >= 2f)
  140. {
  141. Timer = 0;
  142. Counter++;
  143. if (Counter > 4)
  144. {
  145. Complete = true;
  146. ManaCenter.LoginCallbackInitial(new JsonData());
  147. }
  148. else
  149. {
  150. Login(ManaCenter.LoginCallbackInitial);
  151. IOSAlipayRequest();
  152. }
  153. }
  154. }
  155. }
  156. public override bool RegistImmed()
  157. {
  158. if (base.RegistImmed())
  159. {
  160. return true;
  161. }
  162. enabled = true;
  163. return false;
  164. }
  165. public static void NotificationRequest()
  166. {
  167. //Debug.Log("A");
  168. IndexRequest
  169. (
  170. data =>
  171. {
  172. //Debug.Log("B");
  173. URLRequestData urlData = new URLRequestData();
  174. URLRequest.CreateStrURLRequest
  175. (
  176. data["l"][3]["val"].ToString(),
  177. urlData,
  178. notificationXml =>
  179. {
  180. //Debug.Log("C");
  181. NotificationCallback(notificationXml);
  182. }
  183. );
  184. }
  185. );
  186. }
  187. public static void NotificationCallback(string xml)
  188. {
  189. //Debug.Log("D");
  190. XmlNode rootNode;
  191. XmlDocument document = new XmlDocument();
  192. try
  193. {
  194. document.LoadXml(xml);
  195. rootNode = document.SelectSingleNode("announce");
  196. NotificationIndex = int.Parse(rootNode.SelectSingleNode("version").InnerText);
  197. XmlNodeList nodeList = rootNode.SelectNodes("item");
  198. List<string> urlList = new List<string>();
  199. for (int i = 0; i < nodeList.Count; i++)
  200. {
  201. DecodeNotificationItem(nodeList[i], urlList);
  202. }
  203. Auxiliary.Instance.StartCoroutine(PullNotifyTexs(urlList, PullNotifyTexsCallback));
  204. }
  205. catch (Exception)
  206. {
  207. }
  208. finally
  209. {
  210. }
  211. }
  212. public static void DecodeNotificationItem(XmlNode node, List<string> urlList)
  213. {
  214. XmlNodeList nodeList = node.SelectNodes("title");
  215. for (int i = 0; i < nodeList.Count; i++)
  216. {
  217. ManaNotify.AddLine(false, nodeList[i].Attributes[0].Value, nodeList[i].InnerText, TextAnchor.MiddleLeft);
  218. }
  219. ManaNotify.AddLine(false, "null", node.SelectSingleNode("date").InnerText, TextAnchor.MiddleLeft);
  220. nodeList = node.SelectSingleNode("content").ChildNodes;
  221. for (int i = 0; i < nodeList.Count; i++)
  222. {
  223. if (nodeList[i].Name == "text")
  224. {
  225. ManaNotify.AddLine(false, nodeList[i].Attributes[0].Value, nodeList[i].InnerText, TextAnchor.MiddleLeft);
  226. }
  227. else if (nodeList[i].Name == "image")
  228. {
  229. urlList.UniqueAdd(nodeList[i].InnerText);
  230. ManaNotify.AddLine(true, "null", $"<({Path.GetFileNameWithoutExtension(nodeList[i].InnerText)})>", TextAnchor.MiddleCenter);
  231. }
  232. }
  233. ManaNotify.AddLine(false, "null", "", TextAnchor.MiddleLeft);
  234. }
  235. public static void PullNotifyTexsCallback(List<WWW> wwwList)
  236. {
  237. List<Texture2D> textureList = new List<Texture2D>();
  238. List<SpriteInfo> spriteInfoList = new List<SpriteInfo>();
  239. for (int i = 0; i < wwwList.Count; i++)
  240. {
  241. textureList.Add(wwwList[i].texture);
  242. SpriteInfo spriteInfo = new SpriteInfo();
  243. spriteInfo.Name = Path.GetFileNameWithoutExtension(wwwList[i].url);
  244. spriteInfoList.Add(spriteInfo);
  245. }
  246. Texture2D atlas = new Texture2D(2048, 2048);
  247. Rect[] rects = atlas.PackTextures(textureList.ToArray(), 1);
  248. Sprite sprite = Sprite.Create(atlas, new Rect(0, 0, atlas.width, atlas.height), new Vector2(0.5f, 0.5f));
  249. for (int i = 0; i < spriteInfoList.Count; i++)
  250. {
  251. spriteInfoList[i].Width = textureList[i].width;
  252. spriteInfoList[i].Height = textureList[i].height;
  253. spriteInfoList[i].UvList = new List<Vector2>()
  254. {
  255. new Vector2(rects[i].xMin, rects[i].yMax),
  256. new Vector2(rects[i].xMax, rects[i].yMax),
  257. new Vector2(rects[i].xMax, rects[i].yMin),
  258. new Vector2(rects[i].xMin, rects[i].yMin),
  259. };
  260. SpriteAsset.SpriteInfoDic.Add(spriteInfoList[i].Name, spriteInfoList[i]);
  261. }
  262. NotificationSprite = sprite;
  263. NotificationReady = true;
  264. if (Initializer.Complete)
  265. {
  266. ManaReso.Get("C_Notify").TweenForCG();
  267. }
  268. //Debug.Log("Done");
  269. }
  270. public static IEnumerator PullNotifyTexs(List<string> urlList, Action<List<WWW>> callback)
  271. {
  272. List<WWW> wwwList = new List<WWW>();
  273. for (int i = 0; i < urlList.Count; i++)
  274. {
  275. wwwList.Add(new WWW(urlList[i]));
  276. }
  277. for (int i = 0; i < wwwList.Count; i++)
  278. {
  279. yield return wwwList[i];
  280. }
  281. callback(wwwList);
  282. }
  283. public static void Praise(string sendID, string receiveID)
  284. {
  285. if (receiveID == null)
  286. {
  287. return;
  288. }
  289. URLRequestData urlData = new URLRequestData();
  290. urlData.Add("u", sendID);
  291. urlData.Add("t", receiveID);
  292. URLRequest.CreateStrURLRequest(BaseURL + "/praise/click", urlData, (data)=> {}, URLRequest.Method.POST);
  293. }
  294. public static void Target(string userID, string targetID, Action<JsonData> callback)
  295. {
  296. URLRequestData urlData = new URLRequestData();
  297. urlData.Add("u", userID);
  298. urlData.Add("t", targetID);
  299. URLRequest.CreateURLRequest(BaseURL + "/praise/target", urlData, data => callback(data), URLRequest.Method.POST);
  300. }
  301. public static void AddComment(string sendID, string receiveID, string content, CommentType type)
  302. {
  303. URLRequestData urlData = new URLRequestData();
  304. urlData.Add("c", sendID);
  305. urlData.Add("u", receiveID);
  306. urlData.Add("i", content);
  307. urlData.Add("t", type.GetHashCode());
  308. URLRequest.CreateStrURLRequest
  309. (
  310. BaseURL + "/comment/comment",
  311. urlData,
  312. data =>
  313. {
  314. if (data == "{\"error\":0}")
  315. {
  316. Bubble.Show(Language.GetStr("UI", "Q_CommentDone"));
  317. ManaSocial.UpdatePage(false);
  318. }
  319. else
  320. {
  321. Bubble.Show(Language.GetStr("UI", "Q_CommentFail"));
  322. }
  323. },
  324. URLRequest.Method.POST
  325. );
  326. }
  327. public static void GetComment(string id, string page, CommentType type, Action<JsonData> callback)
  328. {
  329. if (string.IsNullOrEmpty(id))
  330. {
  331. return;
  332. }
  333. URLRequestData urlData = new URLRequestData();
  334. urlData.Add("u", id);
  335. urlData.Add("p", page);
  336. urlData.Add("t", type.GetHashCode());
  337. URLRequest.CreateURLRequest(BaseURL + "/comment/index", urlData, data => callback(data), URLRequest.Method.POST);
  338. }
  339. public static void IndexRequest(Action<JsonData> callback)
  340. {
  341. URLRequestData urlData = new URLRequestData();
  342. URLRequest.CreateURLRequest
  343. (
  344. BaseURL + "/index/index",
  345. urlData,
  346. data =>
  347. {
  348. if (data.Inst_Object.ContainsKey("error"))
  349. {
  350. if (ManaData.PlayerDoc_ != null)
  351. {
  352. if (Application.platform == RuntimePlatform.Android)
  353. {
  354. PackLock = true;
  355. }
  356. else if (Application.platform == RuntimePlatform.IPhonePlayer)
  357. {
  358. PackLock = ManaData.GetPlayerBool("PackLock");
  359. }
  360. }
  361. }
  362. else
  363. {
  364. callback(data);
  365. }
  366. }
  367. );
  368. }
  369. public static void MailRequest()
  370. {
  371. //MailXml = "<mail>" +
  372. // "<OneTimeReward>" +
  373. // "<id>4</id>" +
  374. // "<start>2017-08-18 12:12:12</start>" +
  375. // "<end>2017-09-1 11:30:12</end>" +
  376. // "<reward>" +
  377. // "<coin>1000</coin>" +
  378. // "<diamond>10</diamond>" +
  379. // "</reward>" +
  380. // "<targets>" +
  381. // "<id>90arbl</id>" +
  382. // "</targets>" +
  383. // "</OneTimeReward>" +
  384. // "<OneTimeReward>" +
  385. // "<id>3</id>" +
  386. // "<start>2017-08-21 12:12:12</start>" +
  387. // "<end>2017-09-01 18:12:12</end>" +
  388. // "<reward>" +
  389. // "<coin>10000</coin>" +
  390. // "<diamond>100</diamond>" +
  391. // "</reward>" +
  392. // "<targets>" +
  393. // "<id>90arbl</id>" +
  394. // "</targets>" +
  395. // "</OneTimeReward>" +
  396. // "</mail>";
  397. IndexRequest
  398. (
  399. data =>
  400. {
  401. URLRequestData urlData = new URLRequestData();
  402. URLRequest.CreateStrURLRequest
  403. (
  404. data["l"][1]["val"].ToJson().Trim('"'),
  405. urlData,
  406. mailXml =>
  407. {
  408. MailXml = mailXml;
  409. }
  410. );
  411. }
  412. );
  413. }
  414. public static void GetMailReward()
  415. {
  416. for (int i = 0; i < MailRewardList.Count; i++)
  417. {
  418. GetMailReward(MailRewardList[i]);
  419. }
  420. }
  421. public static void GetMailReward(MailReward mailReward)
  422. {
  423. //Debug.Log(mailReward.Id);
  424. ManaData.SavePlayerString("OneTimeReward", $"{ManaData.GetPlayerString("OneTimeReward")} {mailReward.Id}".Trim(' '));
  425. if (mailReward.Key == "pack")
  426. {
  427. SkillRoot skillRoot;
  428. if (ManaCenter.SkillDic.TryGetValue($"Pack{mailReward.Value}", out skillRoot))
  429. {
  430. Pack pack = (Pack) skillRoot;
  431. pack.PurchaseResult();
  432. Transform mailItem = ManaReso.Get("MailItem", Folder.UI, false, ManaReso.Get("Bd_Grid"), new Vector3(), ObjType.MailItem);
  433. float newSpriteSize = 0.35f;
  434. mailItem.GetChild(1).SetActive(false);
  435. mailItem.GetChild(0).GetComponent<Image>().sprite = pack.Icon;
  436. mailItem.GetChild(0).GetComponent<Image>().Resize(true, newSpriteSize, newSpriteSize);
  437. mailItem.GetChild(0).transform.localPosition = new Vector2(0, 0);
  438. mailItem.GetChild(2).GetComponent<Text>().text = pack.Name;
  439. ManaInfo.Show($"{Language.GetStr("Common", "Get")} <(礼包)>{pack.Name}", 10);
  440. }
  441. else
  442. {
  443. Debug.LogWarning($"Unknown id {mailReward.Value}");
  444. }
  445. }
  446. else if (mailReward.Key == "close")
  447. {
  448. List<int> idList = Auxiliary.IntListParse(' ', mailReward.Value, new List<int>());
  449. CloseUnit closeUnit;
  450. for (int i = 0; i < idList.Count; i++)
  451. {
  452. if (ManaPlayer.CloseUnitDic.TryGetValue(idList[i], out closeUnit))
  453. {
  454. if (closeUnit.Bought == false)
  455. {
  456. closeUnit.Unlock();
  457. ManaPlayer.BoughtCloseList.UniqueAdd(idList[i]);
  458. }
  459. Transform mailItem = ManaReso.Get("MailItem", Folder.UI, false, ManaReso.Get("Bd_Grid"), new Vector3(), ObjType.MailItem);
  460. float newSize = 0.6f;
  461. float newSpriteSize = closeUnit.PixelSize*newSize/closeUnit.Sprites[0].rect.width;
  462. mailItem.GetChild(1).GetComponent<Image>().sprite = closeUnit.Sprites[0];
  463. mailItem.GetChild(1).GetComponent<Image>().Resize(true, newSpriteSize, newSpriteSize);
  464. mailItem.GetChild(1).transform.localPosition = new Vector2(0, closeUnit.IconOffset*newSize);
  465. if (closeUnit.Sprites.Length > 1)
  466. {
  467. mailItem.GetChild(0).SetActive(true);
  468. mailItem.GetChild(0).GetComponent<Image>().sprite = closeUnit.Sprites[1];
  469. mailItem.GetChild(0).GetComponent<Image>().Resize(true, newSpriteSize, newSpriteSize);
  470. mailItem.GetChild(0).transform.localPosition = closeUnit.IconOffset1*newSpriteSize + new Vector2(0, closeUnit.IconOffset*newSize);
  471. }
  472. else
  473. {
  474. mailItem.GetChild(0).SetActive(false);
  475. }
  476. mailItem.GetChild(2).GetComponent<Text>().text = closeUnit.Name;
  477. ManaInfo.Show($"{Language.GetStr("Common", "Get")} <(服装)>{closeUnit.Name}", 10);
  478. }
  479. else
  480. {
  481. Debug.LogWarning($"Unknown id {idList[i]}");
  482. }
  483. }
  484. }
  485. else if (mailReward.Key == "flower")
  486. {
  487. List<int> idList = Auxiliary.IntListParse(' ', mailReward.Value, new List<int>());
  488. FlowerInfo flowerInfo;
  489. for (int i = 0; i < idList.Count; i++)
  490. {
  491. if (ManaGarden.FlowerInfoDic.TryGetValue(idList[i], out flowerInfo))
  492. {
  493. if (flowerInfo.Unlock == false)
  494. {
  495. flowerInfo.Unlock = true;
  496. }
  497. Transform mailItem = ManaReso.Get("MailItem", Folder.UI, false, ManaReso.Get("Bd_Grid"), new Vector3(), ObjType.MailItem);
  498. float newSpriteSize = 0.18f;
  499. mailItem.GetChild(1).SetActive(false);
  500. mailItem.GetChild(0).GetComponent<Image>().sprite = flowerInfo.Icon;
  501. mailItem.GetChild(0).GetComponent<Image>().Resize(true, newSpriteSize, newSpriteSize);
  502. mailItem.GetChild(0).transform.localPosition = new Vector2(0, 0);
  503. mailItem.GetChild(2).GetComponent<Text>().text = flowerInfo.Name;
  504. ManaInfo.Show($"{Language.GetStr("Common", "Get")} <(花朵)>{flowerInfo.Name}", 10);
  505. }
  506. else
  507. {
  508. Debug.LogWarning($"Unknown id {idList[i]}");
  509. }
  510. }
  511. }
  512. else if (mailReward.Key == "coin")
  513. {
  514. ManaCenter.AddCoin(double.Parse(mailReward.Value), StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.Mail);
  515. Transform mailItem = ManaReso.Get("MailItem", Folder.UI, false, ManaReso.Get("Bd_Grid"), new Vector3(), ObjType.MailItem);
  516. float newSpriteSize = 0.75f;
  517. mailItem.GetChild(1).SetActive(false);
  518. mailItem.GetChild(0).GetComponent<Image>().sprite = ManaReso.LoadSprite("金币", Folder.UI);
  519. mailItem.GetChild(0).GetComponent<Image>().Resize(true, newSpriteSize, newSpriteSize);
  520. mailItem.GetChild(0).transform.localPosition = new Vector2(0, 0);
  521. mailItem.GetChild(2).GetComponent<Text>().text = Auxiliary.ShrinkNumberStr(double.Parse(mailReward.Value));
  522. ManaInfo.Show($"{Language.GetStr("Common", "Get")} <(金币)>{Auxiliary.ShrinkNumberStr(double.Parse(mailReward.Value))}", 10);
  523. }
  524. else if (mailReward.Key == "diamond")
  525. {
  526. ManaCenter.AddDiamond(double.Parse(mailReward.Value), StaticsManager.ItemID.获得钻石, StaticsManager.ConsumeModule.Mail);
  527. Transform mailItem = ManaReso.Get("MailItem", Folder.UI, false, ManaReso.Get("Bd_Grid"), new Vector3(), ObjType.MailItem);
  528. float newSpriteSize = 0.75f;
  529. mailItem.GetChild(1).SetActive(false);
  530. mailItem.GetChild(0).GetComponent<Image>().sprite = ManaReso.LoadSprite("钻石", Folder.UI);
  531. mailItem.GetChild(0).GetComponent<Image>().Resize(true, newSpriteSize, newSpriteSize);
  532. mailItem.GetChild(0).transform.localPosition = new Vector2(0, 0);
  533. mailItem.GetChild(2).GetComponent<Text>().text = Auxiliary.ShrinkNumberStr(double.Parse(mailReward.Value));
  534. ManaInfo.Show($"{Language.GetStr("Common", "Get")} <(钻石)>{Auxiliary.ShrinkNumberStr(double.Parse(mailReward.Value))}", 10);
  535. }
  536. else
  537. {
  538. Debug.Log(mailReward.Key);
  539. }
  540. }
  541. public static void DecodeMailXml(string mailXml)
  542. {
  543. MailRewardList = new List<MailReward>();
  544. XmlDocument xmlDoc = new XmlDocument();
  545. //Debug.Log("Decode");
  546. try
  547. {
  548. xmlDoc.LoadXml(mailXml);
  549. }
  550. catch (Exception)
  551. {
  552. return;
  553. }
  554. XmlNodeList rewardNodeList = xmlDoc.SelectSingleNode("mail").SelectNodes("OneTimeReward");
  555. //Debug.Log(ManaData.GetPlayerString("OneTimeReward"));
  556. List<string> receivedIdList = Auxiliary.StringListParse(' ', ManaData.GetPlayerString("OneTimeReward"), new List<string>());
  557. //Debug.Log("");
  558. //foreach (var id in receivedIdList)
  559. //{
  560. // Debug.Log(id);
  561. //}
  562. //Debug.Log("");
  563. for (int i = 0; i < rewardNodeList.Count; i++)
  564. {
  565. string id = rewardNodeList[i].SelectSingleNode("id").InnerText;
  566. //Debug.Log(id);
  567. if (receivedIdList.Contains(id))
  568. {
  569. continue;
  570. }
  571. DateTime startTime = DateTime.Parse(rewardNodeList[i].SelectSingleNode("start").InnerText);
  572. DateTime endTime = DateTime.Parse(rewardNodeList[i].SelectSingleNode("end").InnerText);
  573. if (Time < startTime || Time > endTime)
  574. {
  575. //Debug.Log("Skip");
  576. continue;
  577. }
  578. XmlNodeList targetIdNodeList = rewardNodeList[i].SelectSingleNode("targets").SelectNodes("id");
  579. for (int j = 0; j < targetIdNodeList.Count; j++)
  580. {
  581. if (targetIdNodeList[j].InnerText == ID)
  582. {
  583. XmlNodeList xmlNodeList = rewardNodeList[i].SelectSingleNode("reward").ChildNodes;
  584. for (int k = 0; k < xmlNodeList.Count; k++)
  585. {
  586. MailRewardList.Add(new MailReward(id, xmlNodeList[k].Name, xmlNodeList[k].InnerText));
  587. }
  588. break;
  589. }
  590. }
  591. }
  592. }
  593. public static void PackTypeRequest()
  594. {
  595. IndexRequest
  596. (
  597. data =>
  598. {
  599. PackLock = Auxiliary.BoolParse(data["l"][0]["val"].ToJson().Trim('"'), true);
  600. if (Application.platform == RuntimePlatform.Android)
  601. {
  602. PackLock = true;
  603. }
  604. if (ManaData.PlayerDoc_ != null)
  605. {
  606. ManaData.SavePlayerBool("PackLock", PackLock);
  607. }
  608. }
  609. );
  610. }
  611. public static void IOSAlipayRequest()
  612. {
  613. IndexRequest
  614. (
  615. data =>
  616. {
  617. ManaIAP.UseAlipayOnIOS = Auxiliary.BoolParse(data["l"][2]["val"].ToJson().Trim('"'), false);
  618. }
  619. );
  620. }
  621. public static void GetProductID(string id, URLRequest.URLRequestCallBackDelegate callback)
  622. {
  623. URLRequestData urlData = new URLRequestData();
  624. urlData.Add("t", 1);
  625. urlData.Add("i", id);
  626. urlData.Add("u", JsonData.Inst_Object["i"].ToJson().Trim('"'));
  627. URLRequest.CreateStrURLRequest(BaseURL + "/pay/pay", urlData, callback, URLRequest.Method.POST);
  628. }
  629. public static void Login(URLRequest.URLRequestJsonCallBackDelegate callback = null)
  630. {
  631. URLRequestData urlData = new URLRequestData();
  632. urlData.Add("u", SystemInfo.deviceUniqueIdentifier);
  633. URLRequest.CreateURLRequest(NewBaseURL + "/user/login", urlData, LoginCallback + callback, URLRequest.Method.POST);
  634. }
  635. private static void LoginCallback(JsonData jsonData)
  636. {
  637. Complete = true;
  638. if (jsonData.Inst_Object.ContainsKey("c"))
  639. {
  640. Connect = true;
  641. JsonData = jsonData;
  642. Time = DateUtil.GetTime(jsonData["time"].ToJson());
  643. PraiseAmt = int.Parse(jsonData["p"].ToJson().Trim('"'));
  644. if (ManaData.DamageLock)
  645. {
  646. ID = jsonData["o"].ToString();
  647. SerialNumber = jsonData["i"].ToString();
  648. }
  649. else if (ManaData.PlayerDoc_ != null)
  650. {
  651. if (ManaData.GetPlayerString("ID") == "Default")
  652. {
  653. ID = jsonData["o"].ToString();
  654. SerialNumber = jsonData["i"].ToString();
  655. if (Initializer.Complete)
  656. {
  657. ManaReso.SetText("L_UserLab", ID);
  658. }
  659. }
  660. }
  661. if (FirstConnect)
  662. {
  663. FirstConnect = false;
  664. StaticsManager.GetInstance().ActOrReg(ID, DataEyeGA.AccountType.Official);
  665. }
  666. ManaDebug.Log("<color=red>连接成功</color>");
  667. }
  668. else
  669. {
  670. Connect = false;
  671. ManaDebug.Log("<color=red>连接失败</color>");
  672. }
  673. }
  674. public static void Save()
  675. {
  676. ManaCenter.SaveTimer = 0;
  677. URLRequestData urlData = new URLRequestData();
  678. urlData.Add("u", SerialNumber);
  679. ManaData.SavePlayerConfig();
  680. urlData.Add("l", ManaData.PlayerDoc.OuterXml);
  681. URLRequest.CreateURLRequest(NewBaseURL + "/user/save", urlData, SaveCallback, URLRequest.Method.POST);
  682. //URLRequest.CreateStrURLRequest(NewBaseURL + "/user/save", urlData, Debug.Log, URLRequest.Method.POST);
  683. }
  684. private static void SaveCallback(JsonData jsonData)
  685. {
  686. ManaDebug.Log("<color=red>发送存档成功</color>");
  687. }
  688. public static void Other(string id, URLRequest.URLRequestJsonCallBackDelegate callback)
  689. {
  690. URLRequestData urlData = new URLRequestData();
  691. urlData.Add("u", id);
  692. URLRequest.CreateURLRequest(BaseURL + "/user/other", urlData, callback, URLRequest.Method.POST);
  693. }
  694. public static void DownloadByID(string id, URLRequest.URLRequestJsonCallBackDelegate callback)
  695. {
  696. URLRequestData urlData = new URLRequestData();
  697. urlData.Add("u", id);
  698. URLRequest.CreateURLRequest(BaseURL + "/user/load", urlData, callback, URLRequest.Method.POST);
  699. }
  700. public static void DownloadBySerialNumber(string serialNumber, URLRequest.URLRequestJsonCallBackDelegate callback)
  701. {
  702. URLRequestData urlData = new URLRequestData();
  703. urlData.Add("u", serialNumber);
  704. URLRequest.CreateURLRequest(NewBaseURL + "/user/load", urlData, callback, URLRequest.Method.POST);
  705. }
  706. public static void RandomLoad(URLRequest.URLRequestJsonCallBackDelegate callback)
  707. {
  708. URLRequestData urlData = new URLRequestData();
  709. urlData.Add("i", "");
  710. URLRequest.CreateURLRequest(BaseURL + "/user/rand", urlData, callback, URLRequest.Method.POST);
  711. }
  712. public static void Report()
  713. {
  714. ManaReso.Get("Lb_Info").TweenBacCG();
  715. string str = ManaReso.Get<Text>("Lb_InputLab").text;
  716. if (string.IsNullOrEmpty(str))
  717. {
  718. Bubble.Show(null, Language.GetStr("UI", "Lb_Send2"));
  719. }
  720. else if(ReportContent == str)
  721. {
  722. Bubble.Show(null, Language.GetStr("UI", "Lb_Send1"));
  723. }
  724. else
  725. {
  726. MailMessage mailMessage = new MailMessage();
  727. mailMessage.To.Add(new MailAddress("bug@dashgame.com"));
  728. mailMessage.From = new MailAddress("dashgamegarden@163.com");
  729. ReportContent = str;
  730. mailMessage.Body = ReportContent + '\n' + GetSystemInfo();
  731. mailMessage.Subject = ID + " MyLovelyGargen Issue";
  732. SmtpClient smtpClient = new SmtpClient("smtp.163.com");
  733. smtpClient.Credentials = new MyCredentials("dashgamegarden@163.com", "cs670cs");
  734. smtpClient.SendAsync(mailMessage, "Async");
  735. Bubble.Show(null, Language.GetStr("UI", "Lb_Send0"));
  736. }
  737. }
  738. public static string GetSystemInfo()
  739. {
  740. StringBuilder sb = new StringBuilder();
  741. sb.AppendLine("deviceType :" + SystemInfo.deviceType.ToString());
  742. sb.AppendLine("deviceName :" + SystemInfo.deviceName.ToString());
  743. sb.AppendLine("deviceModel :" + SystemInfo.deviceModel.ToString());
  744. sb.AppendLine("deviceUniqueIdentifier :" + SystemInfo.deviceUniqueIdentifier.ToString());
  745. sb.AppendLine("graphicsDeviceID :" + SystemInfo.graphicsDeviceID.ToString());
  746. sb.AppendLine("graphicsDeviceType :" + SystemInfo.graphicsDeviceType.ToString());
  747. sb.AppendLine("graphicsDeviceName :" + SystemInfo.graphicsDeviceName.ToString());
  748. sb.AppendLine("graphicsShaderLevel :" + SystemInfo.graphicsShaderLevel.ToString());
  749. sb.AppendLine("graphicsMemorySize :" + SystemInfo.graphicsMemorySize.ToString());
  750. sb.AppendLine("graphicsDeviceVersion :" + SystemInfo.graphicsDeviceVersion.ToString());
  751. sb.AppendLine("graphicsMultiThreaded :" + SystemInfo.graphicsMultiThreaded.ToString());
  752. sb.AppendLine("graphicsDeviceVendor :" + SystemInfo.graphicsDeviceVendor.ToString());
  753. sb.AppendLine("graphicsDeviceVendorID :" + SystemInfo.graphicsDeviceVendorID.ToString());
  754. sb.AppendLine("npotSupport :" + SystemInfo.npotSupport.ToString());
  755. sb.AppendLine("maxTextureSize :" + SystemInfo.maxTextureSize.ToString());
  756. sb.AppendLine("operatingSystem :" + SystemInfo.operatingSystem.ToString());
  757. sb.AppendLine("operatingSystemFamily :" + SystemInfo.operatingSystemFamily.ToString());
  758. sb.AppendLine("processorType :" + SystemInfo.processorType.ToString());
  759. sb.AppendLine("processorCount :" + SystemInfo.processorCount.ToString());
  760. sb.AppendLine("processorFrequency :" + SystemInfo.processorFrequency.ToString());
  761. sb.AppendLine("copyTextureSupport :" + SystemInfo.copyTextureSupport.ToString());
  762. sb.AppendLine("graphicsMultiThreaded :" + SystemInfo.graphicsMultiThreaded.ToString());
  763. sb.AppendLine("supportedRenderTargetCount :" + SystemInfo.supportedRenderTargetCount.ToString());
  764. sb.AppendLine("supports3DTextures :" + SystemInfo.supports3DTextures.ToString());
  765. sb.AppendLine("supports2DArrayTextures :" + SystemInfo.supports2DArrayTextures.ToString());
  766. sb.AppendLine("supportsAccelerometer :" + SystemInfo.supportsAccelerometer.ToString());
  767. sb.AppendLine("supportsAudio :" + SystemInfo.supportsAudio.ToString());
  768. sb.AppendLine("supportsComputeShaders :" + SystemInfo.supportsComputeShaders.ToString());
  769. sb.AppendLine("supportsCubemapArrayTextures :" + SystemInfo.supportsCubemapArrayTextures.ToString());
  770. sb.AppendLine("supportsGyroscope :" + SystemInfo.supportsGyroscope.ToString());
  771. sb.AppendLine("supportsImageEffects :" + SystemInfo.supportsImageEffects.ToString());
  772. sb.AppendLine("supportsInstancing :" + SystemInfo.supportsInstancing.ToString());
  773. sb.AppendLine("supportsLocationService :" + SystemInfo.supportsLocationService.ToString());
  774. sb.AppendLine("supportsMotionVectors :" + SystemInfo.supportsMotionVectors.ToString());
  775. sb.AppendLine("supportsRawShadowDepthSampling :" + SystemInfo.supportsRawShadowDepthSampling.ToString());
  776. sb.AppendLine("supportsRenderToCubemap :" + SystemInfo.supportsRenderToCubemap.ToString());
  777. sb.AppendLine("supportsShadows :" + SystemInfo.supportsShadows.ToString());
  778. sb.AppendLine("supportsSparseTextures :" + SystemInfo.supportsSparseTextures.ToString());
  779. sb.AppendLine("supportsVibration :" + SystemInfo.supportsVibration.ToString());
  780. sb.AppendLine("systemMemorySize :" + SystemInfo.systemMemorySize.ToString());
  781. sb.AppendLine("usesReversedZBuffer :" + SystemInfo.usesReversedZBuffer.ToString());
  782. return sb.ToString();
  783. }
  784. }