ManaServer.cs 33 KB

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