123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200 |
- 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 HttpManager : 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 Config
- public static bool Connect
- {
- get
- {
- if (Connect_)
- {
- return true;
- }
- else
- {
- return TutorialManager.ConnectExempt;
- }
- }
- set { Connect_ = value; }
- }
- public static bool PackLock
- {
- get { return PackLock_; }
- set
- {
- PackLock_ = value;
- foreach (var kv in Manager.SkillDic)
- {
- if (kv.Value is Pack)
- {
- ((Pack) kv.Value).SetActive();
- }
- }
- }
- }
- 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 int ReplayVersion;
- public static string ID = "Default";
- public static string SerialNumber = "Default";
- public static string ReportContent;
- public static JsonData JsonData;
- public static DateTime Time = DateTime.Now;
- 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";
- public static string NicknameURL = NewBaseURL + "/user/nickname";
- public static string RankURL = NewBaseURL + "/user/look";
- public static string PraiseURL= NewBaseURL + "/praise/click";
- public static string TargetURL= NewBaseURL + "/praise/target";
- public static string AddCommentURL= NewBaseURL + "/comment/comment";
- public static string GetCommentURL= NewBaseURL + "/comment/index";
- public static string IndexURL= NewBaseURL + "/index/index";
- public static string GetProductIDURL= NewBaseURL + "/pay/pay";
- public static string LoginURL= NewBaseURL + "/user/login";
- public static string SaveURL= NewBaseURL + "/user/save";
- public static string OtherURL= NewBaseURL + "/user/other";
- public static string DownloadURL= NewBaseURL + "/user/load";
- public static string RandomURL= NewBaseURL + "/user/rand";
- public static string ThanksGiftInfoURL= NewBaseURL + "/index/gift";
- public static string ReportMailAddress= "bug@dashgame.com";
- #endregion
- public void Awake()
- {
- //URLRequestData urlData = new URLRequestData();
- //urlData.Add("u", "1710065808151506837");
- //urlData.Add("t", "1710066204207012789");
- //URLRequest.CreateStrURLRequest(true, NewBaseURL + "/praise/target", urlData, Debug.Log, URLRequest.Method.POST);
- //URLRequestData urlData = new URLRequestData();
- //urlData.Add("u", "1709207727231988804");
- //URLRequest.CreateStrURLRequest(true, NewBaseURL + "/user/other", urlData, Debug.Log, URLRequest.Method.POST);
- }
- public void Update()
- {
- if (!Manager.Complete && !Complete)
- {
- Timer += UnityEngine.Time.deltaTime;
- if (Timer >= 2f)
- {
- Timer = 0;
- Counter++;
- if (Counter > 4)
- {
- Complete = true;
- Manager.LoginCallbackInitial(new JsonData());
- }
- else
- {
- Login(Manager.LoginCallbackInitial);
- IOSAlipayRequest();
- }
- }
- }
- }
- public override bool InitAtOnce()
- {
- if (base.InitAtOnce())
- {
- return true;
- }
- enabled = true;
- return false;
- }
- public override void FirstInit()
- {
- ReplayVersion = ConfigManager.GetPlayerInt(PlayerConfigLabel.ReplayVersion);
- }
- public static void SetNickName(string nickname, Action succeedCallback, Action<string> failCallback)
- {
- URLRequestData urlData = new URLRequestData();
- urlData.Add("u", SerialNumber);
- urlData.Add("n", nickname);
- URLRequest.CreateStrURLRequest
- (
- true,
- NicknameURL,
- urlData,
- data =>
- {
- if (data == " {\"error\":0}")
- {
- succeedCallback.Invoke();
- }
- else if (data.Contains("Could not resolve host"))
- {
- failCallback.Invoke(Language.GetStr(LanguageLabel.UI__Fg_Lab3));
- }
- else
- {
- failCallback.Invoke(Language.GetStr(LanguageLabel.UI__T_RepeatName));
- }
- },
- URLRequest.Method.POST
- );
- }
- public static void RankRequest()
- {
- URLRequestData urlData = new URLRequestData();
- URLRequest.CreateStrURLRequest
- (
- false,
- RankURL,
- 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;
- SocialManager.InitializeRankPanel();
- }
- }
- public static void NotificationRequest()
- {
- //Debug.Log("A");
- IndexRequest
- (
- data =>
- {
- //Debug.Log("B");
- URLRequestData urlData = new URLRequestData();
- URLRequest.CreateStrURLRequest
- (
- true,
- 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(PlayerConfigLabel.Version).InnerText);
- XmlNodeList nodeList = rootNode.SelectNodes(ConfigLabel.ChildNode);
- 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++)
- {
- AnnounceManager.AddLine(false, nodeList[i].Attributes[0].Value, nodeList[i].InnerText, TextAnchor.MiddleLeft);
- }
- AnnounceManager.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")
- {
- AnnounceManager.AddLine(false, nodeList[i].Attributes[0].Value, nodeList[i].InnerText, TextAnchor.MiddleLeft);
- }
- else if (nodeList[i].Name == "image")
- {
- urlList.UniqueAdd(nodeList[i].InnerText);
- AnnounceManager.AddLine(true, "null", $"<({Path.GetFileNameWithoutExtension(nodeList[i].InnerText)})>", TextAnchor.MiddleCenter);
- }
- }
- AnnounceManager.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)
- {
- ResourceManager.Get(ObjectLabel.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(true, PraiseURL, 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(true, TargetURL, urlData, data => callback(data), URLRequest.Method.POST);
- }
- public static void AddComment(string sendID, string receiveID, string content, CommentType type)
- {
- if (string.IsNullOrEmpty(sendID) || string.IsNullOrEmpty(receiveID))
- {
- return;
- }
- if (sendID.ToLower() == "default" || receiveID.ToLower() == "default")
- {
- return;
- }
- URLRequestData urlData = new URLRequestData();
- urlData.Add("c", sendID);
- urlData.Add("u", receiveID);
- urlData.Add("i", content);
- urlData.Add("t", type.GetHashCode());
- //Debug.LogWarning(sendID);
- //Debug.LogWarning(receiveID);
- //Debug.LogWarning(content);
- //Debug.LogWarning(type.GetHashCode());
- URLRequest.CreateStrURLRequest
- (
- true,
- AddCommentURL,
- urlData,
- data =>
- {
- if (data == "{\"error\":0}")
- {
- Bubble.Show(Language.GetStr(LanguageLabel.UI__Q_CommentDone));
- SocialManager.UpdatePage(false);
- }
- else
- {
- Bubble.Show(Language.GetStr(LanguageLabel.UI__Q_CommentFail));
- }
- },
- URLRequest.Method.POST
- );
- }
- public static void GetComment(string id, string page, CommentType type, Action<JsonData> callback)
- {
- JsonData defaultData = new JsonData();
- defaultData["error"] = 0;
- if (string.IsNullOrEmpty(id))
- {
- callback.Invoke(defaultData);
- return;
- }
- if (id.ToLower() == "default")
- {
- callback.Invoke(defaultData);
- return;
- }
- URLRequestData urlData = new URLRequestData();
- //Debug.LogWarning(id);
- //Debug.LogWarning(page);
- //Debug.LogWarning(type.GetHashCode());
- urlData.Add("u", id);
- urlData.Add("p", page);
- urlData.Add("t", type.GetHashCode());
- URLRequest.CreateURLRequest(true, GetCommentURL, urlData, data => { callback(data);}, URLRequest.Method.POST);
- }
- public static void IndexRequest(Action<JsonData> callback)
- {
- URLRequestData urlData = new URLRequestData();
- URLRequest.CreateURLRequest
- (
- true,
- IndexURL,
- urlData,
- data =>
- {
- if (data.Inst_Object.ContainsKey("error"))
- {
- if (ConfigManager.PlayerDoc_ != null)
- {
- if (Application.platform == RuntimePlatform.Android)
- {
- PackLock = true;
- }
- else if (Application.platform == RuntimePlatform.IPhonePlayer)
- {
- PackLock = ConfigManager.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
- (
- true,
- 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);
- ConfigManager.SavePlayerString("OneTimeReward", $"{ConfigManager.GetPlayerString("OneTimeReward")} {mailReward.Id}".Trim(' '));
- if (mailReward.Key == "pack")
- {
- SkillRoot skillRoot;
- if (Manager.SkillDic.TryGetValue($"Pack{mailReward.Value}", out skillRoot))
- {
- Pack pack = (Pack) skillRoot;
- pack.OnBuySucceed();
- Transform mailItem = ResourceManager.Get("MailItem", Folder.UI, false, ResourceManager.Get(ObjectLabel.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;
- InfoBoxManager.GardenInfoBox.Show($"{Language.GetStr(LanguageLabel.Common__Get)} {TransferLabel.PackSprite}{pack.Name}", 10, Color.white, ResourceManager.LoadSprite("Atlas", Folder.Atlas));
- }
- else
- {
- Debug.LogWarning($"Unknown id {mailReward.Value}");
- }
- }
- else if (mailReward.Key == "close")
- {
- List<int> idList = Auxiliary.StringToInts(' ', mailReward.Value, new List<int>());
- CloseItem closeItem;
- for (int i = 0; i < idList.Count; i++)
- {
- if (PlayerManager.CloseItemDic.TryGetValue(idList[i], out closeItem))
- {
- if (closeItem.Possess == false)
- {
- closeItem.Unlock();
- PlayerManager.BoughtCloseList.UniqueAdd(idList[i]);
- }
- Transform mailItem = ResourceManager.Get("MailItem", Folder.UI, false, ResourceManager.Get(ObjectLabel.Bd_Grid), new Vector3(), ObjType.MailItem);
- float newSize = 0.6f;
- float newSpriteSize = closeItem.PixelSize*newSize/closeItem.Sprites[0].rect.width;
- mailItem.GetChild(1).GetComponent<Image>().sprite = closeItem.Sprites[0];
- mailItem.GetChild(1).GetComponent<Image>().Resize(true, newSpriteSize, newSpriteSize);
- mailItem.GetChild(1).transform.localPosition = new Vector2(0, closeItem.IconOffset*newSize);
- if (closeItem.Sprites.Length > 1)
- {
- mailItem.GetChild(0).SetActive(true);
- mailItem.GetChild(0).GetComponent<Image>().sprite = closeItem.Sprites[1];
- mailItem.GetChild(0).GetComponent<Image>().Resize(true, newSpriteSize, newSpriteSize);
- mailItem.GetChild(0).transform.localPosition = closeItem.IconOffset1*newSpriteSize + new Vector2(0, closeItem.IconOffset*newSize);
- }
- else
- {
- mailItem.GetChild(0).SetActive(false);
- }
- mailItem.GetChild(2).GetComponent<Text>().text = closeItem.Name;
- InfoBoxManager.GardenInfoBox.Show($"{Language.GetStr(LanguageLabel.Common__Get)} {TransferLabel.CloseSprite}{closeItem.Name}", 10, Color.white, ResourceManager.LoadSprite("Atlas", Folder.Atlas));
- }
- else
- {
- Debug.LogWarning($"Unknown id {idList[i]}");
- }
- }
- }
- else if (mailReward.Key == "flower")
- {
- List<int> idList = Auxiliary.StringToInts(' ', mailReward.Value, new List<int>());
- FlowerInfo flowerInfo;
- for (int i = 0; i < idList.Count; i++)
- {
- if (GardenManager.FlowerInfoDic.TryGetValue(idList[i], out flowerInfo))
- {
- flowerInfo.Add();
- Transform mailItem = ResourceManager.Get("MailItem", Folder.UI, false, ResourceManager.Get(ObjectLabel.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;
- InfoBoxManager.GardenInfoBox.Show($"{Language.GetStr(LanguageLabel.Common__Get)} {TransferLabel.FlowerSprite}{flowerInfo.Name}", 10, Color.white, ResourceManager.LoadSprite("Atlas", Folder.Atlas));
- }
- else
- {
- Debug.LogWarning($"Unknown id {idList[i]}");
- }
- }
- }
- else if (mailReward.Key == "coin")
- {
- Manager.AddCoin(double.Parse(mailReward.Value), StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.Mail);
- Transform mailItem = ResourceManager.Get("MailItem", Folder.UI, false, ResourceManager.Get(ObjectLabel.Bd_Grid), new Vector3(), ObjType.MailItem);
- float newSpriteSize = 0.75f;
- mailItem.GetChild(1).SetActive(false);
- mailItem.GetChild(0).GetComponent<Image>().sprite = ResourceManager.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));
- InfoBoxManager.GardenInfoBox.Show($"{Language.GetStr(LanguageLabel.Common__Get)} {TransferLabel.CoinSprite}{Auxiliary.ShrinkNumberStr(double.Parse(mailReward.Value))}", 10, Color.white, ResourceManager.LoadSprite("Atlas", Folder.Atlas));
- }
- else if (mailReward.Key == "diamond")
- {
- Manager.AddDiamond(double.Parse(mailReward.Value), StaticsManager.ItemID.获得钻石, StaticsManager.ConsumeModule.Mail);
- Transform mailItem = ResourceManager.Get("MailItem", Folder.UI, false, ResourceManager.Get(ObjectLabel.Bd_Grid), new Vector3(), ObjType.MailItem);
- float newSpriteSize = 0.75f;
- mailItem.GetChild(1).SetActive(false);
- mailItem.GetChild(0).GetComponent<Image>().sprite = ResourceManager.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));
- InfoBoxManager.GardenInfoBox.Show($"{Language.GetStr(LanguageLabel.Common__Get)} {TransferLabel.DiamondSprite}{Auxiliary.ShrinkNumberStr(double.Parse(mailReward.Value))}", 10, Color.white, ResourceManager.LoadSprite("Atlas", Folder.Atlas));
- }
- 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.StringToStrings(' ', ConfigManager.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.StringToBool(data["l"][0]["val"].ToJson().Trim('"'), true);
- if (Application.platform == RuntimePlatform.Android)
- {
- PackLock = true;
- }
- if (ConfigManager.PlayerDoc_ != null)
- {
- ConfigManager.SavePlayerBool("PackLock", PackLock);
- }
- }
- );
- }
- public static void IOSAlipayRequest()
- {
- IndexRequest
- (
- data =>
- {
- IAPManager.UseAlipayOnIOS = Auxiliary.StringToBool(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(true, GetProductIDURL, urlData, callback, URLRequest.Method.POST);
- }
- public static void Login(URLRequest.URLRequestJsonCallBackDelegate callback = null)
- {
- URLRequestData urlData = new URLRequestData();
- urlData.Add("u", SystemInfo.deviceUniqueIdentifier);
- URLRequest.CreateURLRequest(false, LoginURL, urlData, LoginCallback + callback, URLRequest.Method.POST);
- }
- private static void LoginCallback(JsonData jsonData)
- {
- Complete = true;
- if (jsonData.Inst_Object.ContainsKey("c"))
- {
- Connect = true;
- //Debug.Log(jsonData.ToJson());
- JsonData = jsonData;
- Time = DateUtil.GetTime(jsonData["time"].ToJson());
- PraiseAmt = int.Parse(jsonData["p"].ToJson().Trim('"'));
- if (ConfigManager.DamageLock)
- {
- ID = jsonData["o"].ToString();
- SerialNumber = jsonData["i"].ToString();
- }
- else if (ConfigManager.PlayerDoc_ != null)
- {
- if (ConfigManager.GetPlayerString("ID") == "Default")
- {
- ID = jsonData["o"].ToString();
- if (Initializer.Complete)
- {
- ResourceManager.SetText(ObjectLabel.L_UserLab, ID);
- }
- }
- if (ConfigManager.GetPlayerString("SerialNumber") == "Default")
- {
- SerialNumber = JsonData["i"].ToString();
- }
- }
- 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()
- {
- Manager.SaveTimer = 0;
- URLRequestData urlData = new URLRequestData();
- urlData.Add("u", SerialNumber);
- urlData.Add("v", ReplayVersion);
- ConfigManager.SavePlayerConfig();
- urlData.Add("l", ConfigManager.PlayerDoc.OuterXml);
- URLRequest.CreateURLRequest(false, SaveURL, urlData, SaveCallback, URLRequest.Method.POST);
- //URLRequest.CreateStrURLRequest(false, 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(true, OtherURL, urlData, callback, URLRequest.Method.POST);
- }
- public static void DownloadByID(string id, URLRequest.URLRequestJsonCallBackDelegate callback)
- {
- URLRequestData urlData = new URLRequestData();
- urlData.Add("u", id);
- URLRequest.CreateURLRequest(true, DownloadURL, urlData, callback, URLRequest.Method.POST);
- }
- public static void DownloadBySerialNumber(string serialNumber, URLRequest.URLRequestJsonCallBackDelegate callback)
- {
- URLRequestData urlData = new URLRequestData();
- urlData.Add("u", serialNumber);
- URLRequest.CreateURLRequest(true, DownloadURL, urlData, callback, URLRequest.Method.POST);
- }
- public static void RandomLoad(URLRequest.URLRequestJsonCallBackDelegate callback)
- {
- URLRequestData urlData = new URLRequestData();
- urlData.Add("i", "");
- URLRequest.CreateURLRequest(false, RandomURL, urlData, callback, URLRequest.Method.POST);
- }
- public static void GetThanksGiftInfo(Action<JsonData> callback, Action failed)
- {
- URLRequestData urlData = new URLRequestData();
- URLRequest.CreateURLRequest
- (
- false,
- ThanksGiftInfoURL,
- urlData,
- jData =>
- {
- if (jData.Inst_Object.ContainsKey("l"))
- {
- callback.Invoke(jData["l"]);
- }
- else
- {
- failed.Invoke();
- }
- }
- );
- //URLRequest.CreateStrURLRequest
- //(
- // false,
- // NewBaseURL + "/index/gift",
- // urlData,
- // Debug.Log
- //);
- //JsonData rootJson = new JsonData();
- //JsonData jData = new JsonData();
- //rootJson["l"] = jData;
- //JsonData json = new JsonData();
- //json["i"] = 1;
- //json["g"] = "g100";
- //jData.Add(json);
- //json = new JsonData();
- //json["i"] = 2;
- //json["g"] = "d200";
- //jData.Add(json);
- //json = new JsonData();
- //json["i"] = 3;
- //json["g"] = "p1";
- //rootJson.Add(json);
- //json = new JsonData();
- //json["i"] = 4;
- //json["g"] = "f1";
- //rootJson.Add(json);
- //json = new JsonData();
- //json["i"] = 5;
- //json["g"] = "c1";
- //rootJson.Add(json);
- //json = new JsonData();
- //json["i"] = 6;
- //json["g"] = "s1";
- //rootJson.Add(json);
- //json = new JsonData();
- //json["i"] = 7;
- //json["g"] = "a1";
- //rootJson.Add(json);
- //Debug.Log(rootJson.ToJson());
- //Debug.Log(rootJson["l"][0].ToJson());
- //Debug.Log(rootJson["l"][1].ToJson());
- }
- public static void Report()
- {
- ResourceManager.Get(ObjectLabel.Lb_Info).TweenBacCG();
- string emailAddress = ResourceManager.Get<Text>(ObjectLabel.Lb_InputLab0).text;
- if (string.IsNullOrEmpty(emailAddress) || !emailAddress.Contains("@"))
- {
- Bubble.Show(null, Language.GetStr(LanguageLabel.UI__Lb_Send3));
- return;
- }
- string content = ResourceManager.Get<Text>(ObjectLabel.Lb_InputLab).text;
- if (string.IsNullOrEmpty(content))
- {
- Bubble.Show(null, Language.GetStr(LanguageLabel.UI__Lb_Send2));
- }
- else if(ReportContent == content)
- {
- Bubble.Show(null, Language.GetStr(LanguageLabel.UI__Lb_Send1));
- }
- else
- {
- MailMessage mailMessage = new MailMessage();
- mailMessage.To.Add(new MailAddress(ReportMailAddress));
- mailMessage.From = new MailAddress("dashgamegarden@163.com");
- ReportContent = content;
- mailMessage.Body = emailAddress + '\n' + 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(LanguageLabel.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();
- }
- }
|