ManaServer.cs 36 KB

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