using UnityEngine; using UnityEngine.UI; using UnityEngine.Events; using UnityEngine.EventSystems; using System; using System.Xml; using System.Linq; using System.Collections; using System.Collections.Generic; using Random = UnityEngine.Random; public class GardenLabel { public static string GardenBK2 = "GardenBK2"; public static string GardenBK3 = "GardenBK3"; public static string GardenBK4 = "GardenBK4"; public static string BK2RightPos = "BK2RightPos"; public static string BK2LeftPos = "BK2LeftPos"; public static string BK3RightPos = "BK3RightPos"; public static string BK3LeftPos = "BK3LeftPos"; public static string BK4RightPos = "BK4RightPos"; public static string BK4LeftPos = "BK4LeftPos"; public static string MinigameLeftPos = "MinigameLeftPos"; public static string GardenCloud1 = "GardenCloud1"; public static string GardenCloud2 = "GardenCloud2"; public static string GardenCloud3 = "GardenCloud3"; public static string BirdPivot = "BirdPivot"; public static string GardenLeftTree = "GardenLeftTree"; public static string GardenRightTree = "GardenRightTree"; public static string GardenRainbow = "GardenRainbow"; public static string Minigame = "Minigame"; public static string SlotPage = "SlotPage"; public static string GardenPivot = "GardenPivot"; public static string GardenPlayerPos = "GardenPlayerPos"; public static string Minigame_DropAward_LeftBorder = "Minigame_DropAward_LeftBorder"; public static string FindMinigame_DropAward_RightBorder = "FindMinigame_DropAward_RightBorder"; public static string MemoryMinigame_DropAward_RightBorder = "MemoryMinigame_DropAward_RightBorder"; public static string MinigameSlot1 = "MinigameSlot1"; public static string MinigameSlot2 = "MinigameSlot2"; public static string MinigameSlot3 = "MinigameSlot3"; public static string MinigameSlot4 = "MinigameSlot4"; public static string MinigameSlot5 = "MinigameSlot5"; public static string MinigameSlot6 = "MinigameSlot6"; public static string MinigameSlot7 = "MinigameSlot7"; public static string MinigameSlot8 = "MinigameSlot8"; public static string MinigameSlot9 = "MinigameSlot9"; } public enum ElfType { Bee_Red, Bee_Blue, Bee_White, Bee_Purple, Bee_Yellow, Beetle_Red, Beetle_Blue, Beetle_White, Beetle_Purple, Beetle_Yellow, Butterfly_Red, Butterfly_Blue, Butterfly_White, Butterfly_Purple, Butterfly_Yellow, Dragonfly_Red, Dragonfly_Blue, Dragonfly_White, Dragonfly_Purple, Dragonfly_Yellow, } public class GardenManager : Regist { #region Config public static int TotalSlot { get { return totalSlot; } set { totalSlot = value; ResourceManager.SetText(CanvasLabel.G_CollectLab2, string.Format("{0}/{1}", totalSlot, TotalSlotPage * TotalSlotInOnePage)); } } public static int totalSlot; public static int TotalSlotPage { get { return SlotPageList.Count; } } public static int TotalUnlockFlower { get { return totalUnlockFlower; } set { totalUnlockFlower = value; AchieveManager.UpdateStatus(AchieveType.UnlockFlowerAmt, totalUnlockFlower); ResourceManager.SetText(CanvasLabel.F_FlowerLab, string.Format("{0}", TotalUnlockFlower)); ResourceManager.SetText(CanvasLabel.G_CollectLab1, string.Format("{0}/{1}", TotalUnlockFlower, TotalFlower)); if (totalUnlockFlower >= TutorialManager.MinFlowerForFindSoloGame && Manager.GardenLevel >= TutorialManager.FindSoloMinigameTutorialLevel) { if (TutorialManager.findSoloMinigameTutorial) { TutorialManager.PlayFindSoloGame(); } } if (totalUnlockFlower >= TutorialManager.MinFlowerForFindMissingGame && Manager.GardenLevel >= TutorialManager.FindMissingMinigameTutorialLevel) { if (TutorialManager.findMissingMinigameTutorial) { TutorialManager.PlayFindMissingGame(); } } } } private static int totalUnlockFlower; public static int TotalUnlockSpecialFlower { get { return totalUnlockSpecialFlower; } set { totalUnlockSpecialFlower = value; TotalUnlockFlower = totalUnlockSpecialFlower + totalUnlockNormalFlower; } } private static int totalUnlockSpecialFlower; public static int TotalUnlockNormalFlower { get { return totalUnlockNormalFlower; } set { totalUnlockNormalFlower = value; TotalUnlockFlower = totalUnlockSpecialFlower + totalUnlockNormalFlower; } } private static int totalUnlockNormalFlower; public static int TotalFlower; public static int TotalSpecialFlower { get { return totalSpecialFlower; } set { totalSpecialFlower = value; TotalFlower = totalSpecialFlower + totalNormalFlower; } } private static int totalSpecialFlower; public static int TotalNormalFlower { get { return totalNormalFlower; } set { totalNormalFlower = value; TotalFlower = totalSpecialFlower + totalNormalFlower; } } private static int totalNormalFlower; public static int FirstUnlockFlowerID { get { foreach (var kv in FlowerInfoDictionary) { if (!kv.Value.Unlock) { return kv.Key; } } return -1; } } public static List UnlockedFlowerIDList { get { List unlockedFlowerIDList = new List(); foreach (var kv in FlowerInfoDictionary) { if (kv.Value.Unlock) { unlockedFlowerIDList.Add(kv.Key); } } return unlockedFlowerIDList; } } public static int DefaultUnlockSlot = 1; public static bool InMinigameFlag = true; public static float MinCreateElfTime = 5; public static float MaxCreateElfTime = 30; public static float CreateElfTimer; public static float MinCreateStarTime; public static float MaxCreateStarTime; public static float CreateStarTimer; public static float MinCreateAwardTime = 5; public static float MaxCreateAwardTime = 15; public static float CreateAwardTimer; public static Text BuyFlowerButtonText; public static Text RetrieveFlowerButtonText; public static Button BuyFlowerButton; public static Button RetrieveFlowerButton; public static FlowerInfo SelectFlowerInfo; public static TweenMatFloat FlowerCardMaterialTween; public static GardenManager Instance; public static List SlotList = new List(); public static List PlantSlotList = new List(); public static List StarList = new List(); public static List ElfList = new List(); public static List SlotPageList = new List(); public static Dictionary FlowerInfoDictionary = new Dictionary(); public static int DefaultSlotPage = 2; public static int CriticalSlotIndex = 7; public static int TotalSlotInOnePage = 9; public static int LeftTopSlotIndex = 0; public static int RightTopSlotIndex = 3; public static int RightDownSlotIndex = 8; public static int LeftDownSlotIndex = 4; #endregion public void Update() { if (TutorialManager.NewplayerTutorial || Player.InDressRoom || SFSManager.GardenSmartFox.PlazaRoomController.JoinedPlazaRoom) { return; } CreateElfThread(); CreateStarThread(); CreateAwardThread(); } public void CreateElfThread() { if (!InMinigameFlag) { return; } CreateElfTimer -= Time.deltaTime; if (CreateElfTimer < 0) { CreateElfTimer = Random.Range(MinCreateElfTime, MaxCreateElfTime); if (ElfList.Count > 0 && PlantSlotList.Count > 0) { PlantSlotList.Random()[0].PlantFlower.GetElf(ElfList.Random()[0]); } } } public void CreateStarThread() { if (InMinigameFlag && !Manager.MinigameFlag && !VisitManager.InVisit) { CreateStarTimer -= Time.deltaTime; if (CreateStarTimer < 0) { CreateStarTimer = Mathf.Lerp(MinCreateStarTime, MaxCreateStarTime, Random.Range(0f, 1f)); StarList.Add(ResourceManager.GetStar()); } } } public void CreateAwardThread() { if (InMinigameFlag) { CreateAwardTimer -= Time.deltaTime; if (CreateAwardTimer <= 0) { CreateAwardTimer = Random.Range(MinCreateAwardTime, MaxCreateAwardTime); List spareList = new List(); for (int i = 0; i < PlantSlotList.Count; i++) { if (PlantSlotList[i].PlantFlower.HaveAward == false) { spareList.Add(PlantSlotList[i].PlantFlower); } } if (spareList.Count > 0) { spareList.Random()[0].HaveAward = true; } } } } public override void InstantiatePrefabs() { ResourceManager.Get(ResourceLabel.Garden, Folder.Scene, true, transform, true, ObjType.Garden).AddScript(); for (int i = 0; i < DefaultSlotPage; i++) { CreatePage(); } #region 生成FlowerItem List attributeList = ConfigManager.GetFlowerConfig(); //attributeList.AddRange(Bundle.NewFlowerConfigs); for (int i = 0; i < attributeList.Count; i++) { FlowerInfo flowerInfo = new FlowerInfo(attributeList[i]); if (flowerInfo.IsSpecial) { TotalSpecialFlower++; } else { TotalNormalFlower++; } FlowerInfoDictionary.Add(flowerInfo.ID, flowerInfo); } #endregion } public override void FirstInit() { Instance = this; CreateElfTimer = Random.Range(MinCreateElfTime, MaxCreateElfTime); CreateAwardTimer = Random.Range(MinCreateAwardTime, MaxCreateAwardTime); UnlockSlot(); for (int i = 0; i < ConfigManager.GetIntFormConfig(PlayerConfigLabel.ExtraSlot); i++) { UnlockSlot(); } #region 读花朵存档 List flowerIDList = ConfigManager.GetFlowerList(); for (int i = 0; i < flowerIDList.Count; i++) { FlowerInfoDictionary[flowerIDList[i]].Unlock = true; } List flowerAmountList = ConfigManager.GetIntList(' ', PlayerConfigLabel.FlowerAmtList, null); for (int i = 0; i < flowerAmountList.Count; i++) { FlowerInfoDictionary[flowerIDList[i]].Amount = flowerAmountList[i]; } List> plantList = ConfigManager.GetPlantList(); for (int i = 0; i < plantList.Count; i++) { PlantFlower(plantList[i].Key, plantList[i].Value); } #endregion } public override void RegistReference() { RetrieveFlowerButton = ResourceManager.Get