12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121 |
- using LitJson;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityEngine.Events;
- using System;
- using System.IO;
- using System.Net;
- using System.Xml;
- using System.Text;
- using System.Linq;
- using System.Net.Mail;
- using System.Collections;
- using System.Collections.Generic;
- using Random = UnityEngine.Random;
- public class MyCredentials : ICredentialsByHost
- {
- public NetworkCredential NetworkCredential;
- public NetworkCredential GetCredential(string host, int port, string authType)
- {
- return NetworkCredential.GetCredential(new Uri("http://" + host + ":" + port), authType);
- }
- public MyCredentials(string username, string password)
- {
- NetworkCredential = new NetworkCredential(username, password);
- }
- }
- public enum CommentType
- {
- Garden = 0,
- }
- public class ManaServer : Regist
- {
- public class MailReward
- {
- public string Id;
- public string Key;
- public string Value;
- public MailReward(string id, string key, string value)
- {
- Id = id;
- Key = key;
- Value = value;
- }
- }
- #region 变量
- public static bool Connect
- {
- get
- {
- if (Connect_)
- {
- return true;
- }
- else
- {
- if (ManaTutorial.ConnectExemptAmt > 0)
- {
- ManaTutorial.ConnectExemptAmt--;
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- set { Connect_ = value; }
- }
- public static bool PackLock
- {
- get { return PackLock_; }
- set
- {
- PackLock_ = value;
- foreach (var kv in ManaCenter.SkillDic)
- {
- if (kv.Value is Pack)
- {
- ((Pack) kv.Value).SetActive(!PackLock_);
- }
- }
- }
- }
- public static bool Connect_;
- public static bool PackLock_;
- public static int Counter;
- public static int PraiseAmt;
- public static bool RankReady;
- public static List<JsonData> RankDatas;
- public static int NotificationIndex = -1;
- public static bool NotificationReady;
- public static string NotificationStr;
- public static Sprite NotificationSprite;
- public static float Timer;
- public static bool Complete;
- public static bool FirstConnect = true;
- public static string ID = "Default";
- public static string SerialNumber = "Default";
- public static string ReportContent;
- public static JsonData JsonData;
- public static DateTime Time;
- public static string MailXml;
- public static List<MailReward> MailRewardList = new List<MailReward>();
- public static string BaseURL = "https://garden.dashgame.com/index.php/home";
- public static string NewBaseURL = "https://garden.dashgame.com/index.php/newhome";
- #endregion
- public void Awake()
- {
- //URLRequestData urlData = new URLRequestData();
- //urlData.Add("u", "1706142186026389627");
- //urlData.Add("n", "123");
- //URLRequest.CreateStrURLRequest(BaseURL + "/user/nickname", urlData, Debug.Log, URLRequest.Method.POST);
- //urlData = new URLRequestData();
- //urlData.Add("u", "2121212121212121");
- //urlData.Add("n", "123");
- //URLRequest.CreateStrURLRequest(BaseURL + "/user/nickname", urlData, Debug.Log, URLRequest.Method.POST);
- //URLRequestData urlData = new URLRequestData();
- //urlData.Add("i", "");
- //URLRequest.CreateStrURLRequest("https://garden.dashgame.com/index.php/home/user/rand", urlData, Debug.Log, URLRequest.Method.POST);
- //URLRequestData urlData = new URLRequestData();
- //urlData.Add("u", "hsoiv1");
- //URLRequest.CreateStrURLRequest("https://garden.dashgame.com/index.php/home/user/load", urlData, Debug.Log, URLRequest.Method.POST);
- //Login((data => print(data.ToJson())));
- //Download("ytcy9g",(data)=> { print(data.ToJson()); });
- //Other("1704189794672324513", (data) => { print(data.ToJson()); });
- //for (int i = 0; i < 10; i++)
- //{
- // string str = "";
- // for (int j = 0; j < 80; j++)
- // {
- // str += Random.Range(0, 100);
- // }
- // AddComment("1704189794672324513", "1706142186026389627", 1, CommentType.Garden);
- //}
- //GetComment("123", "0", CommentType.Garden);
- //Praise("1704189794672324513", "1704189794672324513");
- //Target("", "1704189794672324513",null);
- }
- public void Update()
- {
- if (!ManaCenter.Complete && !Complete)
- {
- Timer += UnityEngine.Time.deltaTime;
- if (Timer >= 2f)
- {
- Timer = 0;
- Counter++;
- if (Counter > 4)
- {
- Complete = true;
- ManaCenter.LoginCallbackInitial(new JsonData());
- }
- else
- {
- Login(ManaCenter.LoginCallbackInitial);
- IOSAlipayRequest();
- }
- }
- }
- }
- public override bool RegistImmed()
- {
- if (base.RegistImmed())
- {
- return true;
- }
- enabled = true;
- return false;
- }
- public static void SetNickName(string nickname, Action action, Action succeedCallback, Action failCallback)
- {
- URLRequestData urlData = new URLRequestData();
- urlData.Add("u", SerialNumber);
- urlData.Add("n", nickname);
- if (action != null)
- {
- action.Invoke();
- }
- URLRequest.CreateStrURLRequest
- (
- BaseURL + "/user/nickname",
- urlData,
- (data) =>
- {
- if (data == "{\"error\":0}")
- {
- succeedCallback.Invoke();
- }
- else
- {
- failCallback.Invoke();
- }
- },
- URLRequest.Method.POST
- );
- }
- public static void RankRequest()
- {
- URLRequestData urlData = new URLRequestData();
- URLRequest.CreateStrURLRequest
- (
- NewBaseURL + "/user/look",
- urlData,
- data =>
- {
- //Debug.Log(data);
- string str = "{\"l\":" + data.Substring(1) + "}";
- JsonData jsondata;
- try
- {
- jsondata = JsonMapper.ToObject(str);
- }
- catch (Exception)
- {
- jsondata = new JsonData();
- jsondata["error"] = 0;
- }
-
- RankRequestCallback(jsondata);
- //Debug.Log(data[0]);
- //StreamWriter streamWriter = new StreamWriter("Assets/123.txt");
- //streamWriter.Write(data);
- //streamWriter.Close();
- }
- );
- //URLRequest.CreateURLRequest
- //(
- // NewBaseURL + "/user/look",
- // urlData,
- // RankRequestCallback,
- // URLRequest.Method.POST
- //);
- }
- public static void RankRequestCallback(JsonData jsonData)
- {
- if (jsonData.Inst_Object.ContainsKey("l"))
- {
- RankDatas = new List<JsonData>();
- for (int i = 0; i < jsonData["l"].Count; i++)
- {
- RankDatas.Add(jsonData["l"][i]);
- }
- RankReady = true;
- ManaSocial.InitializeRankPanel();
- }
- }
- public static void NotificationRequest()
- {
- //Debug.Log("A");
- IndexRequest
- (
- data =>
- {
- //Debug.Log("B");
- URLRequestData urlData = new URLRequestData();
- URLRequest.CreateStrURLRequest
- (
- data["l"][3]["val"].ToString(),
- urlData,
- notificationXml =>
- {
- //Debug.Log("C");
- NotificationCallback(notificationXml);
- }
- );
- }
- );
- }
- public static void NotificationCallback(string xml)
- {
- //Debug.Log("D");
- XmlNode rootNode;
- XmlDocument document = new XmlDocument();
- try
- {
- document.LoadXml(xml);
- rootNode = document.SelectSingleNode("announce");
- NotificationIndex = int.Parse(rootNode.SelectSingleNode("version").InnerText);
- XmlNodeList nodeList = rootNode.SelectNodes("item");
- List<string> urlList = new List<string>();
- for (int i = 0; i < nodeList.Count; i++)
- {
- DecodeNotificationItem(nodeList[i], urlList);
- }
- Auxiliary.Instance.StartCoroutine(PullNotifyTexs(urlList, PullNotifyTexsCallback));
- }
- catch (Exception)
- {
- }
- finally
- {
-
- }
- }
- public static void DecodeNotificationItem(XmlNode node, List<string> urlList)
- {
- XmlNodeList nodeList = node.SelectNodes("title");
- for (int i = 0; i < nodeList.Count; i++)
- {
- ManaNotify.AddLine(false, nodeList[i].Attributes[0].Value, nodeList[i].InnerText, TextAnchor.MiddleLeft);
- }
- ManaNotify.AddLine(false, "null", node.SelectSingleNode("date").InnerText, TextAnchor.MiddleLeft);
- nodeList = node.SelectSingleNode("content").ChildNodes;
- for (int i = 0; i < nodeList.Count; i++)
- {
- if (nodeList[i].Name == "text")
- {
- ManaNotify.AddLine(false, nodeList[i].Attributes[0].Value, nodeList[i].InnerText, TextAnchor.MiddleLeft);
- }
- else if (nodeList[i].Name == "image")
- {
- urlList.UniqueAdd(nodeList[i].InnerText);
- ManaNotify.AddLine(true, "null", $"<({Path.GetFileNameWithoutExtension(nodeList[i].InnerText)})>", TextAnchor.MiddleCenter);
- }
- }
- ManaNotify.AddLine(false, "null", "", TextAnchor.MiddleLeft);
- }
- public static void PullNotifyTexsCallback(List<WWW> wwwList)
- {
- List<Texture2D> textureList = new List<Texture2D>();
- List<SpriteInfo> spriteInfoList = new List<SpriteInfo>();
- for (int i = 0; i < wwwList.Count; i++)
- {
- textureList.Add(wwwList[i].texture);
- SpriteInfo spriteInfo = new SpriteInfo();
- spriteInfo.Name = Path.GetFileNameWithoutExtension(wwwList[i].url);
- spriteInfoList.Add(spriteInfo);
- }
- Texture2D atlas = new Texture2D(2048, 2048);
- Rect[] rects = atlas.PackTextures(textureList.ToArray(), 1);
- Sprite sprite = Sprite.Create(atlas, new Rect(0, 0, atlas.width, atlas.height), new Vector2(0.5f, 0.5f));
- for (int i = 0; i < spriteInfoList.Count; i++)
- {
- spriteInfoList[i].Width = textureList[i].width;
- spriteInfoList[i].Height = textureList[i].height;
- spriteInfoList[i].UvList = new List<Vector2>()
- {
- new Vector2(rects[i].xMin, rects[i].yMax),
- new Vector2(rects[i].xMax, rects[i].yMax),
- new Vector2(rects[i].xMax, rects[i].yMin),
- new Vector2(rects[i].xMin, rects[i].yMin),
- };
- SpriteAsset.SpriteInfoDic.Add(spriteInfoList[i].Name, spriteInfoList[i]);
- }
- NotificationSprite = sprite;
- NotificationReady = true;
- if (Initializer.Complete)
- {
- ManaReso.Get("C_Notify").TweenForCG();
- }
- //Debug.Log("Done");
- }
- public static IEnumerator PullNotifyTexs(List<string> urlList, Action<List<WWW>> callback)
- {
- List<WWW> wwwList = new List<WWW>();
- for (int i = 0; i < urlList.Count; i++)
- {
- wwwList.Add(new WWW(urlList[i]));
- }
-
- for (int i = 0; i < wwwList.Count; i++)
- {
- yield return wwwList[i];
- }
- callback(wwwList);
- }
- public static void Praise(string sendID, string receiveID)
- {
- if (receiveID == null)
- {
- return;
- }
- URLRequestData urlData = new URLRequestData();
- urlData.Add("u", sendID);
- urlData.Add("t", receiveID);
- URLRequest.CreateStrURLRequest(BaseURL + "/praise/click", urlData, (data)=> {}, URLRequest.Method.POST);
- }
- public static void Target(string userID, string targetID, Action<JsonData> callback)
- {
- URLRequestData urlData = new URLRequestData();
- urlData.Add("u", userID);
- urlData.Add("t", targetID);
- URLRequest.CreateURLRequest(BaseURL + "/praise/target", urlData, data => callback(data), URLRequest.Method.POST);
- }
- public static void AddComment(string sendID, string receiveID, string content, CommentType type)
- {
- URLRequestData urlData = new URLRequestData();
- urlData.Add("c", sendID);
- urlData.Add("u", receiveID);
- urlData.Add("i", content);
- urlData.Add("t", type.GetHashCode());
- URLRequest.CreateStrURLRequest
- (
- BaseURL + "/comment/comment",
- urlData,
- data =>
- {
- if (data == "{\"error\":0}")
- {
- Bubble.Show(Language.GetStr("UI", "Q_CommentDone"));
- ManaSocial.UpdatePage(false);
- }
- else
- {
- Bubble.Show(Language.GetStr("UI", "Q_CommentFail"));
- }
- },
- URLRequest.Method.POST
- );
- }
- public static void GetComment(string id, string page, CommentType type, Action<JsonData> callback)
- {
- if (string.IsNullOrEmpty(id))
- {
- return;
- }
- URLRequestData urlData = new URLRequestData();
- urlData.Add("u", id);
- urlData.Add("p", page);
- urlData.Add("t", type.GetHashCode());
- URLRequest.CreateURLRequest(BaseURL + "/comment/index", urlData, data => callback(data), URLRequest.Method.POST);
- }
- public static void IndexRequest(Action<JsonData> callback)
- {
- URLRequestData urlData = new URLRequestData();
- URLRequest.CreateURLRequest
- (
- BaseURL + "/index/index",
- urlData,
- data =>
- {
- if (data.Inst_Object.ContainsKey("error"))
- {
- if (ManaData.PlayerDoc_ != null)
- {
- if (Application.platform == RuntimePlatform.Android)
- {
- PackLock = true;
- }
- else if (Application.platform == RuntimePlatform.IPhonePlayer)
- {
- PackLock = ManaData.GetPlayerBool("PackLock");
- }
- }
- }
- else
- {
- callback(data);
- }
- }
- );
- }
- public static void MailRequest()
- {
- //MailXml = "<mail>" +
- // "<OneTimeReward>" +
- // "<id>4</id>" +
- // "<start>2017-08-18 12:12:12</start>" +
- // "<end>2017-09-1 11:30:12</end>" +
- // "<reward>" +
- // "<coin>1000</coin>" +
- // "<diamond>10</diamond>" +
- // "</reward>" +
- // "<targets>" +
- // "<id>90arbl</id>" +
- // "</targets>" +
- // "</OneTimeReward>" +
- // "<OneTimeReward>" +
- // "<id>3</id>" +
- // "<start>2017-08-21 12:12:12</start>" +
- // "<end>2017-09-01 18:12:12</end>" +
- // "<reward>" +
- // "<coin>10000</coin>" +
- // "<diamond>100</diamond>" +
- // "</reward>" +
- // "<targets>" +
- // "<id>90arbl</id>" +
- // "</targets>" +
- // "</OneTimeReward>" +
- // "</mail>";
- IndexRequest
- (
- data =>
- {
- URLRequestData urlData = new URLRequestData();
- URLRequest.CreateStrURLRequest
- (
- data["l"][1]["val"].ToJson().Trim('"'),
- urlData,
- mailXml =>
- {
- MailXml = mailXml;
- }
- );
- }
- );
- }
- public static void GetMailReward()
- {
- for (int i = 0; i < MailRewardList.Count; i++)
- {
- GetMailReward(MailRewardList[i]);
- }
- }
- public static void GetMailReward(MailReward mailReward)
- {
- //Debug.Log(mailReward.Id);
- ManaData.SavePlayerString("OneTimeReward", $"{ManaData.GetPlayerString("OneTimeReward")} {mailReward.Id}".Trim(' '));
- if (mailReward.Key == "pack")
- {
- SkillRoot skillRoot;
- if (ManaCenter.SkillDic.TryGetValue($"Pack{mailReward.Value}", out skillRoot))
- {
- Pack pack = (Pack) skillRoot;
- pack.PurchaseResult();
- Transform mailItem = ManaReso.Get("MailItem", Folder.UI, false, ManaReso.Get("Bd_Grid"), new Vector3(), ObjType.MailItem);
- float newSpriteSize = 0.35f;
- mailItem.GetChild(1).SetActive(false);
- mailItem.GetChild(0).GetComponent<Image>().sprite = pack.Icon;
- mailItem.GetChild(0).GetComponent<Image>().Resize(true, newSpriteSize, newSpriteSize);
- mailItem.GetChild(0).transform.localPosition = new Vector2(0, 0);
- mailItem.GetChild(2).GetComponent<Text>().text = pack.Name;
- ManaInfo.Show($"{Language.GetStr("Common", "Get")} <(礼包)>{pack.Name}", 10);
- }
- else
- {
- Debug.LogWarning($"Unknown id {mailReward.Value}");
- }
- }
- else if (mailReward.Key == "close")
- {
- List<int> idList = Auxiliary.IntListParse(' ', mailReward.Value, new List<int>());
- CloseUnit closeUnit;
- for (int i = 0; i < idList.Count; i++)
- {
- if (ManaPlayer.CloseUnitDic.TryGetValue(idList[i], out closeUnit))
- {
- if (closeUnit.Bought == false)
- {
- closeUnit.Unlock();
- ManaPlayer.BoughtCloseList.UniqueAdd(idList[i]);
- }
- Transform mailItem = ManaReso.Get("MailItem", Folder.UI, false, ManaReso.Get("Bd_Grid"), new Vector3(), ObjType.MailItem);
- float newSize = 0.6f;
- float newSpriteSize = closeUnit.PixelSize*newSize/closeUnit.Sprites[0].rect.width;
- mailItem.GetChild(1).GetComponent<Image>().sprite = closeUnit.Sprites[0];
- mailItem.GetChild(1).GetComponent<Image>().Resize(true, newSpriteSize, newSpriteSize);
- mailItem.GetChild(1).transform.localPosition = new Vector2(0, closeUnit.IconOffset*newSize);
- if (closeUnit.Sprites.Length > 1)
- {
- mailItem.GetChild(0).SetActive(true);
- mailItem.GetChild(0).GetComponent<Image>().sprite = closeUnit.Sprites[1];
- mailItem.GetChild(0).GetComponent<Image>().Resize(true, newSpriteSize, newSpriteSize);
- mailItem.GetChild(0).transform.localPosition = closeUnit.IconOffset1*newSpriteSize + new Vector2(0, closeUnit.IconOffset*newSize);
- }
- else
- {
- mailItem.GetChild(0).SetActive(false);
- }
- mailItem.GetChild(2).GetComponent<Text>().text = closeUnit.Name;
- ManaInfo.Show($"{Language.GetStr("Common", "Get")} <(服装)>{closeUnit.Name}", 10);
- }
- else
- {
- Debug.LogWarning($"Unknown id {idList[i]}");
- }
- }
- }
- else if (mailReward.Key == "flower")
- {
- List<int> idList = Auxiliary.IntListParse(' ', mailReward.Value, new List<int>());
- FlowerInfo flowerInfo;
- for (int i = 0; i < idList.Count; i++)
- {
- if (ManaGarden.FlowerInfoDic.TryGetValue(idList[i], out flowerInfo))
- {
- if (flowerInfo.Unlock == false)
- {
- flowerInfo.Unlock = true;
- }
- Transform mailItem = ManaReso.Get("MailItem", Folder.UI, false, ManaReso.Get("Bd_Grid"), new Vector3(), ObjType.MailItem);
- float newSpriteSize = 0.225f;
- mailItem.GetChild(1).SetActive(false);
- mailItem.GetChild(0).GetComponent<Image>().sprite = flowerInfo.Icon;
- mailItem.GetChild(0).GetComponent<Image>().Resize(true, newSpriteSize, newSpriteSize);
- mailItem.GetChild(0).transform.localPosition = new Vector2(0, 0);
- mailItem.GetChild(2).GetComponent<Text>().text = flowerInfo.Name;
- ManaInfo.Show($"{Language.GetStr("Common", "Get")} <(花朵)>{flowerInfo.Name}", 10);
- }
- else
- {
- Debug.LogWarning($"Unknown id {idList[i]}");
- }
- }
- }
- else if (mailReward.Key == "coin")
- {
- ManaCenter.AddCoin(double.Parse(mailReward.Value), StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.Mail);
- Transform mailItem = ManaReso.Get("MailItem", Folder.UI, false, ManaReso.Get("Bd_Grid"), new Vector3(), ObjType.MailItem);
- float newSpriteSize = 0.75f;
- mailItem.GetChild(1).SetActive(false);
- mailItem.GetChild(0).GetComponent<Image>().sprite = ManaReso.LoadSprite("金币", Folder.UI);
- mailItem.GetChild(0).GetComponent<Image>().Resize(true, newSpriteSize, newSpriteSize);
- mailItem.GetChild(0).transform.localPosition = new Vector2(0, 0);
- mailItem.GetChild(2).GetComponent<Text>().text = Auxiliary.ShrinkNumberStr(double.Parse(mailReward.Value));
- ManaInfo.Show($"{Language.GetStr("Common", "Get")} <(金币)>{Auxiliary.ShrinkNumberStr(double.Parse(mailReward.Value))}", 10);
- }
- else if (mailReward.Key == "diamond")
- {
- ManaCenter.AddDiamond(double.Parse(mailReward.Value), StaticsManager.ItemID.获得钻石, StaticsManager.ConsumeModule.Mail);
- Transform mailItem = ManaReso.Get("MailItem", Folder.UI, false, ManaReso.Get("Bd_Grid"), new Vector3(), ObjType.MailItem);
- float newSpriteSize = 0.75f;
- mailItem.GetChild(1).SetActive(false);
- mailItem.GetChild(0).GetComponent<Image>().sprite = ManaReso.LoadSprite("钻石", Folder.UI);
- mailItem.GetChild(0).GetComponent<Image>().Resize(true, newSpriteSize, newSpriteSize);
- mailItem.GetChild(0).transform.localPosition = new Vector2(0, 0);
- mailItem.GetChild(2).GetComponent<Text>().text = Auxiliary.ShrinkNumberStr(double.Parse(mailReward.Value));
- ManaInfo.Show($"{Language.GetStr("Common", "Get")} <(钻石)>{Auxiliary.ShrinkNumberStr(double.Parse(mailReward.Value))}", 10);
- }
- else
- {
- Debug.Log(mailReward.Key);
- }
- }
- public static void DecodeMailXml(string mailXml)
- {
- MailRewardList = new List<MailReward>();
- XmlDocument xmlDoc = new XmlDocument();
- //Debug.Log("Decode");
- try
- {
- xmlDoc.LoadXml(mailXml);
- }
- catch (Exception)
- {
- return;
- }
- XmlNodeList rewardNodeList = xmlDoc.SelectSingleNode("mail").SelectNodes("OneTimeReward");
- //Debug.Log(ManaData.GetPlayerString("OneTimeReward"));
- List<string> receivedIdList = Auxiliary.StringListParse(' ', ManaData.GetPlayerString("OneTimeReward"), new List<string>());
- //Debug.Log("");
- //foreach (var id in receivedIdList)
- //{
- // Debug.Log(id);
- //}
- //Debug.Log("");
- for (int i = 0; i < rewardNodeList.Count; i++)
- {
- string id = rewardNodeList[i].SelectSingleNode("id").InnerText;
- //Debug.Log(id);
- if (receivedIdList.Contains(id))
- {
- continue;
- }
- DateTime startTime = DateTime.Parse(rewardNodeList[i].SelectSingleNode("start").InnerText);
- DateTime endTime = DateTime.Parse(rewardNodeList[i].SelectSingleNode("end").InnerText);
- if (Time < startTime || Time > endTime)
- {
- //Debug.Log("Skip");
- continue;
- }
- XmlNodeList targetIdNodeList = rewardNodeList[i].SelectSingleNode("targets").SelectNodes("id");
- for (int j = 0; j < targetIdNodeList.Count; j++)
- {
- if (targetIdNodeList[j].InnerText == ID)
- {
- XmlNodeList xmlNodeList = rewardNodeList[i].SelectSingleNode("reward").ChildNodes;
- for (int k = 0; k < xmlNodeList.Count; k++)
- {
- MailRewardList.Add(new MailReward(id, xmlNodeList[k].Name, xmlNodeList[k].InnerText));
- }
- break;
- }
- }
- }
- }
- public static void PackTypeRequest()
- {
- IndexRequest
- (
- data =>
- {
- PackLock = Auxiliary.BoolParse(data["l"][0]["val"].ToJson().Trim('"'), true);
- if (Application.platform == RuntimePlatform.Android)
- {
- PackLock = true;
- }
- if (ManaData.PlayerDoc_ != null)
- {
- ManaData.SavePlayerBool("PackLock", PackLock);
- }
- }
- );
- }
- public static void IOSAlipayRequest()
- {
- IndexRequest
- (
- data =>
- {
- ManaIAP.UseAlipayOnIOS = Auxiliary.BoolParse(data["l"][2]["val"].ToJson().Trim('"'), false);
- }
- );
- }
- public static void GetProductID(string id, URLRequest.URLRequestCallBackDelegate callback)
- {
- URLRequestData urlData = new URLRequestData();
- urlData.Add("t", 1);
- urlData.Add("i", id);
- urlData.Add("u", JsonData.Inst_Object["i"].ToJson().Trim('"'));
- URLRequest.CreateStrURLRequest(BaseURL + "/pay/pay", urlData, callback, URLRequest.Method.POST);
- }
- public static void Login(URLRequest.URLRequestJsonCallBackDelegate callback = null)
- {
- URLRequestData urlData = new URLRequestData();
- urlData.Add("u", SystemInfo.deviceUniqueIdentifier);
- URLRequest.CreateURLRequest(NewBaseURL + "/user/login", urlData, LoginCallback + callback, URLRequest.Method.POST);
- }
- private static void LoginCallback(JsonData jsonData)
- {
- Complete = true;
-
- if (jsonData.Inst_Object.ContainsKey("c"))
- {
- Connect = true;
- JsonData = jsonData;
- Time = DateUtil.GetTime(jsonData["time"].ToJson());
- PraiseAmt = int.Parse(jsonData["p"].ToJson().Trim('"'));
- if (ManaData.DamageLock)
- {
- ID = jsonData["o"].ToString();
- SerialNumber = jsonData["i"].ToString();
- }
- else if (ManaData.PlayerDoc_ != null)
- {
- if (ManaData.GetPlayerString("ID") == "Default")
- {
- ID = jsonData["o"].ToString();
- SerialNumber = jsonData["i"].ToString();
- if (Initializer.Complete)
- {
- ManaReso.SetText("L_UserLab", ID);
- }
- }
- }
- if (FirstConnect)
- {
- FirstConnect = false;
- StaticsManager.GetInstance().ActOrReg(ID, DataEyeGA.AccountType.Official);
- }
- ManaDebug.Log("<color=red>连接成功</color>");
- }
- else
- {
- Connect = false;
- ManaDebug.Log("<color=red>连接失败</color>");
- }
- }
- public static void Save()
- {
- ManaCenter.SaveTimer = 0;
- URLRequestData urlData = new URLRequestData();
-
- urlData.Add("u", SerialNumber);
- ManaData.SavePlayerConfig();
- urlData.Add("l", ManaData.PlayerDoc.OuterXml);
- URLRequest.CreateURLRequest(NewBaseURL + "/user/save", urlData, SaveCallback, URLRequest.Method.POST);
- //URLRequest.CreateStrURLRequest(NewBaseURL + "/user/save", urlData, Debug.Log, URLRequest.Method.POST);
- }
- private static void SaveCallback(JsonData jsonData)
- {
- ManaDebug.Log("<color=red>发送存档成功</color>");
- }
- public static void Other(string id, URLRequest.URLRequestJsonCallBackDelegate callback)
- {
- URLRequestData urlData = new URLRequestData();
- urlData.Add("u", id);
- URLRequest.CreateURLRequest(BaseURL + "/user/other", urlData, callback, URLRequest.Method.POST);
- }
- public static void DownloadByID(string id, URLRequest.URLRequestJsonCallBackDelegate callback)
- {
- URLRequestData urlData = new URLRequestData();
- urlData.Add("u", id);
- URLRequest.CreateURLRequest(BaseURL + "/user/load", urlData, callback, URLRequest.Method.POST);
- }
- public static void DownloadBySerialNumber(string serialNumber, URLRequest.URLRequestJsonCallBackDelegate callback)
- {
- URLRequestData urlData = new URLRequestData();
- urlData.Add("u", serialNumber);
- URLRequest.CreateURLRequest(NewBaseURL + "/user/load", urlData, callback, URLRequest.Method.POST);
- }
- public static void RandomLoad(URLRequest.URLRequestJsonCallBackDelegate callback)
- {
- URLRequestData urlData = new URLRequestData();
- urlData.Add("i", "");
- URLRequest.CreateURLRequest(BaseURL + "/user/rand", urlData, callback, URLRequest.Method.POST);
- }
- public static void Report()
- {
- ManaReso.Get("Lb_Info").TweenBacCG();
- string str = ManaReso.Get<Text>("Lb_InputLab").text;
- if (string.IsNullOrEmpty(str))
- {
- Bubble.Show(null, Language.GetStr("UI", "Lb_Send2"));
- }
- else if(ReportContent == str)
- {
- Bubble.Show(null, Language.GetStr("UI", "Lb_Send1"));
- }
- else
- {
- MailMessage mailMessage = new MailMessage();
- mailMessage.To.Add(new MailAddress("bug@dashgame.com"));
- mailMessage.From = new MailAddress("dashgamegarden@163.com");
- ReportContent = str;
- mailMessage.Body = ReportContent + '\n' + GetSystemInfo();
- mailMessage.Subject = ID + " MyLovelyGargen Issue";
- SmtpClient smtpClient = new SmtpClient("smtp.163.com");
-
- smtpClient.Credentials = new MyCredentials("dashgamegarden@163.com", "cs670cs");
- smtpClient.SendAsync(mailMessage, "Async");
- Bubble.Show(null, Language.GetStr("UI", "Lb_Send0"));
- }
- }
- public static string GetSystemInfo()
- {
- StringBuilder sb = new StringBuilder();
- sb.AppendLine("deviceType :" + SystemInfo.deviceType.ToString());
- sb.AppendLine("deviceName :" + SystemInfo.deviceName.ToString());
- sb.AppendLine("deviceModel :" + SystemInfo.deviceModel.ToString());
- sb.AppendLine("deviceUniqueIdentifier :" + SystemInfo.deviceUniqueIdentifier.ToString());
- sb.AppendLine("graphicsDeviceID :" + SystemInfo.graphicsDeviceID.ToString());
- sb.AppendLine("graphicsDeviceType :" + SystemInfo.graphicsDeviceType.ToString());
- sb.AppendLine("graphicsDeviceName :" + SystemInfo.graphicsDeviceName.ToString());
- sb.AppendLine("graphicsShaderLevel :" + SystemInfo.graphicsShaderLevel.ToString());
- sb.AppendLine("graphicsMemorySize :" + SystemInfo.graphicsMemorySize.ToString());
- sb.AppendLine("graphicsDeviceVersion :" + SystemInfo.graphicsDeviceVersion.ToString());
- sb.AppendLine("graphicsMultiThreaded :" + SystemInfo.graphicsMultiThreaded.ToString());
- sb.AppendLine("graphicsDeviceVendor :" + SystemInfo.graphicsDeviceVendor.ToString());
- sb.AppendLine("graphicsDeviceVendorID :" + SystemInfo.graphicsDeviceVendorID.ToString());
- sb.AppendLine("npotSupport :" + SystemInfo.npotSupport.ToString());
- sb.AppendLine("maxTextureSize :" + SystemInfo.maxTextureSize.ToString());
- sb.AppendLine("operatingSystem :" + SystemInfo.operatingSystem.ToString());
- sb.AppendLine("operatingSystemFamily :" + SystemInfo.operatingSystemFamily.ToString());
- sb.AppendLine("processorType :" + SystemInfo.processorType.ToString());
- sb.AppendLine("processorCount :" + SystemInfo.processorCount.ToString());
- sb.AppendLine("processorFrequency :" + SystemInfo.processorFrequency.ToString());
- sb.AppendLine("copyTextureSupport :" + SystemInfo.copyTextureSupport.ToString());
- sb.AppendLine("graphicsMultiThreaded :" + SystemInfo.graphicsMultiThreaded.ToString());
- sb.AppendLine("supportedRenderTargetCount :" + SystemInfo.supportedRenderTargetCount.ToString());
- sb.AppendLine("supports3DTextures :" + SystemInfo.supports3DTextures.ToString());
- sb.AppendLine("supports2DArrayTextures :" + SystemInfo.supports2DArrayTextures.ToString());
- sb.AppendLine("supportsAccelerometer :" + SystemInfo.supportsAccelerometer.ToString());
- sb.AppendLine("supportsAudio :" + SystemInfo.supportsAudio.ToString());
- sb.AppendLine("supportsComputeShaders :" + SystemInfo.supportsComputeShaders.ToString());
- sb.AppendLine("supportsCubemapArrayTextures :" + SystemInfo.supportsCubemapArrayTextures.ToString());
- sb.AppendLine("supportsGyroscope :" + SystemInfo.supportsGyroscope.ToString());
- sb.AppendLine("supportsImageEffects :" + SystemInfo.supportsImageEffects.ToString());
- sb.AppendLine("supportsInstancing :" + SystemInfo.supportsInstancing.ToString());
- sb.AppendLine("supportsLocationService :" + SystemInfo.supportsLocationService.ToString());
- sb.AppendLine("supportsMotionVectors :" + SystemInfo.supportsMotionVectors.ToString());
- sb.AppendLine("supportsRawShadowDepthSampling :" + SystemInfo.supportsRawShadowDepthSampling.ToString());
- sb.AppendLine("supportsRenderToCubemap :" + SystemInfo.supportsRenderToCubemap.ToString());
- sb.AppendLine("supportsShadows :" + SystemInfo.supportsShadows.ToString());
- sb.AppendLine("supportsSparseTextures :" + SystemInfo.supportsSparseTextures.ToString());
- sb.AppendLine("supportsVibration :" + SystemInfo.supportsVibration.ToString());
- sb.AppendLine("systemMemorySize :" + SystemInfo.systemMemorySize.ToString());
- sb.AppendLine("usesReversedZBuffer :" + SystemInfo.usesReversedZBuffer.ToString());
- return sb.ToString();
- }
- }
|