VisitManager.cs 31 KB

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