VisitManager.cs 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067
  1. using LitJson;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. using UnityEngine.Events;
  5. using System;
  6. using System.Xml;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using Random = UnityEngine.Random;
  10. public enum ArchiveSource
  11. {
  12. Fake,
  13. Random,
  14. SerialNumber,
  15. }
  16. public class VisitData
  17. {
  18. //public bool Praised;
  19. public JsonData JsonData;
  20. public XmlDocument Document;
  21. public VisitData(JsonData jsonData, XmlDocument document)
  22. {
  23. JsonData = jsonData;
  24. Document = document;
  25. }
  26. }
  27. public class VisitManager : Regist
  28. {
  29. #region Config
  30. #region 配置
  31. public static int Cost
  32. {
  33. get { return Cost_; }
  34. set
  35. {
  36. Cost_ = value;
  37. ResourceManager.Get<Text>(ObjectLabel.C_CostLab).text = TransferLabel.CoinSprite + Cost;
  38. }
  39. }
  40. public static int Cost_;
  41. public static int CoolTime;
  42. public static float FancyRate;
  43. public static float AwardRate;
  44. public static float CreateRate;
  45. public static string CostFml;
  46. public static string AwardMinFml;
  47. public static string AwardMaxFml;
  48. #endregion
  49. public static float PullTimer;
  50. public static List<VisitData> UsedDataList = new List<VisitData>();
  51. public static List<VisitData> UnusedDataList = new List<VisitData>();
  52. public static bool InVisit;
  53. public static bool Complete;
  54. public static bool LoadComplete;
  55. public static bool TweenComplete;
  56. public static int Slot;
  57. public static int Level;
  58. public static XmlNode Node;
  59. public static XmlDocument Document;
  60. public static int VisiteePraise;
  61. public static string VisiteeSerialNumber;
  62. public static bool OriginBird;
  63. public static bool OriginTree;
  64. public static bool OriginRainbow;
  65. public static List<Slot> VisitPlantList;
  66. public static List<Slot> OriginPlantList;
  67. public static List<ElfType> OriginElfList;
  68. #endregion
  69. private int MaxStachAmt = 8;
  70. private float PullArchiveTime = 0.5f;
  71. public void Update()
  72. {
  73. if (UnusedDataList.Count > MaxStachAmt)
  74. {
  75. return;
  76. }
  77. PullTimer += Time.deltaTime;
  78. if (PullTimer >= PullArchiveTime)
  79. {
  80. PullTimer = 0;
  81. HttpManager.RandomLoad
  82. (
  83. data =>
  84. {
  85. PullArchiveCallback(data, null, SavePulledArchive);
  86. }
  87. );
  88. }
  89. }
  90. public static void Initialize()
  91. {
  92. XmlAttributeCollection attribute = ConfigManager.GetVisitConfig();
  93. CostFml = attribute[5].Value;
  94. Cost = Mathf.FloorToInt((float)Auxiliary.FmlParse(CostFml, "l", Manager.Level.ToString()));
  95. AwardMinFml = attribute[2].Value;
  96. AwardMaxFml = attribute[3].Value;
  97. CoolTime = int.Parse(attribute[4].Value);
  98. FancyRate = float.Parse(attribute[7].Value);
  99. AwardRate = float.Parse(attribute[1].Value);
  100. CreateRate = float.Parse(attribute[6].Value);
  101. #region 倒计时
  102. if (CoolTime != 0)
  103. {
  104. Text text = ResourceManager.Get<Text>(ObjectLabel.C_VisitLab);
  105. List<float> delayList = new List<float>();
  106. List<float> durationList = new List<float>();
  107. List<VecPair> pairList = new List<VecPair>();
  108. List<UnityAction> actionList = new List<UnityAction>();
  109. Vector3 v1 = new Vector3(0.75f, 0.75f, 0.75f);
  110. Vector3 v2 = new Vector3(0.4f, 0.4f, 0.4f);
  111. Vector3 v3 = new Vector3(0, 0, 0);
  112. for (int i = 0; i < CoolTime - 1; i++)
  113. {
  114. delayList.Add(0.5f);
  115. delayList.Add(0);
  116. }
  117. delayList.Add(0.5f);
  118. for (int i = 0; i < CoolTime; i++)
  119. {
  120. durationList.Add(0.25f);
  121. durationList.Add(0.25f);
  122. pairList.Add(new VecPair(v1, v2));
  123. pairList.Add(new VecPair(v2, v3));
  124. var tempInt = i;
  125. actionList.Add
  126. (
  127. () =>
  128. {
  129. text.text = (CoolTime - tempInt).ToString();
  130. AudioManager.PlayClip(AudioLabel.ClickButton);
  131. }
  132. );
  133. actionList.Add(null);
  134. }
  135. TweenRoot tween = ResourceManager.Get(ObjectLabel.C_VisitLab).CreateStreamScale
  136. (
  137. delayList,
  138. durationList,
  139. pairList,
  140. true,
  141. false,
  142. Curve.EaseOutQuad,
  143. false,
  144. actionList
  145. );
  146. tween.OnForwardFinish += () =>
  147. {
  148. AudioManager.PlayClip(AudioLabel.Bubble);
  149. };
  150. }
  151. #endregion
  152. Complete = true;
  153. }
  154. public static void ExitVisiteeGarden()
  155. {
  156. ResourceManager.Get(ObjectLabel.I_BlackMask).TweenForCG();
  157. HideTip ();
  158. ResourceManager.SetActive(ObjectLabel.C_Visit, true);
  159. ResourceManager.SetActive(ObjectLabel.C_Coin, true);
  160. ResourceManager.SetActive(ObjectLabel.C_Group1, true);
  161. ResourceManager.SetActive(ObjectLabel.C_Group2, true);
  162. ResourceManager.Get<Button>(ObjectLabel.C_NickNameBK).interactable = true;
  163. ResourceManager.SetActive(ObjectLabel.C_Return, false);
  164. ResourceManager.SetActive(ObjectLabel.C_Garden, false);
  165. GardenManager.MiniLock = true;
  166. #region Garden
  167. GardenManager.RetriveFlowerAll();
  168. for (int i = 0; i < GardenManager.PageList.Count; i++)
  169. {
  170. ResourceManager.Save(GardenManager.PageList[i]);
  171. }
  172. GardenManager.PageList = new List<Transform>();
  173. GardenManager.SlotList = new List<Slot>();
  174. GardenManager.PageList = new List<Transform>();
  175. Garden.ResetPage();
  176. Garden.PagePos = new List<Vector3>();
  177. int pageAmt = GardenManager.DefaultPage;
  178. if (GardenManager.Slot >= GardenManager.CriticalSlotAmt)
  179. {
  180. pageAmt = (GardenManager.Slot - GardenManager.CriticalSlotAmt) / GardenManager.TotalSlotAmtInOnePage + 3;
  181. }
  182. for (int i = 0; i < pageAmt; i++)
  183. {
  184. GardenManager.CreatePage();
  185. }
  186. for (int i = 0; i < GardenManager.SlotList.Count; i++)
  187. {
  188. if (i < GardenManager.Slot)
  189. {
  190. GardenManager.SlotList[i].Lock = true;
  191. GardenManager.SlotList[i].Available = true;
  192. }
  193. else
  194. {
  195. GardenManager.SlotList[i].Lock = false;
  196. GardenManager.SlotList[i].Available = false;
  197. }
  198. }
  199. List<KV<int, int>> plantList = ConfigManager.GetPlantList();
  200. for (int i = 0; i < plantList.Count; i++)
  201. {
  202. GardenManager.PlantFlower(plantList[i].Key, plantList[i].Value);
  203. }
  204. #endregion
  205. #region Bird Tree Rainbow
  206. if (OriginBird)
  207. {
  208. ResourceManager.Get(GardenLabel.BirdPivot).GetTweenSr().InDestination = true;
  209. }
  210. else
  211. {
  212. ResourceManager.Get(GardenLabel.BirdPivot).GetTweenSr().InOrigin = true;
  213. }
  214. if (OriginTree)
  215. {
  216. ResourceManager.Get(GardenLabel.GardenLeftTree).GetTweenSr().InDestination = true;
  217. ResourceManager.Get(GardenLabel.GardenRightTree).GetTweenSr().InDestination = true;
  218. }
  219. else
  220. {
  221. ResourceManager.Get(GardenLabel.GardenLeftTree).GetTweenSr().InOrigin = true;
  222. ResourceManager.Get(GardenLabel.GardenRightTree).GetTweenSr().InOrigin = true;
  223. }
  224. if (OriginRainbow)
  225. {
  226. ResourceManager.Get(GardenLabel.GardenRainbow).GetTweenSr().InDestination = true;
  227. }
  228. else
  229. {
  230. ResourceManager.Get(GardenLabel.GardenRainbow).GetTweenSr().InOrigin = true;
  231. }
  232. #endregion
  233. #region Player
  234. ResourceManager.Save(PlayerManager.Player);
  235. ResourceManager.TraDic.Remove(PlayerLabel.Player);
  236. PlayerManager.Instance.GetPlayer();
  237. UIManager.SetEnterGameLabel();
  238. Garden.PlayerPos = new List<Vector3>();
  239. Garden.Player = ResourceManager.Get(PlayerLabel.Player);
  240. Garden.PlayerPos.Add(PlayerManager.Player.ChildDic[PlayerLabel.RightPos].position);
  241. Garden.PlayerPos.Add(PlayerManager.Player.ChildDic[PlayerLabel.LeftPos].position);
  242. #endregion
  243. GardenManager.ElfList = new List<ElfType>(OriginElfList);
  244. InVisit = false;
  245. LoadComplete = false;
  246. TweenComplete = false;
  247. SetPlayerPraise();
  248. SetPlayerCommentPanel();
  249. SetPlayerRankPanel();
  250. SetPlayerNickName();
  251. }
  252. public static void EnterVisiteeGarden()
  253. {
  254. if (!LoadComplete || !TweenComplete)
  255. {
  256. return;
  257. }
  258. ResourceManager.Get(ObjectLabel.I_BlackMask).TweenForCG();
  259. //Debug.Log(Document.OuterXml);
  260. SetVisiteePraise(Document);
  261. ShowTip ();
  262. Node = Document.SelectSingleNode(PlayerConfigLabel.RootNode);
  263. ResourceManager.SetActive(ObjectLabel.C_Coin, false);
  264. ResourceManager.SetActive(ObjectLabel.C_Group1, false);
  265. ResourceManager.SetActive(ObjectLabel.C_Group2, false);
  266. ResourceManager.Get<Button>(ObjectLabel.C_NickNameBK).interactable = false;
  267. ResourceManager.SetActive(ObjectLabel.C_Garden, true);
  268. if (!InVisit)
  269. {
  270. GardenManager.RetrieveAllStar();
  271. GardenManager.RetrieveAllElf();
  272. IAPManager.RetrieveADChest();
  273. GardenManager.StarList = new List<Star>();
  274. }
  275. ResourceManager.SetActive(ObjectLabel.C_Return, true);
  276. GardenManager.MiniLock = false;
  277. #region Bird Tree Rainbow
  278. if (!InVisit)
  279. {
  280. if (ResourceManager.Get(GardenLabel.BirdPivot).gameObject.activeSelf)
  281. {
  282. OriginBird = true;
  283. }
  284. if (ResourceManager.Get(GardenLabel.GardenLeftTree).gameObject.activeSelf)
  285. {
  286. OriginTree = true;
  287. }
  288. if (ResourceManager.Get(GardenLabel.GardenRainbow).gameObject.activeSelf)
  289. {
  290. OriginRainbow = true;
  291. }
  292. }
  293. ResourceManager.SetActive(GardenLabel.BirdPivot, false);
  294. ResourceManager.SetActive(GardenLabel.GardenLeftTree, false);
  295. ResourceManager.SetActive(GardenLabel.GardenRightTree, false);
  296. ResourceManager.SetActive(GardenLabel.GardenRainbow, false);
  297. #endregion
  298. #region Ability
  299. Slot = GardenManager.DefaultSlot;
  300. Slot += ConfigManager.GetIntFormConfig(PlayerConfigLabel.ExtraSlot);
  301. if (!InVisit)
  302. {
  303. OriginElfList = new List<ElfType>(GardenManager.ElfList);
  304. }
  305. GardenManager.ElfList = new List<ElfType>();
  306. List<XmlAttributeCollection> attributeList = ConfigManager.GetSkillList(Node);
  307. for (int i = 0; i < attributeList.Count; i++)
  308. {
  309. if (!attributeList[i][0].Value.Contains("Ability"))
  310. {
  311. continue;
  312. }
  313. if (attributeList[i][0].Value == "Ability1")
  314. {
  315. Level = int.Parse(attributeList[i][3].Value);
  316. ResourceManager.SetText(ObjectLabel.C_GardenLab, Language.GetStr(LanguageLabel.UI__C_GardenLab) + Level);
  317. continue;
  318. }
  319. if (int.Parse(attributeList[i][3].Value) == 0)
  320. {
  321. continue;
  322. }
  323. if (attributeList[i][0].Value == "Ability2")
  324. {
  325. ResourceManager.Get(GardenLabel.GardenRainbow).GetTweenSr().InDestination = true;
  326. }
  327. else if (attributeList[i][0].Value == "Ability3")
  328. {
  329. ResourceManager.Get(GardenLabel.GardenLeftTree).GetTweenSr().InDestination = true;
  330. ResourceManager.Get(GardenLabel.GardenRightTree).GetTweenSr().InDestination = true;
  331. }
  332. else if (attributeList[i][0].Value == "Ability4")
  333. {
  334. ResourceManager.Get(GardenLabel.BirdPivot).GetTweenSr().InDestination = true;
  335. }
  336. else if (attributeList[i][0].Value == "Ability5")
  337. {
  338. GardenManager.ElfList.Add(ElfType.Bee_Yellow);
  339. }
  340. else if (attributeList[i][0].Value == "Ability6")
  341. {
  342. Slot++;
  343. GardenManager.ElfList.Add(ElfType.Bee_Purple);
  344. }
  345. else if (attributeList[i][0].Value == "Ability7")
  346. {
  347. Slot++;
  348. GardenManager.ElfList.Add(ElfType.Bee_Blue);
  349. }
  350. else if (attributeList[i][0].Value == "Ability8")
  351. {
  352. Slot++;
  353. GardenManager.ElfList.Add(ElfType.Bee_Red);
  354. }
  355. else if (attributeList[i][0].Value == "Ability9")
  356. {
  357. Slot++;
  358. GardenManager.ElfList.Add(ElfType.Bee_White);
  359. }
  360. else if (attributeList[i][0].Value == "Ability10")
  361. {
  362. Slot++;
  363. GardenManager.ElfList.Add(ElfType.Butterfly_Yellow);
  364. }
  365. else if (attributeList[i][0].Value == "Ability11")
  366. {
  367. Slot++;
  368. GardenManager.ElfList.Add(ElfType.Butterfly_Purple);
  369. }
  370. else if (attributeList[i][0].Value == "Ability12")
  371. {
  372. Slot++;
  373. GardenManager.ElfList.Add(ElfType.Butterfly_Blue);
  374. }
  375. else if (attributeList[i][0].Value == "Ability13")
  376. {
  377. Slot++;
  378. GardenManager.ElfList.Add(ElfType.Butterfly_Red);
  379. }
  380. else if (attributeList[i][0].Value == "Ability14")
  381. {
  382. Slot++;
  383. GardenManager.ElfList.Add(ElfType.Butterfly_White);
  384. }
  385. else if (attributeList[i][0].Value == "Ability15")
  386. {
  387. Slot++;
  388. GardenManager.ElfList.Add(ElfType.Dragonfly_Yellow);
  389. }
  390. else if (attributeList[i][0].Value == "Ability16")
  391. {
  392. Slot++;
  393. GardenManager.ElfList.Add(ElfType.Dragonfly_Purple);
  394. }
  395. else if (attributeList[i][0].Value == "Ability17")
  396. {
  397. Slot++;
  398. GardenManager.ElfList.Add(ElfType.Dragonfly_Blue);
  399. }
  400. else if (attributeList[i][0].Value == "Ability18")
  401. {
  402. Slot++;
  403. GardenManager.ElfList.Add(ElfType.Dragonfly_Red);
  404. }
  405. else if (attributeList[i][0].Value == "Ability19")
  406. {
  407. Slot++;
  408. GardenManager.ElfList.Add(ElfType.Dragonfly_White);
  409. }
  410. else if (attributeList[i][0].Value == "Ability20")
  411. {
  412. Slot++;
  413. GardenManager.ElfList.Add(ElfType.Beetle_Yellow);
  414. }
  415. else if (attributeList[i][0].Value == "Ability21")
  416. {
  417. Slot++;
  418. GardenManager.ElfList.Add(ElfType.Beetle_Purple);
  419. }
  420. else if (attributeList[i][0].Value == "Ability22")
  421. {
  422. Slot++;
  423. GardenManager.ElfList.Add(ElfType.Beetle_Blue);
  424. }
  425. else if (attributeList[i][0].Value == "Ability23")
  426. {
  427. Slot++;
  428. GardenManager.ElfList.Add(ElfType.Beetle_Red);
  429. }
  430. else if (attributeList[i][0].Value == "Ability24")
  431. {
  432. Slot++;
  433. GardenManager.ElfList.Add(ElfType.Beetle_White);
  434. }
  435. }
  436. #endregion
  437. #region Garden
  438. if (!InVisit)
  439. {
  440. OriginPlantList = new List<Slot>(GardenManager.PlantList);
  441. ConfigManager.SaveDress();
  442. ConfigManager.SavePlantList();
  443. }
  444. GardenManager.RetriveFlowerAll();
  445. for (int i = 0; i < GardenManager.PageList.Count; i++)
  446. {
  447. ResourceManager.Save(GardenManager.PageList[i]);
  448. }
  449. GardenManager.PageList = new List<Transform>();
  450. GardenManager.SlotList = new List<Slot>();
  451. GardenManager.PageList = new List<Transform>();
  452. Garden.ResetPage();
  453. Garden.PagePos = new List<Vector3>();
  454. int pageAmt = GardenManager.DefaultPage;
  455. if (Slot >= GardenManager.CriticalSlotAmt)
  456. {
  457. pageAmt = (Slot - GardenManager.CriticalSlotAmt) / GardenManager.TotalSlotAmtInOnePage + 3;
  458. }
  459. for (int i = 0; i < pageAmt; i++)
  460. {
  461. GardenManager.CreatePage();
  462. }
  463. for (int i = 0; i < GardenManager.SlotList.Count; i++)
  464. {
  465. if (i < Slot)
  466. {
  467. GardenManager.SlotList[i].Lock = true;
  468. GardenManager.SlotList[i].Available = true;
  469. }
  470. else
  471. {
  472. GardenManager.SlotList[i].Lock = false;
  473. GardenManager.SlotList[i].Available = false;
  474. }
  475. }
  476. List<KV<int, int>> plantList = ConfigManager.GetPlantList(Node);
  477. for (int i = 0; i < plantList.Count; i++)
  478. {
  479. GardenManager.PlantFlower(plantList[i].Key, plantList[i].Value);
  480. }
  481. #endregion
  482. #region Player
  483. ResourceManager.Save(PlayerManager.Player);
  484. ResourceManager.TraDic.Remove(PlayerLabel.Player);
  485. PlayerManager.Instance.GetPlayer(Node).SetAllCollider(false);
  486. Garden.PlayerPos = new List<Vector3>();
  487. Garden.Player = ResourceManager.Get(PlayerLabel.Player);
  488. Garden.PlayerPos.Add(PlayerManager.Player.ChildDic[PlayerLabel.RightPos].position);
  489. Garden.PlayerPos.Add(PlayerManager.Player.ChildDic[PlayerLabel.LeftPos].position);
  490. #endregion
  491. #region Award
  492. if (Random.Range(0f,1f) <= AwardRate)
  493. {
  494. if (GardenManager.PlantList.Count > 0)
  495. {
  496. GardenManager.PlantList.Random()[0].Flower.Award = true;
  497. }
  498. }
  499. #endregion
  500. XmlNode nicknameNode = Document.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.NickName);
  501. if (nicknameNode == null || string.IsNullOrEmpty(nicknameNode.Attributes[0].Value))
  502. {
  503. SetVisiteeNickName(Language.GetStr(LanguageLabel.UI__Unnamed));
  504. }
  505. else
  506. {
  507. SetVisiteeNickName(nicknameNode.Attributes[0].Value);
  508. }
  509. InVisit = true;
  510. }
  511. public static void SetPlayerRankPanel()
  512. {
  513. SocialManager.RecoverRankPanel();
  514. }
  515. public static void SetPlayerPraise()
  516. {
  517. SocialManager.PraiseText.text = HttpManager.PraiseAmt.ToString();
  518. SocialManager.PraiseBtn.interactable = false;
  519. SocialManager.PraiseBtn.image.color = Color.white;
  520. }
  521. public static void SetVisiteePraise(XmlDocument document)
  522. {
  523. SocialManager.PraiseText.text = VisiteePraise.ToString();
  524. //Debug.Log(VisiteeSerialNumber);
  525. HttpManager.Target
  526. (
  527. HttpManager.SerialNumber,
  528. VisiteeSerialNumber,
  529. jsonData =>
  530. {
  531. if (jsonData["i"].ToString() == "0")
  532. {
  533. SocialManager.EnablePraise();
  534. }
  535. else if (jsonData["i"].ToString() == "1")
  536. {
  537. SocialManager.DisablePraise();
  538. }
  539. }
  540. );
  541. }
  542. public static void SetPlayerCommentPanel()
  543. {
  544. if (SocialManager.CommentRecordFlag)
  545. {
  546. SocialManager.RecoverCommentPanel();
  547. }
  548. else
  549. {
  550. //ManaSocial.UpdatePage(true);
  551. }
  552. }
  553. public static void SetVisiteeCommentPanel()
  554. {
  555. SocialManager.ClearComment();
  556. //ManaSocial.UpdatePage(false);
  557. }
  558. public static void SetPlayerNickName()
  559. {
  560. ResourceManager.SetText(ObjectLabel.C_NickNameLab, NickNameManager.NickName);
  561. }
  562. public static void SetVisiteeNickName(string nickname)
  563. {
  564. ResourceManager.SetText(ObjectLabel.C_NickNameLab, nickname);
  565. }
  566. public static void UpdateCost()
  567. {
  568. if (Complete)
  569. {
  570. Cost = Mathf.FloorToInt((float)Auxiliary.FmlParse(CostFml, "l", Manager.Level.ToString()));
  571. }
  572. }
  573. public static void DataReverse()
  574. {
  575. if (InVisit)
  576. {
  577. VisitPlantList = new List<Slot>(GardenManager.PlantList);
  578. GardenManager.PlantList = OriginPlantList;
  579. }
  580. }
  581. public static void DataRecover()
  582. {
  583. if (InVisit)
  584. {
  585. GardenManager.PlantList = VisitPlantList;
  586. }
  587. }
  588. private static int TipAmt = 10;
  589. public static void ShowTip()
  590. {
  591. ResourceManager.SetActive (ObjectLabel.C_Tip, true);
  592. string languageID = LanguageLabel.Tip + Random.Range(1, TipAmt);
  593. ResourceManager.Get<Text> (ObjectLabel.C_TipLab).text = Language.GetStr (LabelUtility.CombineLanguageLabel(LanguageLabel.Tip, languageID));
  594. }
  595. public static void HideTip()
  596. {
  597. ResourceManager.SetActive (ObjectLabel.C_Tip, false);
  598. }
  599. public static void Visit(ArchiveSource archiveSource, string info = null)
  600. {
  601. if (Manager.SceneSwitchLock)
  602. {
  603. return;
  604. }
  605. ResourceManager.SetActive(ObjectLabel.C_EnterPlazaRoom0, false);
  606. Manager.Pay
  607. (
  608. "",
  609. Cost,
  610. Current.Coin,
  611. () =>
  612. {
  613. ResourceManager.Get(ObjectLabel.I_BlackMask).GetTweenCG().Duration = 0.5f;
  614. LoadComplete = false;
  615. TweenComplete = false;
  616. GetArchive(archiveSource, info);
  617. AudioManager.PlayClip(AudioLabel.Bubble);
  618. ResourceManager.SetActive(ObjectLabel.C_Return, false);
  619. TweenRoot tween;
  620. if (CoolTime != 0)
  621. {
  622. ResourceManager.Get<Button>(ObjectLabel.C_Visit).interactable = false;
  623. tween = ResourceManager.Get(ObjectLabel.C_VisitLab).StreamReForScale();
  624. tween.AddEventOnetime
  625. (
  626. EventType.ForwardFinish,
  627. () =>
  628. {
  629. ResourceManager.Get<Button>(ObjectLabel.C_Visit).interactable = true;
  630. }
  631. );
  632. }
  633. tween = ResourceManager.Get(ObjectLabel.I_BlackMask).TweenBacCG();
  634. tween.AddEventOnetime
  635. (
  636. EventType.BackwardFinish,
  637. () =>
  638. {
  639. TweenComplete = true;
  640. EnterVisiteeGarden();
  641. }
  642. );
  643. },
  644. StaticsManager.ItemID.参观花费,
  645. StaticsManager.ConsumeModule.Shop,
  646. false
  647. );
  648. }
  649. public static void GetArchive(ArchiveSource archiveSource, string info = null)
  650. {
  651. if (archiveSource == ArchiveSource.SerialNumber)
  652. {
  653. HttpManager.Other
  654. (
  655. info,
  656. data =>
  657. {
  658. VisiteeSerialNumber = info;
  659. PullArchiveCallback
  660. (
  661. data,
  662. ShowFailPanel,
  663. (jData) =>
  664. {
  665. XmlDocument document = new XmlDocument();
  666. document.LoadXml(data["l"].ToString());
  667. EnterVisiteeGarden(new VisitData(jData, document));
  668. }
  669. );
  670. }
  671. );
  672. }
  673. else if (archiveSource == ArchiveSource.Random)
  674. {
  675. if (UnusedDataList.Count > 0)
  676. {
  677. EnterVisiteeGarden(UnusedDataList[0]);
  678. UsedDataList.Add(UnusedDataList[0]);
  679. UnusedDataList.RemoveAt(0);
  680. }
  681. else if (UsedDataList.Count > 0)
  682. {
  683. EnterVisiteeGarden(UsedDataList.Random()[0]);
  684. }
  685. else
  686. {
  687. ShowFailPanel();
  688. }
  689. }
  690. }
  691. public static void PullArchiveCallback(JsonData jsonData, Action failed, Action<JsonData> succeed)
  692. {
  693. if (jsonData.Inst_Object.ContainsKey("l"))
  694. {
  695. if (succeed != null)
  696. succeed.Invoke(jsonData);
  697. }
  698. else
  699. {
  700. if (failed != null)
  701. failed.Invoke();
  702. }
  703. }
  704. public static void SavePulledArchive(JsonData jsonData)
  705. {
  706. //Debug.Log(jsonData.ToJson());
  707. XmlDocument document = new XmlDocument();
  708. document.LoadXml(jsonData["l"].ToString());
  709. XmlNode xmlNode = document.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.SerialNumber);
  710. if (xmlNode != null && xmlNode.Attributes[0].Value != HttpManager.SerialNumber)
  711. {
  712. UnusedDataList.Add(new VisitData(jsonData, document));
  713. }
  714. }
  715. public static void EnterVisiteeGarden(VisitData visitData)
  716. {
  717. LoadComplete = true;
  718. VisiteePraise = int.Parse(visitData.JsonData["p"].ToString());
  719. if (visitData.JsonData.Inst_Object.ContainsKey("i"))
  720. {
  721. VisiteeSerialNumber = visitData.JsonData["i"].ToString();
  722. }
  723. Document = visitData.Document;
  724. SetVisiteeCommentPanel();
  725. EnterVisiteeGarden();
  726. }
  727. public static void ShowFailPanel()
  728. {
  729. Bubble.Show
  730. (
  731. Language.GetStr(LanguageLabel.UI__C_VisitFail),
  732. null,
  733. null,
  734. null,
  735. () =>
  736. {
  737. ResourceManager.Get(ObjectLabel.I_BlackMask).TweenForCG();
  738. ResourceManager.SetActive(ObjectLabel.C_EnterPlazaRoom0, true);
  739. },
  740. null,
  741. false
  742. );
  743. Manager.AddCoin(Cost, StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.VisitRefund);
  744. }
  745. public static string CreateArchive()
  746. {
  747. XmlDocument doc = new XmlDocument();
  748. doc.LoadXml(ConfigManager.ConfigDocument.OuterXml); //以自己的存档做模板进行修改
  749. int newLevel = Random.Range(1, 450); //随机等级
  750. #region 根据等级确定有多少土地解锁
  751. int slot = 1; //解锁土地数量
  752. XmlNodeList nodeList = doc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.SkillList).ChildNodes;
  753. for (int i = 0; i < nodeList.Count; i++)
  754. {
  755. SkillType type = nodeList[i].Attributes[1].Value.ToEnum<SkillType>();
  756. if (type == SkillType.Ability)
  757. {
  758. Ability ability = (Ability)Manager.SkillDic[nodeList[i].Attributes[0].Value];
  759. int unlockLevel = ability.UnlockLv;
  760. if (newLevel >= unlockLevel)
  761. {
  762. if (ability.ID_ >= 6)
  763. {
  764. slot++;
  765. }
  766. nodeList[i].Attributes[2].Value = "Upgrade";
  767. nodeList[i].Attributes[3].Value = newLevel.ToString();
  768. }
  769. else
  770. {
  771. nodeList[i].Attributes[2].Value = "Lock";
  772. nodeList[i].Attributes[3].Value = "0";
  773. }
  774. }
  775. }
  776. #endregion
  777. #region 随机种一些花
  778. bool fancy = Random.Range(0f, 1f) < FancyRate; //fancy=True时 种的花比较多
  779. List<int> flowerList = new List<int>();
  780. for (int i = 1; i < 36; i++)
  781. {
  782. flowerList.Add(i);
  783. }
  784. int slotIndex = 0;
  785. string plantList = "";
  786. for (int i = 0; i < slot; i++)
  787. {
  788. if (fancy || Random.Range(0f, 1f) >= 0.35f)
  789. {
  790. int flowerID = slotIndex + 1;
  791. plantList += string.Format("{0},{1} ", flowerID, slotIndex);
  792. slotIndex++;
  793. }
  794. }
  795. plantList = plantList.TrimEnd(' ');
  796. doc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.PlantList).Attributes[0].Value = plantList;
  797. #endregion
  798. #region 随机一套服装 等级越高拥有的服装越多 再随机选几件穿上
  799. XmlNode xmlNode = doc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.DressData);
  800. xmlNode.Attributes[0].Value = "";
  801. xmlNode.Attributes[0].Value = PlayerManager.CloseItemDic[Random.Range(2, (int)Mathf.Lerp(2, 30, newLevel / 449f) + 1)].ArmatureName;
  802. xmlNode.Attributes[1].Value = PlayerManager.CloseItemDic[Random.Range(201, (int)Mathf.Lerp(201, 217, newLevel / 449f) + 1)].ArmatureName;
  803. xmlNode.Attributes[2].Value = PlayerManager.CloseItemDic[Random.Range(401, (int)Mathf.Lerp(401, 415, newLevel / 449f) + 1)].ArmatureName;
  804. xmlNode.Attributes[3].Value = PlayerManager.CloseItemDic[Random.Range(601, (int)Mathf.Lerp(601, 612, newLevel / 449f) + 1)].ArmatureName;
  805. xmlNode.Attributes[4].Value = PlayerManager.CloseItemDic[Random.Range(801, (int)Mathf.Lerp(801, 817, newLevel / 449f) + 1)].ArmatureName;
  806. xmlNode.Attributes[7].Value = PlayerManager.CloseItemDic[Random.Range(1001, (int)Mathf.Lerp(1001, 1003, newLevel / 449f) + 1)].ArmatureName;
  807. #region 随机选一套眼睛嘴巴
  808. float eyeMouseRate = Random.Range(0f, 1f);
  809. if (eyeMouseRate <= 0.33f)
  810. {
  811. xmlNode.Attributes[5].Value = "眼睛1";
  812. xmlNode.Attributes[6].Value = "嘴巴1";
  813. }
  814. else if (eyeMouseRate <= 0.66f)
  815. {
  816. xmlNode.Attributes[5].Value = "眼睛2";
  817. xmlNode.Attributes[6].Value = "嘴巴2";
  818. }
  819. else
  820. {
  821. xmlNode.Attributes[5].Value = "眼睛3";
  822. xmlNode.Attributes[6].Value = "嘴巴3";
  823. }
  824. #endregion
  825. #endregion
  826. return doc.OuterXml;
  827. }
  828. }