ManaServer.cs 36 KB

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