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