1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132 |
- 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 ConfigSource
- {
- 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 VisitCost
- {
- get { return visitCost; }
- set
- {
- visitCost = value;
- ResourceManager.Get<Text>(CanvasLabel.C_CostLab).text = TransferLabel.CoinSprite + VisitCost;
- }
- }
- public static int visitCost;
- public static int VisitCDTime;
- public static float FancyGardenRate;
- public static float CreateAwardRate;
- public static float FakeGardenRate;
- public static string VisitCostFml;
- public static string AwardMinFml;
- public static string AwardMaxFml;
- #endregion
- public static int MaxTipAmt = 10;
- public static Action OnExitVisteeGarden;
- public static Action OnEnterVisteeGarden;
- public static int MaxStachConfigAmt = 8;
- public static float PullArchiveTime = 0.5f;
- public static float PullConfigTimer;
- public static List<VisitData> UsedDataList = new List<VisitData>();
- public static List<VisitData> UnusedDataList = new List<VisitData>();
- public static bool Inited;
- public static bool InVisit;
- public static bool IsPullConfigComplete;
- public static bool IsBlackMaskTweenComplete;
- public static int VisiteeLevel;
- public static int VisiteeTotalSlot;
- public static int VisiteePraiseAmt;
- public static string VisiteeSerialNumber;
- public static Player VisiteePlayer;
- public static XmlNode VisiteeRootNode;
- public static XmlDocument VisiteeDocument;
- public static List<Slot> VisiteePlantList;
- public static bool PlayerBirdFlag;
- public static bool PlayerTreeFlag;
- public static bool PlayerRainbowFlag;
- public static List<Slot> PlayerPlantList;
- public static List<ElfType> PlayerElfList;
- #endregion
- public void Update()
- {
- if (UnusedDataList.Count > MaxStachConfigAmt)
- {
- return;
- }
- PullConfigTimer += Time.deltaTime;
- if (PullConfigTimer >= PullArchiveTime)
- {
- PullConfigTimer = 0;
- HttpManager.GetRandomConfig
- (
- data =>
- {
- PullConfigCallback(data, null, SavePulledConfig);
- }
- );
- }
- }
- public static void Init()
- {
- XmlAttributeCollection attribute = ConfigManager.GetVisitConfig();
- VisitCostFml = attribute[5].Value;
- VisitCost = Mathf.FloorToInt((float)Auxiliary.FmlParse(VisitCostFml, "l", Manager.GardenLevel.ToString()));
- AwardMinFml = attribute[2].Value;
- AwardMaxFml = attribute[3].Value;
- VisitCDTime = int.Parse(attribute[4].Value);
- FancyGardenRate = float.Parse(attribute[7].Value);
- CreateAwardRate = float.Parse(attribute[1].Value);
- FakeGardenRate = float.Parse(attribute[6].Value);
- #region 倒计时
- if (VisitCDTime != 0)
- {
- Text text = ResourceManager.Get<Text>(CanvasLabel.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 < VisitCDTime - 1; i++)
- {
- delayList.Add(0.5f);
- delayList.Add(0);
- }
- delayList.Add(0.5f);
- for (int i = 0; i < VisitCDTime; 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 = (VisitCDTime - tempInt).ToString();
- AudioManager.PlayClip(AudioLabel.ClickButton);
- }
- );
- actionList.Add(null);
- }
- TweenRoot tween = ResourceManager.Get(CanvasLabel.C_VisitLab).CreateStreamScale
- (
- delayList,
- durationList,
- pairList,
- true,
- false,
- Curve.EaseOutQuad,
- false,
- actionList
- );
- tween.OnForwardFinish += () =>
- {
- AudioManager.PlayClip(AudioLabel.Bubble);
- };
- }
- #endregion
- OnEnterVisteeGarden += () =>
- {
- ResourceManager.SetActive(CanvasLabel.C_OpenCloseRightSidePanelButtons, false);
- ResourceManager.Get<Button>(CanvasLabel.C_OpenSidePanelButton).onClick.Invoke();
- };
- OnExitVisteeGarden += () =>
- {
- ResourceManager.SetActive(CanvasLabel.C_OpenCloseRightSidePanelButtons, true);
- };
- Inited = true;
- }
- public static void OnStartEnterVisiteeGarden()
- {
- ResourceManager.SetActive(CanvasLabel.C_EnterPlazaRoom0, false);
- }
- public static void EnterVisiteeGarden(VisitData visitData)
- {
- IsPullConfigComplete = true;
- VisiteePraiseAmt = int.Parse(visitData.JsonData["p"].ToString());
- if (visitData.JsonData.Inst_Object.ContainsKey("i"))
- {
- VisiteeSerialNumber = visitData.JsonData["i"].ToString();
- }
- VisiteeDocument = visitData.Document;
- SetVisiteeCommentPanel();
- EnterVisiteeGarden();
- OnEnterVisteeGarden.SafeInvoke();
- if (Application.isEditor)
- {
- Debug.Log(VisiteeSerialNumber);
- }
- }
- public static void StartExitVisiteeGarden()
- {
- ResourceManager.Get(CanvasLabel.I_BlackMask).TweenForCG();
- HideTip ();
- ResourceManager.SetActive(CanvasLabel.C_Visit, true);
- ResourceManager.SetActive(CanvasLabel.C_Coin, true);
- ResourceManager.SetActive(CanvasLabel.C_Group1, true);
- ResourceManager.SetActive(CanvasLabel.C_Group2, true);
- ResourceManager.Get<Button>(CanvasLabel.C_NickNameBK).interactable = true;
- ResourceManager.SetActive(CanvasLabel.C_Return, false);
- ResourceManager.SetActive(CanvasLabel.C_Garden, false);
- GardenManager.InMinigameFlag = true;
- #region Garden
- GardenManager.RetriveAllFlower();
- for (int i = 0; i < GardenManager.SlotPageList.Count; i++)
- {
- ResourceManager.Save(GardenManager.SlotPageList[i]);
- }
- GardenManager.SlotPageList = new List<Transform>();
- GardenManager.SlotList = new List<Slot>();
- GardenManager.SlotPageList = new List<Transform>();
- Garden.ResetPage();
- Garden.PagePos = new List<Vector3>();
- int pageAmt = GardenManager.DefaultSlotPage;
- if (GardenManager.TotalSlot >= GardenManager.CriticalSlotIndex)
- {
- pageAmt = (GardenManager.TotalSlot - GardenManager.CriticalSlotIndex) / GardenManager.TotalSlotInOnePage + 3;
- }
- for (int i = 0; i < pageAmt; i++)
- {
- GardenManager.CreatePage();
- }
- for (int i = 0; i < GardenManager.SlotList.Count; i++)
- {
- if (i < GardenManager.TotalSlot)
- {
- 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 (PlayerBirdFlag)
- {
- ResourceManager.Get(GardenLabel.BirdPivot).GetTweenSr().InDestination = true;
- }
- else
- {
- ResourceManager.Get(GardenLabel.BirdPivot).GetTweenSr().InOrigin = true;
- }
- if (PlayerTreeFlag)
- {
- 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 (PlayerRainbowFlag)
- {
- ResourceManager.Get(GardenLabel.GardenRainbow).GetTweenSr().InDestination = true;
- }
- else
- {
- ResourceManager.Get(GardenLabel.GardenRainbow).GetTweenSr().InOrigin = true;
- }
- #endregion
- #region Player
- ResourceManager.Save(PlayerManager.Player);
- ResourceManager.TransformDictionary.Remove(PlayerLabel.Player);
- PlayerManager.Instance.GetPlayer();
- UIManager.SetEnterMinigameGameLabel();
- 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>(PlayerElfList);
- InVisit = false;
- IsPullConfigComplete = false;
- IsBlackMaskTweenComplete = false;
- SetPlayerPraise();
- SetPlayerCommentPanel();
- SetPlayerRankPanel();
- SetPlayerNickName();
- OnExitVisteeGarden.SafeInvoke();
- }
- public static void OnStartExitVisiteeGarden()
- {
- if (Manager.GardenLevel >= TutorialManager.PlazaRoomTutorialLevel)
- {
- ResourceManager.SetActive(CanvasLabel.C_EnterPlazaRoom0, true);
- }
- }
- public static void EnterVisiteeGarden()
- {
- if (!IsPullConfigComplete || !IsBlackMaskTweenComplete)
- {
- return;
- }
- if (ConfigManager.GetConfigVersion(ConfigManager.ConfigDocument) < ConfigManager.GetConfigVersion(VisiteeDocument))
- {
- ShowVisitFailPanelFromSelfGarden();
- return;
- }
- ResourceManager.Get(CanvasLabel.I_BlackMask).TweenForCG();
- //Debug.Log(Document.OuterXml);
- SetVisiteePraise(VisiteeDocument);
- VisiteeRootNode = VisiteeDocument.SelectSingleNode(PlayerConfigLabel.RootNode);
- ResourceManager.SetActive(CanvasLabel.C_Coin, false);
- ResourceManager.SetActive(CanvasLabel.C_Group1, false);
- ResourceManager.SetActive(CanvasLabel.C_Group2, false);
- ResourceManager.Get<Button>(CanvasLabel.C_NickNameBK).interactable = false;
- ResourceManager.SetActive(CanvasLabel.C_Garden, true);
- if (!InVisit)
- {
- GardenManager.RetrieveAllStar();
- GardenManager.RetrieveAllElf();
- IAPManager.RetrieveADChest();
- GardenManager.StarList = new List<Star>();
- }
- if (FriendPanel.FriendAccountDatas.MyContains(data => data.SerialNumber == VisiteeSerialNumber))
- {
- ResourceManager.SetActive(CanvasLabel.C_AddFriendButton, false);
- }
- else
- {
- ResourceManager.SetActive(CanvasLabel.C_AddFriendButton, true);
- }
- ResourceManager.SetActive(CanvasLabel.C_Return, true);
- GardenManager.InMinigameFlag = false;
- #region Bird Tree Rainbow
- if (!InVisit)
- {
- if (ResourceManager.Get(GardenLabel.BirdPivot).gameObject.activeSelf)
- {
- PlayerBirdFlag = true;
- }
- if (ResourceManager.Get(GardenLabel.GardenLeftTree).gameObject.activeSelf)
- {
- PlayerTreeFlag = true;
- }
- if (ResourceManager.Get(GardenLabel.GardenRainbow).gameObject.activeSelf)
- {
- PlayerRainbowFlag = true;
- }
- }
- ResourceManager.SetActive(GardenLabel.BirdPivot, false);
- ResourceManager.SetActive(GardenLabel.GardenLeftTree, false);
- ResourceManager.SetActive(GardenLabel.GardenRightTree, false);
- ResourceManager.SetActive(GardenLabel.GardenRainbow, false);
- #endregion
- #region Ability
- VisiteeTotalSlot = GardenManager.DefaultUnlockSlot;
- VisiteeTotalSlot += ConfigManager.GetIntFormConfig(PlayerConfigLabel.ExtraSlot);
- if (!InVisit)
- {
- PlayerElfList = new List<ElfType>(GardenManager.ElfList);
- }
- GardenManager.ElfList = new List<ElfType>();
- List<XmlAttributeCollection> attributeList = ConfigManager.GetSkillList(VisiteeRootNode);
- for (int i = 0; i < attributeList.Count; i++)
- {
- if (!attributeList[i][0].Value.Contains("Ability"))
- {
- continue;
- }
- if (attributeList[i][0].Value == "Ability1")
- {
- VisiteeLevel = int.Parse(attributeList[i][3].Value);
- ResourceManager.SetText(CanvasLabel.C_GardenLab, Language.GetStr(LanguageLabel.UI__C_GardenLab) + VisiteeLevel);
- 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")
- {
- VisiteeTotalSlot++;
- GardenManager.ElfList.Add(ElfType.Bee_Purple);
- }
- else if (attributeList[i][0].Value == "Ability7")
- {
- VisiteeTotalSlot++;
- GardenManager.ElfList.Add(ElfType.Bee_Blue);
- }
- else if (attributeList[i][0].Value == "Ability8")
- {
- VisiteeTotalSlot++;
- GardenManager.ElfList.Add(ElfType.Bee_Red);
- }
- else if (attributeList[i][0].Value == "Ability9")
- {
- VisiteeTotalSlot++;
- GardenManager.ElfList.Add(ElfType.Bee_White);
- }
- else if (attributeList[i][0].Value == "Ability10")
- {
- VisiteeTotalSlot++;
- GardenManager.ElfList.Add(ElfType.Butterfly_Yellow);
- }
- else if (attributeList[i][0].Value == "Ability11")
- {
- VisiteeTotalSlot++;
- GardenManager.ElfList.Add(ElfType.Butterfly_Purple);
- }
- else if (attributeList[i][0].Value == "Ability12")
- {
- VisiteeTotalSlot++;
- GardenManager.ElfList.Add(ElfType.Butterfly_Blue);
- }
- else if (attributeList[i][0].Value == "Ability13")
- {
- VisiteeTotalSlot++;
- GardenManager.ElfList.Add(ElfType.Butterfly_Red);
- }
- else if (attributeList[i][0].Value == "Ability14")
- {
- VisiteeTotalSlot++;
- GardenManager.ElfList.Add(ElfType.Butterfly_White);
- }
- else if (attributeList[i][0].Value == "Ability15")
- {
- VisiteeTotalSlot++;
- GardenManager.ElfList.Add(ElfType.Dragonfly_Yellow);
- }
- else if (attributeList[i][0].Value == "Ability16")
- {
- VisiteeTotalSlot++;
- GardenManager.ElfList.Add(ElfType.Dragonfly_Purple);
- }
- else if (attributeList[i][0].Value == "Ability17")
- {
- VisiteeTotalSlot++;
- GardenManager.ElfList.Add(ElfType.Dragonfly_Blue);
- }
- else if (attributeList[i][0].Value == "Ability18")
- {
- VisiteeTotalSlot++;
- GardenManager.ElfList.Add(ElfType.Dragonfly_Red);
- }
- else if (attributeList[i][0].Value == "Ability19")
- {
- VisiteeTotalSlot++;
- GardenManager.ElfList.Add(ElfType.Dragonfly_White);
- }
- else if (attributeList[i][0].Value == "Ability20")
- {
- VisiteeTotalSlot++;
- GardenManager.ElfList.Add(ElfType.Beetle_Yellow);
- }
- else if (attributeList[i][0].Value == "Ability21")
- {
- VisiteeTotalSlot++;
- GardenManager.ElfList.Add(ElfType.Beetle_Purple);
- }
- else if (attributeList[i][0].Value == "Ability22")
- {
- VisiteeTotalSlot++;
- GardenManager.ElfList.Add(ElfType.Beetle_Blue);
- }
- else if (attributeList[i][0].Value == "Ability23")
- {
- VisiteeTotalSlot++;
- GardenManager.ElfList.Add(ElfType.Beetle_Red);
- }
- else if (attributeList[i][0].Value == "Ability24")
- {
- VisiteeTotalSlot++;
- GardenManager.ElfList.Add(ElfType.Beetle_White);
- }
- }
-
- #endregion
- #region Garden
- if (!InVisit)
- {
- PlayerPlantList = new List<Slot>(GardenManager.PlantSlotList);
- ConfigManager.SaveDress();
- ConfigManager.SavePlantList();
- }
- GardenManager.RetriveAllFlower();
- for (int i = 0; i < GardenManager.SlotPageList.Count; i++)
- {
- ResourceManager.Save(GardenManager.SlotPageList[i]);
- }
- GardenManager.SlotPageList = new List<Transform>();
- GardenManager.SlotList = new List<Slot>();
- GardenManager.SlotPageList = new List<Transform>();
- Garden.ResetPage();
- Garden.PagePos = new List<Vector3>();
- int pageAmt = GardenManager.DefaultSlotPage;
- if (VisiteeTotalSlot >= GardenManager.CriticalSlotIndex)
- {
- pageAmt = (VisiteeTotalSlot - GardenManager.CriticalSlotIndex) / GardenManager.TotalSlotInOnePage + 3;
- }
- for (int i = 0; i < pageAmt; i++)
- {
- GardenManager.CreatePage();
- }
-
- for (int i = 0; i < GardenManager.SlotList.Count; i++)
- {
- if (i < VisiteeTotalSlot)
- {
- 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(VisiteeRootNode);
- for (int i = 0; i < plantList.Count; i++)
- {
- GardenManager.PlantFlower(plantList[i].Key, plantList[i].Value);
- }
- #endregion
- #region Player
- ResourceManager.Save(PlayerManager.Player);
- ResourceManager.TransformDictionary.Remove(PlayerLabel.Player);
- VisiteePlayer = PlayerManager.Instance.GetPlayer(VisiteeRootNode);
- VisiteePlayer.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) <= CreateAwardRate)
- {
- if (GardenManager.PlantSlotList.Count > 0)
- {
- GardenManager.PlantSlotList.Random()[0].PlantFlower.HaveAward = true;
- }
- }
- #endregion
- ShowTip();
- XmlNode nicknameNode = VisiteeDocument.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 ShowVisitFailPanelFromSelfGarden()
- {
- Bubble.Show
- (
- Language.GetStr(LanguageLabel.UI__C_VisitFail),
- null,
- null,
- null,
- () =>
- {
- ResourceManager.Get(CanvasLabel.I_BlackMask).TweenForCG();
- if (InVisit)
- {
- ResourceManager.SetActive(CanvasLabel.C_Return, true);
- }
- else
- {
- OnStartExitVisiteeGarden();
- }
- },
- null,
- false
- );
- Manager.AddCoin(VisitCost, StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.VisitRefund);
- }
- public static void SetPlayerRankPanel()
- {
- SocialManager.RecoverRankPanel();
- }
- public static void SetPlayerPraise()
- {
- SocialManager.PraiseText.text = HttpManager.PraiseAmt.ToString();
- SocialManager.PraiseButton.interactable = false;
- SocialManager.PraiseButton.image.color = Color.white;
- SocialManager.PraiseText.color =Lib.PraiseTextBlue;
- }
- public static void SetVisiteePraise(XmlDocument document)
- {
- SocialManager.PraiseText.text = VisiteePraiseAmt.ToString();
- //Debug.Log(VisiteeSerialNumber);
- HttpManager.CheckIsPraised
- (
- 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.OpenCommentFlag)
- {
- SocialManager.RecoverCommentPanel();
- }
- else
- {
- //ManaSocial.UpdatePage(true);
- }
- }
- public static void SetVisiteeCommentPanel()
- {
- SocialManager.ClearCommentPanel();
- //ManaSocial.UpdatePage(false);
- }
- public static void SetPlayerNickName()
- {
- ResourceManager.SetText(CanvasLabel.C_NickNameLab, NickNameManager.NickName);
- }
- public static void SetVisiteeNickName(string nickname)
- {
- ResourceManager.SetText(CanvasLabel.C_NickNameLab, nickname);
- }
- public static void UpdateVisitCost()
- {
- if (Inited)
- {
- VisitCost = Mathf.FloorToInt((float)Auxiliary.FmlParse(VisitCostFml, "l", Manager.GardenLevel.ToString()));
- }
- }
- public static void ReverseConfigData()
- {
- if (InVisit)
- {
- VisiteePlantList = new List<Slot>(GardenManager.PlantSlotList);
- GardenManager.PlantSlotList = PlayerPlantList;
- }
- }
- public static void RecoverConfigData()
- {
- if (InVisit)
- {
- GardenManager.PlantSlotList = VisiteePlantList;
- }
- }
- public static void ShowTip()
- {
- ResourceManager.SetActive (CanvasLabel.C_Tip, true);
- HudTarget hudTarget = ResourceManager.Get(CanvasLabel.C_Tip).GetComponent<HudTarget>();
- hudTarget.PosTra = VisiteePlayer.ChildDic[PlayerLabel.EnterGameTra];
- string languageID = LanguageLabel.Tip + Random.Range(1, MaxTipAmt);
- ResourceManager.Get<Text> (CanvasLabel.C_TipLab).text = Language.GetStr (LanguageLabel.CombineLanguageLabel(LanguageLabel.Tip, languageID));
- }
- public static void HideTip()
- {
- ResourceManager.SetActive (CanvasLabel.C_Tip, false);
- }
- public static void Visit(ConfigSource configSource, string info = null)
- {
- if (Manager.SceneSwitchFlag)
- {
- return;
- }
- OnStartEnterVisiteeGarden();
- Manager.Pay
- (
- "",
- VisitCost,
- Current.Coin,
- () =>
- {
- ResourceManager.Get(CanvasLabel.I_BlackMask).GetTweenCG().Duration = 0.5f;
- IsPullConfigComplete = false;
- IsBlackMaskTweenComplete = false;
- PullConfig(configSource, info);
- AudioManager.PlayClip(AudioLabel.Bubble);
- ResourceManager.SetActive(CanvasLabel.C_Return, false);
- TweenRoot tween;
- if (VisitCDTime != 0)
- {
- ResourceManager.Get<Button>(CanvasLabel.C_Visit).interactable = false;
- tween = ResourceManager.Get(CanvasLabel.C_VisitLab).StreamReForScale();
- tween.AddEventOnetime
- (
- EventType.ForwardFinish,
- () =>
- {
- ResourceManager.Get<Button>(CanvasLabel.C_Visit).interactable = true;
- }
- );
- }
- tween = ResourceManager.Get(CanvasLabel.I_BlackMask).TweenBacCG();
- tween.AddEventOnetime
- (
- EventType.BackwardFinish,
- () =>
- {
- IsBlackMaskTweenComplete = true;
- EnterVisiteeGarden();
- }
- );
- },
- StaticsManager.ItemID.参观花费,
- StaticsManager.ConsumeModule.Shop,
- false
- );
- }
- public static void PullConfig(ConfigSource configSource, string info = null)
- {
- if (configSource == ConfigSource.SerialNumber)
- {
- HttpManager.GetTargetConfig
- (
- info,
- data =>
- {
- VisiteeSerialNumber = info;
- PullConfigCallback
- (
- data,
- ShowVisitFailPanelFromSelfGarden,
- (jData) =>
- {
- //Debug.Log(jData.ToJson());
- XmlDocument document = new XmlDocument();
- document.LoadXml(data["l"].ToString());
- EnterVisiteeGarden(new VisitData(jData, document));
- }
- );
- }
- );
- }
- else if (configSource == ConfigSource.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
- {
- ShowVisitFailPanelFromSelfGarden();
- }
- }
- }
- public static void PullConfigCallback(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 SavePulledConfig(JsonData jsonData)
- {
- //Debug.Log(jsonData.ToJson());
- XmlDocument document = new XmlDocument();
- document.LoadXml(jsonData["l"].ToString());
- if (ConfigManager.GetGardenLevel(document) == 0)
- {
- return;
- }
- 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 string CreateFakeConfig()
- {
- 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.SkillDictionary[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) < FancyGardenRate; //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.CloseItemDictionary[Random.Range(2, (int)Mathf.Lerp(2, 30, newLevel / 449f) + 1)].ArmatureName;
- xmlNode.Attributes[1].Value = PlayerManager.CloseItemDictionary[Random.Range(201, (int)Mathf.Lerp(201, 217, newLevel / 449f) + 1)].ArmatureName;
- xmlNode.Attributes[2].Value = PlayerManager.CloseItemDictionary[Random.Range(401, (int)Mathf.Lerp(401, 415, newLevel / 449f) + 1)].ArmatureName;
- xmlNode.Attributes[3].Value = PlayerManager.CloseItemDictionary[Random.Range(601, (int)Mathf.Lerp(601, 612, newLevel / 449f) + 1)].ArmatureName;
- xmlNode.Attributes[4].Value = PlayerManager.CloseItemDictionary[Random.Range(801, (int)Mathf.Lerp(801, 817, newLevel / 449f) + 1)].ArmatureName;
- xmlNode.Attributes[7].Value = PlayerManager.CloseItemDictionary[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;
- }
- }
|