12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067 |
- using LitJson;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityEngine.Events;
- using System;
- using System.Xml;
- using System.Collections;
- using System.Collections.Generic;
- using Random = UnityEngine.Random;
- public enum ArchiveSource
- {
- Fake,
- Random,
- SerialNumber,
- }
- public class VisitData
- {
- //public bool Praised;
- public JsonData JsonData;
- public XmlDocument Document;
- public VisitData(JsonData jsonData, XmlDocument document)
- {
- JsonData = jsonData;
- Document = document;
- }
- }
- public class VisitManager : Regist
- {
- #region Config
- #region 配置
- public static int Cost
- {
- get { return Cost_; }
- set
- {
- Cost_ = value;
- ResourceManager.Get<Text>(ObjectLabel.C_CostLab).text = TransferLabel.CoinSprite + Cost;
- }
- }
- public static int Cost_;
- public static int CoolTime;
- public static float FancyRate;
- public static float AwardRate;
- public static float CreateRate;
- public static string CostFml;
- public static string AwardMinFml;
- public static string AwardMaxFml;
- #endregion
- public static float PullTimer;
- public static List<VisitData> UsedDataList = new List<VisitData>();
- public static List<VisitData> UnusedDataList = new List<VisitData>();
- public static bool InVisit;
- public static bool Complete;
- public static bool LoadComplete;
- public static bool TweenComplete;
- public static int Slot;
- public static int Level;
- public static XmlNode Node;
- public static XmlDocument Document;
- public static int VisiteePraise;
- public static string VisiteeSerialNumber;
- public static bool OriginBird;
- public static bool OriginTree;
- public static bool OriginRainbow;
- public static List<Slot> VisitPlantList;
- public static List<Slot> OriginPlantList;
- public static List<ElfType> OriginElfList;
- #endregion
- private int MaxStachAmt = 8;
- private float PullArchiveTime = 0.5f;
- public void Update()
- {
- if (UnusedDataList.Count > MaxStachAmt)
- {
- return;
- }
- PullTimer += Time.deltaTime;
- if (PullTimer >= PullArchiveTime)
- {
- PullTimer = 0;
- HttpManager.RandomLoad
- (
- data =>
- {
- PullArchiveCallback(data, null, SavePulledArchive);
- }
- );
- }
- }
- public static void Initialize()
- {
- XmlAttributeCollection attribute = ConfigManager.GetVisitConfig();
- CostFml = attribute[5].Value;
- Cost = Mathf.FloorToInt((float)Auxiliary.FmlParse(CostFml, "l", Manager.Level.ToString()));
- AwardMinFml = attribute[2].Value;
- AwardMaxFml = attribute[3].Value;
- CoolTime = int.Parse(attribute[4].Value);
- FancyRate = float.Parse(attribute[7].Value);
- AwardRate = float.Parse(attribute[1].Value);
- CreateRate = float.Parse(attribute[6].Value);
- #region 倒计时
- if (CoolTime != 0)
- {
- Text text = ResourceManager.Get<Text>(ObjectLabel.C_VisitLab);
- List<float> delayList = new List<float>();
- List<float> durationList = new List<float>();
- List<VecPair> pairList = new List<VecPair>();
- List<UnityAction> actionList = new List<UnityAction>();
- Vector3 v1 = new Vector3(0.75f, 0.75f, 0.75f);
- Vector3 v2 = new Vector3(0.4f, 0.4f, 0.4f);
- Vector3 v3 = new Vector3(0, 0, 0);
- for (int i = 0; i < CoolTime - 1; i++)
- {
- delayList.Add(0.5f);
- delayList.Add(0);
- }
- delayList.Add(0.5f);
- for (int i = 0; i < CoolTime; i++)
- {
- durationList.Add(0.25f);
- durationList.Add(0.25f);
- pairList.Add(new VecPair(v1, v2));
- pairList.Add(new VecPair(v2, v3));
- var tempInt = i;
- actionList.Add
- (
- () =>
- {
- text.text = (CoolTime - tempInt).ToString();
- AudioManager.PlayClip(AudioLabel.ClickButton);
- }
- );
- actionList.Add(null);
- }
- TweenRoot tween = ResourceManager.Get(ObjectLabel.C_VisitLab).CreateStreamScale
- (
- delayList,
- durationList,
- pairList,
- true,
- false,
- Curve.EaseOutQuad,
- false,
- actionList
- );
- tween.OnForwardFinish += () =>
- {
- AudioManager.PlayClip(AudioLabel.Bubble);
- };
- }
- #endregion
- Complete = true;
- }
- public static void ExitVisiteeGarden()
- {
- ResourceManager.Get(ObjectLabel.I_BlackMask).TweenForCG();
- HideTip ();
- ResourceManager.SetActive(ObjectLabel.C_Visit, true);
- ResourceManager.SetActive(ObjectLabel.C_Coin, true);
- ResourceManager.SetActive(ObjectLabel.C_Group1, true);
- ResourceManager.SetActive(ObjectLabel.C_Group2, true);
- ResourceManager.Get<Button>(ObjectLabel.C_NickNameBK).interactable = true;
- ResourceManager.SetActive(ObjectLabel.C_Return, false);
- ResourceManager.SetActive(ObjectLabel.C_Garden, false);
- GardenManager.MiniLock = true;
- #region Garden
- GardenManager.RetriveFlowerAll();
- for (int i = 0; i < GardenManager.PageList.Count; i++)
- {
- ResourceManager.Save(GardenManager.PageList[i]);
- }
- GardenManager.PageList = new List<Transform>();
- GardenManager.SlotList = new List<Slot>();
- GardenManager.PageList = new List<Transform>();
- Garden.ResetPage();
- Garden.PagePos = new List<Vector3>();
- int pageAmt = GardenManager.DefaultPage;
- if (GardenManager.Slot >= GardenManager.CriticalSlotAmt)
- {
- pageAmt = (GardenManager.Slot - GardenManager.CriticalSlotAmt) / GardenManager.TotalSlotAmtInOnePage + 3;
- }
- for (int i = 0; i < pageAmt; i++)
- {
- GardenManager.CreatePage();
- }
- for (int i = 0; i < GardenManager.SlotList.Count; i++)
- {
- if (i < GardenManager.Slot)
- {
- GardenManager.SlotList[i].Lock = true;
- GardenManager.SlotList[i].Available = true;
- }
- else
- {
- GardenManager.SlotList[i].Lock = false;
- GardenManager.SlotList[i].Available = false;
- }
- }
- List<KV<int, int>> plantList = ConfigManager.GetPlantList();
- for (int i = 0; i < plantList.Count; i++)
- {
- GardenManager.PlantFlower(plantList[i].Key, plantList[i].Value);
- }
- #endregion
- #region Bird Tree Rainbow
- if (OriginBird)
- {
- ResourceManager.Get(GardenLabel.BirdPivot).GetTweenSr().InDestination = true;
- }
- else
- {
- ResourceManager.Get(GardenLabel.BirdPivot).GetTweenSr().InOrigin = true;
- }
- if (OriginTree)
- {
- ResourceManager.Get(GardenLabel.GardenLeftTree).GetTweenSr().InDestination = true;
- ResourceManager.Get(GardenLabel.GardenRightTree).GetTweenSr().InDestination = true;
- }
- else
- {
- ResourceManager.Get(GardenLabel.GardenLeftTree).GetTweenSr().InOrigin = true;
- ResourceManager.Get(GardenLabel.GardenRightTree).GetTweenSr().InOrigin = true;
- }
- if (OriginRainbow)
- {
- ResourceManager.Get(GardenLabel.GardenRainbow).GetTweenSr().InDestination = true;
- }
- else
- {
- ResourceManager.Get(GardenLabel.GardenRainbow).GetTweenSr().InOrigin = true;
- }
- #endregion
- #region Player
- ResourceManager.Save(PlayerManager.Player);
- ResourceManager.TraDic.Remove(PlayerLabel.Player);
- PlayerManager.Instance.GetPlayer();
- UIManager.SetEnterGameLabel();
- Garden.PlayerPos = new List<Vector3>();
- Garden.Player = ResourceManager.Get(PlayerLabel.Player);
- Garden.PlayerPos.Add(PlayerManager.Player.ChildDic[PlayerLabel.RightPos].position);
- Garden.PlayerPos.Add(PlayerManager.Player.ChildDic[PlayerLabel.LeftPos].position);
- #endregion
- GardenManager.ElfList = new List<ElfType>(OriginElfList);
- InVisit = false;
- LoadComplete = false;
- TweenComplete = false;
- SetPlayerPraise();
- SetPlayerCommentPanel();
- SetPlayerRankPanel();
- SetPlayerNickName();
- }
- public static void EnterVisiteeGarden()
- {
- if (!LoadComplete || !TweenComplete)
- {
- return;
- }
- ResourceManager.Get(ObjectLabel.I_BlackMask).TweenForCG();
- //Debug.Log(Document.OuterXml);
- SetVisiteePraise(Document);
- ShowTip ();
- Node = Document.SelectSingleNode(PlayerConfigLabel.RootNode);
- ResourceManager.SetActive(ObjectLabel.C_Coin, false);
- ResourceManager.SetActive(ObjectLabel.C_Group1, false);
- ResourceManager.SetActive(ObjectLabel.C_Group2, false);
- ResourceManager.Get<Button>(ObjectLabel.C_NickNameBK).interactable = false;
- ResourceManager.SetActive(ObjectLabel.C_Garden, true);
- if (!InVisit)
- {
- GardenManager.RetrieveAllStar();
- GardenManager.RetrieveAllElf();
- IAPManager.RetrieveADChest();
- GardenManager.StarList = new List<Star>();
- }
- ResourceManager.SetActive(ObjectLabel.C_Return, true);
- GardenManager.MiniLock = false;
- #region Bird Tree Rainbow
- if (!InVisit)
- {
- if (ResourceManager.Get(GardenLabel.BirdPivot).gameObject.activeSelf)
- {
- OriginBird = true;
- }
- if (ResourceManager.Get(GardenLabel.GardenLeftTree).gameObject.activeSelf)
- {
- OriginTree = true;
- }
- if (ResourceManager.Get(GardenLabel.GardenRainbow).gameObject.activeSelf)
- {
- OriginRainbow = true;
- }
- }
- ResourceManager.SetActive(GardenLabel.BirdPivot, false);
- ResourceManager.SetActive(GardenLabel.GardenLeftTree, false);
- ResourceManager.SetActive(GardenLabel.GardenRightTree, false);
- ResourceManager.SetActive(GardenLabel.GardenRainbow, false);
- #endregion
- #region Ability
- Slot = GardenManager.DefaultSlot;
- Slot += ConfigManager.GetIntFormConfig(PlayerConfigLabel.ExtraSlot);
- if (!InVisit)
- {
- OriginElfList = new List<ElfType>(GardenManager.ElfList);
- }
- GardenManager.ElfList = new List<ElfType>();
- List<XmlAttributeCollection> attributeList = ConfigManager.GetSkillList(Node);
- for (int i = 0; i < attributeList.Count; i++)
- {
- if (!attributeList[i][0].Value.Contains("Ability"))
- {
- continue;
- }
- if (attributeList[i][0].Value == "Ability1")
- {
- Level = int.Parse(attributeList[i][3].Value);
- ResourceManager.SetText(ObjectLabel.C_GardenLab, Language.GetStr(LanguageLabel.UI__C_GardenLab) + Level);
- continue;
- }
- if (int.Parse(attributeList[i][3].Value) == 0)
- {
- continue;
- }
- if (attributeList[i][0].Value == "Ability2")
- {
- ResourceManager.Get(GardenLabel.GardenRainbow).GetTweenSr().InDestination = true;
- }
- else if (attributeList[i][0].Value == "Ability3")
- {
- ResourceManager.Get(GardenLabel.GardenLeftTree).GetTweenSr().InDestination = true;
- ResourceManager.Get(GardenLabel.GardenRightTree).GetTweenSr().InDestination = true;
- }
- else if (attributeList[i][0].Value == "Ability4")
- {
- ResourceManager.Get(GardenLabel.BirdPivot).GetTweenSr().InDestination = true;
- }
- else if (attributeList[i][0].Value == "Ability5")
- {
- GardenManager.ElfList.Add(ElfType.Bee_Yellow);
- }
- else if (attributeList[i][0].Value == "Ability6")
- {
- Slot++;
- GardenManager.ElfList.Add(ElfType.Bee_Purple);
- }
- else if (attributeList[i][0].Value == "Ability7")
- {
- Slot++;
- GardenManager.ElfList.Add(ElfType.Bee_Blue);
- }
- else if (attributeList[i][0].Value == "Ability8")
- {
- Slot++;
- GardenManager.ElfList.Add(ElfType.Bee_Red);
- }
- else if (attributeList[i][0].Value == "Ability9")
- {
- Slot++;
- GardenManager.ElfList.Add(ElfType.Bee_White);
- }
- else if (attributeList[i][0].Value == "Ability10")
- {
- Slot++;
- GardenManager.ElfList.Add(ElfType.Butterfly_Yellow);
- }
- else if (attributeList[i][0].Value == "Ability11")
- {
- Slot++;
- GardenManager.ElfList.Add(ElfType.Butterfly_Purple);
- }
- else if (attributeList[i][0].Value == "Ability12")
- {
- Slot++;
- GardenManager.ElfList.Add(ElfType.Butterfly_Blue);
- }
- else if (attributeList[i][0].Value == "Ability13")
- {
- Slot++;
- GardenManager.ElfList.Add(ElfType.Butterfly_Red);
- }
- else if (attributeList[i][0].Value == "Ability14")
- {
- Slot++;
- GardenManager.ElfList.Add(ElfType.Butterfly_White);
- }
- else if (attributeList[i][0].Value == "Ability15")
- {
- Slot++;
- GardenManager.ElfList.Add(ElfType.Dragonfly_Yellow);
- }
- else if (attributeList[i][0].Value == "Ability16")
- {
- Slot++;
- GardenManager.ElfList.Add(ElfType.Dragonfly_Purple);
- }
- else if (attributeList[i][0].Value == "Ability17")
- {
- Slot++;
- GardenManager.ElfList.Add(ElfType.Dragonfly_Blue);
- }
- else if (attributeList[i][0].Value == "Ability18")
- {
- Slot++;
- GardenManager.ElfList.Add(ElfType.Dragonfly_Red);
- }
- else if (attributeList[i][0].Value == "Ability19")
- {
- Slot++;
- GardenManager.ElfList.Add(ElfType.Dragonfly_White);
- }
- else if (attributeList[i][0].Value == "Ability20")
- {
- Slot++;
- GardenManager.ElfList.Add(ElfType.Beetle_Yellow);
- }
- else if (attributeList[i][0].Value == "Ability21")
- {
- Slot++;
- GardenManager.ElfList.Add(ElfType.Beetle_Purple);
- }
- else if (attributeList[i][0].Value == "Ability22")
- {
- Slot++;
- GardenManager.ElfList.Add(ElfType.Beetle_Blue);
- }
- else if (attributeList[i][0].Value == "Ability23")
- {
- Slot++;
- GardenManager.ElfList.Add(ElfType.Beetle_Red);
- }
- else if (attributeList[i][0].Value == "Ability24")
- {
- Slot++;
- GardenManager.ElfList.Add(ElfType.Beetle_White);
- }
- }
-
- #endregion
- #region Garden
- if (!InVisit)
- {
- OriginPlantList = new List<Slot>(GardenManager.PlantList);
- ConfigManager.SaveDress();
- ConfigManager.SavePlantList();
- }
- GardenManager.RetriveFlowerAll();
- for (int i = 0; i < GardenManager.PageList.Count; i++)
- {
- ResourceManager.Save(GardenManager.PageList[i]);
- }
- GardenManager.PageList = new List<Transform>();
- GardenManager.SlotList = new List<Slot>();
- GardenManager.PageList = new List<Transform>();
- Garden.ResetPage();
- Garden.PagePos = new List<Vector3>();
- int pageAmt = GardenManager.DefaultPage;
- if (Slot >= GardenManager.CriticalSlotAmt)
- {
- pageAmt = (Slot - GardenManager.CriticalSlotAmt) / GardenManager.TotalSlotAmtInOnePage + 3;
- }
- for (int i = 0; i < pageAmt; i++)
- {
- GardenManager.CreatePage();
- }
-
- for (int i = 0; i < GardenManager.SlotList.Count; i++)
- {
- if (i < Slot)
- {
- GardenManager.SlotList[i].Lock = true;
- GardenManager.SlotList[i].Available = true;
- }
- else
- {
- GardenManager.SlotList[i].Lock = false;
- GardenManager.SlotList[i].Available = false;
- }
- }
- List<KV<int, int>> plantList = ConfigManager.GetPlantList(Node);
- for (int i = 0; i < plantList.Count; i++)
- {
- GardenManager.PlantFlower(plantList[i].Key, plantList[i].Value);
- }
- #endregion
- #region Player
- ResourceManager.Save(PlayerManager.Player);
- ResourceManager.TraDic.Remove(PlayerLabel.Player);
- PlayerManager.Instance.GetPlayer(Node).SetAllCollider(false);
- Garden.PlayerPos = new List<Vector3>();
- Garden.Player = ResourceManager.Get(PlayerLabel.Player);
- Garden.PlayerPos.Add(PlayerManager.Player.ChildDic[PlayerLabel.RightPos].position);
- Garden.PlayerPos.Add(PlayerManager.Player.ChildDic[PlayerLabel.LeftPos].position);
- #endregion
- #region Award
-
- if (Random.Range(0f,1f) <= AwardRate)
- {
- if (GardenManager.PlantList.Count > 0)
- {
- GardenManager.PlantList.Random()[0].Flower.Award = true;
- }
- }
- #endregion
- XmlNode nicknameNode = Document.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.NickName);
- if (nicknameNode == null || string.IsNullOrEmpty(nicknameNode.Attributes[0].Value))
- {
- SetVisiteeNickName(Language.GetStr(LanguageLabel.UI__Unnamed));
- }
- else
- {
- SetVisiteeNickName(nicknameNode.Attributes[0].Value);
- }
- InVisit = true;
- }
- public static void SetPlayerRankPanel()
- {
- SocialManager.RecoverRankPanel();
- }
- public static void SetPlayerPraise()
- {
- SocialManager.PraiseText.text = HttpManager.PraiseAmt.ToString();
- SocialManager.PraiseBtn.interactable = false;
- SocialManager.PraiseBtn.image.color = Color.white;
- }
- public static void SetVisiteePraise(XmlDocument document)
- {
- SocialManager.PraiseText.text = VisiteePraise.ToString();
- //Debug.Log(VisiteeSerialNumber);
- HttpManager.Target
- (
- HttpManager.SerialNumber,
- VisiteeSerialNumber,
- jsonData =>
- {
- if (jsonData["i"].ToString() == "0")
- {
- SocialManager.EnablePraise();
- }
- else if (jsonData["i"].ToString() == "1")
- {
- SocialManager.DisablePraise();
- }
- }
- );
- }
- public static void SetPlayerCommentPanel()
- {
- if (SocialManager.CommentRecordFlag)
- {
- SocialManager.RecoverCommentPanel();
- }
- else
- {
- //ManaSocial.UpdatePage(true);
- }
- }
- public static void SetVisiteeCommentPanel()
- {
- SocialManager.ClearComment();
- //ManaSocial.UpdatePage(false);
- }
- public static void SetPlayerNickName()
- {
- ResourceManager.SetText(ObjectLabel.C_NickNameLab, NickNameManager.NickName);
- }
- public static void SetVisiteeNickName(string nickname)
- {
- ResourceManager.SetText(ObjectLabel.C_NickNameLab, nickname);
- }
- public static void UpdateCost()
- {
- if (Complete)
- {
- Cost = Mathf.FloorToInt((float)Auxiliary.FmlParse(CostFml, "l", Manager.Level.ToString()));
- }
- }
- public static void DataReverse()
- {
- if (InVisit)
- {
- VisitPlantList = new List<Slot>(GardenManager.PlantList);
- GardenManager.PlantList = OriginPlantList;
- }
- }
- public static void DataRecover()
- {
- if (InVisit)
- {
- GardenManager.PlantList = VisitPlantList;
- }
- }
- private static int TipAmt = 10;
- public static void ShowTip()
- {
- ResourceManager.SetActive (ObjectLabel.C_Tip, true);
- string languageID = LanguageLabel.Tip + Random.Range(1, TipAmt);
- ResourceManager.Get<Text> (ObjectLabel.C_TipLab).text = Language.GetStr (LabelUtility.CombineLanguageLabel(LanguageLabel.Tip, languageID));
- }
- public static void HideTip()
- {
- ResourceManager.SetActive (ObjectLabel.C_Tip, false);
- }
- public static void Visit(ArchiveSource archiveSource, string info = null)
- {
- if (Manager.SceneSwitchLock)
- {
- return;
- }
- ResourceManager.SetActive(ObjectLabel.C_EnterPlazaRoom0, false);
- Manager.Pay
- (
- "",
- Cost,
- Current.Coin,
- () =>
- {
- ResourceManager.Get(ObjectLabel.I_BlackMask).GetTweenCG().Duration = 0.5f;
- LoadComplete = false;
- TweenComplete = false;
- GetArchive(archiveSource, info);
- AudioManager.PlayClip(AudioLabel.Bubble);
- ResourceManager.SetActive(ObjectLabel.C_Return, false);
- TweenRoot tween;
- if (CoolTime != 0)
- {
- ResourceManager.Get<Button>(ObjectLabel.C_Visit).interactable = false;
- tween = ResourceManager.Get(ObjectLabel.C_VisitLab).StreamReForScale();
- tween.AddEventOnetime
- (
- EventType.ForwardFinish,
- () =>
- {
- ResourceManager.Get<Button>(ObjectLabel.C_Visit).interactable = true;
- }
- );
- }
- tween = ResourceManager.Get(ObjectLabel.I_BlackMask).TweenBacCG();
- tween.AddEventOnetime
- (
- EventType.BackwardFinish,
- () =>
- {
- TweenComplete = true;
- EnterVisiteeGarden();
- }
- );
- },
- StaticsManager.ItemID.参观花费,
- StaticsManager.ConsumeModule.Shop,
- false
- );
- }
- public static void GetArchive(ArchiveSource archiveSource, string info = null)
- {
- if (archiveSource == ArchiveSource.SerialNumber)
- {
- HttpManager.Other
- (
- info,
- data =>
- {
- VisiteeSerialNumber = info;
- PullArchiveCallback
- (
- data,
- ShowFailPanel,
- (jData) =>
- {
- XmlDocument document = new XmlDocument();
- document.LoadXml(data["l"].ToString());
- EnterVisiteeGarden(new VisitData(jData, document));
- }
- );
- }
- );
- }
- else if (archiveSource == ArchiveSource.Random)
- {
- if (UnusedDataList.Count > 0)
- {
- EnterVisiteeGarden(UnusedDataList[0]);
- UsedDataList.Add(UnusedDataList[0]);
- UnusedDataList.RemoveAt(0);
- }
- else if (UsedDataList.Count > 0)
- {
- EnterVisiteeGarden(UsedDataList.Random()[0]);
- }
- else
- {
- ShowFailPanel();
- }
- }
- }
- public static void PullArchiveCallback(JsonData jsonData, Action failed, Action<JsonData> succeed)
- {
- if (jsonData.Inst_Object.ContainsKey("l"))
- {
- if (succeed != null)
- succeed.Invoke(jsonData);
- }
- else
- {
- if (failed != null)
- failed.Invoke();
- }
- }
- public static void SavePulledArchive(JsonData jsonData)
- {
- //Debug.Log(jsonData.ToJson());
- XmlDocument document = new XmlDocument();
- document.LoadXml(jsonData["l"].ToString());
- XmlNode xmlNode = document.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.SerialNumber);
- if (xmlNode != null && xmlNode.Attributes[0].Value != HttpManager.SerialNumber)
- {
- UnusedDataList.Add(new VisitData(jsonData, document));
- }
- }
- public static void EnterVisiteeGarden(VisitData visitData)
- {
- LoadComplete = true;
- VisiteePraise = int.Parse(visitData.JsonData["p"].ToString());
- if (visitData.JsonData.Inst_Object.ContainsKey("i"))
- {
- VisiteeSerialNumber = visitData.JsonData["i"].ToString();
- }
- Document = visitData.Document;
- SetVisiteeCommentPanel();
- EnterVisiteeGarden();
- }
- public static void ShowFailPanel()
- {
- Bubble.Show
- (
- Language.GetStr(LanguageLabel.UI__C_VisitFail),
- null,
- null,
- null,
- () =>
- {
- ResourceManager.Get(ObjectLabel.I_BlackMask).TweenForCG();
- ResourceManager.SetActive(ObjectLabel.C_EnterPlazaRoom0, true);
- },
- null,
- false
- );
- Manager.AddCoin(Cost, StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.VisitRefund);
- }
- public static string CreateArchive()
- {
- XmlDocument doc = new XmlDocument();
- doc.LoadXml(ConfigManager.ConfigDocument.OuterXml); //以自己的存档做模板进行修改
- int newLevel = Random.Range(1, 450); //随机等级
- #region 根据等级确定有多少土地解锁
- int slot = 1; //解锁土地数量
- XmlNodeList nodeList = doc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.SkillList).ChildNodes;
- for (int i = 0; i < nodeList.Count; i++)
- {
- SkillType type = nodeList[i].Attributes[1].Value.ToEnum<SkillType>();
- if (type == SkillType.Ability)
- {
- Ability ability = (Ability)Manager.SkillDic[nodeList[i].Attributes[0].Value];
- int unlockLevel = ability.UnlockLv;
- if (newLevel >= unlockLevel)
- {
- if (ability.ID_ >= 6)
- {
- slot++;
- }
- nodeList[i].Attributes[2].Value = "Upgrade";
- nodeList[i].Attributes[3].Value = newLevel.ToString();
- }
- else
- {
- nodeList[i].Attributes[2].Value = "Lock";
- nodeList[i].Attributes[3].Value = "0";
- }
- }
- }
- #endregion
- #region 随机种一些花
- bool fancy = Random.Range(0f, 1f) < FancyRate; //fancy=True时 种的花比较多
- List<int> flowerList = new List<int>();
- for (int i = 1; i < 36; i++)
- {
- flowerList.Add(i);
- }
- int slotIndex = 0;
- string plantList = "";
- for (int i = 0; i < slot; i++)
- {
- if (fancy || Random.Range(0f, 1f) >= 0.35f)
- {
- int flowerID = slotIndex + 1;
- plantList += string.Format("{0},{1} ", flowerID, slotIndex);
- slotIndex++;
- }
- }
- plantList = plantList.TrimEnd(' ');
- doc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.PlantList).Attributes[0].Value = plantList;
- #endregion
- #region 随机一套服装 等级越高拥有的服装越多 再随机选几件穿上
- XmlNode xmlNode = doc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.DressData);
- xmlNode.Attributes[0].Value = "";
- xmlNode.Attributes[0].Value = PlayerManager.CloseItemDic[Random.Range(2, (int)Mathf.Lerp(2, 30, newLevel / 449f) + 1)].ArmatureName;
- xmlNode.Attributes[1].Value = PlayerManager.CloseItemDic[Random.Range(201, (int)Mathf.Lerp(201, 217, newLevel / 449f) + 1)].ArmatureName;
- xmlNode.Attributes[2].Value = PlayerManager.CloseItemDic[Random.Range(401, (int)Mathf.Lerp(401, 415, newLevel / 449f) + 1)].ArmatureName;
- xmlNode.Attributes[3].Value = PlayerManager.CloseItemDic[Random.Range(601, (int)Mathf.Lerp(601, 612, newLevel / 449f) + 1)].ArmatureName;
- xmlNode.Attributes[4].Value = PlayerManager.CloseItemDic[Random.Range(801, (int)Mathf.Lerp(801, 817, newLevel / 449f) + 1)].ArmatureName;
- xmlNode.Attributes[7].Value = PlayerManager.CloseItemDic[Random.Range(1001, (int)Mathf.Lerp(1001, 1003, newLevel / 449f) + 1)].ArmatureName;
- #region 随机选一套眼睛嘴巴
- float eyeMouseRate = Random.Range(0f, 1f);
- if (eyeMouseRate <= 0.33f)
- {
- xmlNode.Attributes[5].Value = "眼睛1";
- xmlNode.Attributes[6].Value = "嘴巴1";
- }
- else if (eyeMouseRate <= 0.66f)
- {
- xmlNode.Attributes[5].Value = "眼睛2";
- xmlNode.Attributes[6].Value = "嘴巴2";
- }
- else
- {
- xmlNode.Attributes[5].Value = "眼睛3";
- xmlNode.Attributes[6].Value = "嘴巴3";
- }
- #endregion
- #endregion
- return doc.OuterXml;
- }
- }
|