VisitManager.cs 31 KB

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