using LitJson; using UnityEngine; using UnityEngine.UI; using UnityEngine.Events; using UnityEngine.Analytics; using UnityEngine.EventSystems; using System; using System.Xml; using System.Collections; using System.Collections.Generic; public class Manager : Regist { #region Config #region 成就 public static double PlayADsAmt { get { return playADsAmt; } set { playADsAmt = value; AchieveManager.UpdateStatus(AchieveType.PlayADsAmt, playADsAmt); } } private static double playADsAmt; public static double UseSkillAmt { get { return useSkillAmt; } set { useSkillAmt = value; AchieveManager.UpdateStatus(AchieveType.UseSkillAmt, useSkillAmt); } } private static double useSkillAmt; public static double SignAmt { get { return signAmt; } set { signAmt = value; AchieveManager.UpdateStatus(AchieveType.SignAmt, signAmt); } } private static double signAmt; public static double CloseAmt { get { return closeAmt; } set { closeAmt = value; AchieveManager.UpdateStatus(AchieveType.CloseAmt, closeAmt); } } private static double closeAmt; public static double ShareAmt { get { return shareAmt; } set { shareAmt = value; AchieveManager.UpdateStatus(AchieveType.ShareAmt, shareAmt); } } private static double shareAmt; public static double PlayMinigameAmt { get { return playMinigameAmt; } set { playMinigameAmt = value; AchieveManager.UpdateStatus(AchieveType.PlayMinigameAmt, playMinigameAmt); } } private static double playMinigameAmt; public static double AllElfLevel { get { return allElfLevel; } set { allElfLevel = value; AchieveManager.UpdateStatus(AchieveType.AllElfLevel, allElfLevel); } } private static double allElfLevel; public static double TotalCoin { get { return totalCoin; } set { totalCoin = value; AchieveManager.UpdateStatus(AchieveType.TotalCoin, totalCoin); } } private static double totalCoin; public static double TotalFlowerAwardCoin { get { return totalFlowerAwardCoin; } set { totalFlowerAwardCoin = value; AchieveManager.UpdateStatus(AchieveType.TotalFlowerAwardCoin, totalFlowerAwardCoin); } } private static double totalFlowerAwardCoin; public static double TotalVisitPerson { get { return totalVisitPerson; } set { totalVisitPerson = value; AchieveManager.UpdateStatus(AchieveType.TotalVisitPerson, totalVisitPerson); } } private static double totalVisitPerson; public static double TotalSpendDiamond { get { return totalSpendDiamond; } set { totalSpendDiamond = value; AchieveManager.UpdateStatus(AchieveType.TotalSpendDiamond, totalSpendDiamond); } } private static double totalSpendDiamond; public static double CreateRoomAmt { get { return createRoomAmt; } set { createRoomAmt = value; AchieveManager.UpdateStatus(AchieveType.CreateRoomAmt, createRoomAmt); } } private static double createRoomAmt; public static double CreateChestAmt { get { return createChestAmt; } set { createChestAmt = value; AchieveManager.UpdateStatus(AchieveType.CreateChestAmt, createChestAmt); } } private static double createChestAmt; public static double CreateLuckyChestAmt { get { return createLuckyChestAmt; } set { createLuckyChestAmt = value; AchieveManager.UpdateStatus(AchieveType.CreateLuckyChestAmt, createLuckyChestAmt); } } private static double createLuckyChestAmt; public static double CreateGuessColorChestAmt { get { return createGuessColorChestAmt; } set { createGuessColorChestAmt = value; AchieveManager.UpdateStatus(AchieveType.CreateGuessColorChestAmt, createGuessColorChestAmt); } } private static double createGuessColorChestAmt; public static double CreateGuessNumberChestAmt { get { return createGuessNumberChestAmt; } set { createGuessNumberChestAmt = value; AchieveManager.UpdateStatus(AchieveType.CreateGuessNumberChestAmt, createGuessNumberChestAmt); } } private static double createGuessNumberChestAmt; public static double GetChestAwardAmt { get { return getChestAwardAmt; } set { getChestAwardAmt = value; AchieveManager.UpdateStatus(AchieveType.GetChestAwardAmt, getChestAwardAmt); } } private static double getChestAwardAmt; #endregion public static Action OnLevelChange; public static Action OnCoinChange; public static Action OnDiamondChange; public static int GardenLevel { get { return gardenLevel; } set { gardenLevel = value; if (!Inited) { return; } LanguageManager.Add(ResourceManager.Get(CanvasLabel.C_LevelText), new MulLanStr(LanguageLabel.UI__C_Level), gardenLevel.ToString()); VisitManager.UpdateVisitCost(); AchieveManager.UpdateStatus(AchieveType.GardenLevel, gardenLevel); for (int i = 0; i < SkillList.Count; i++) { SkillList[i].UpdateStatus(); } foreach (var kv in PlayerManager.CloseItemDictionary) { kv.Value.OnLevelChange(); } if (OnLevelChange != null) { OnLevelChange.Invoke(gardenLevel); } if (gardenLevel >= TutorialManager.MemoryMinigameTutorialLevel) { if (TutorialManager.memoryMinigameTutorial) { TutorialManager.MemoryMinigameTutorial = true; } } if (GardenLevel < TutorialManager.DressroomTutorialLevel) { ResourceManager.Get(CanvasLabel.C_DressRoom).material = Lib.GrayMat; } else { ResourceManager.Get(CanvasLabel.C_DressRoom).material = null; } if (GardenManager.TotalUnlockFlower >= TutorialManager.MinFlowerForFindSoloGame && gardenLevel >= TutorialManager.FindSoloMinigameTutorialLevel) { if (TutorialManager.findSoloMinigameTutorial) { TutorialManager.PlayFindSoloGame(); } } if (GardenManager.TotalUnlockFlower >= TutorialManager.MinFlowerForFindMissingGame && gardenLevel >= TutorialManager.FindMissingMinigameTutorialLevel) { if (TutorialManager.findMissingMinigameTutorial) { TutorialManager.PlayFindMissingGame(); } } if (gardenLevel >= TutorialManager.CommentTutorialLevel) { ResourceManager.Get(CanvasLabel.C_CommentParent).TweenForCG(); } if (gardenLevel >= TutorialManager.VisitTutorialLevel) { if (TutorialManager.visitTutorial) { TutorialManager.ClickVisitBtn(); return; } else { ResourceManager.SetActive(CanvasLabel.C_Visit, true); } } if (gardenLevel >= TutorialManager.DressroomTutorialLevel) { if (TutorialManager.dressroomTutorial) { TutorialManager.ClickDressroomButton(); return; } } if (gardenLevel >= TutorialManager.PlazaRoomTutorialLevel) { if (TutorialManager.plazaRoomTutorial) { TutorialManager.ClickPlazaRoomBtn(); return; } else { ResourceManager.SetActive(CanvasLabel.C_EnterPlazaRoom, true); ResourceManager.SetActive(CanvasLabel.C_EnterPlazaRoom0, true); } } } } private static int gardenLevel; public static float Person { get { return person; } set { person = value; ResourceManager.SetText(CanvasLabel.F_PersonLab, Auxiliary.ShrinkBigNumberStr(CurrentPerson*60)); } } private static float person; public static List ExtraPersonSourceSpritesName = new List(); public static float CoinPerson { get { return coinPerson; } set { coinPerson = value; ResourceManager.SetText(CanvasLabel.F_CoinPersonLab, Auxiliary.ShrinkBigNumberStr(CurrentCoinPerson)); } } private static float coinPerson; public static List ExtraCoinPersonSourceSpritesName = new List(); public static float SkillPerson { get { return skillPerson; } set { skillPerson = value; //TweenOutline tween = ResourceManager.Get(CanvasLabel.F_PersonLab).GetTweenOutline(); //if (skillPerson.Equal(0)) //{ // tween.Pause(); // tween.Target.enabled = false; //} //else //{ // if (tween.InPause) // { // tween.Resume(); // tween.Target.enabled = true; // } // else // { // tween.StartForward(); // } //} Person = Person; } } public static float skillPerson; public static float TempSkillPerson { get { return tempSkillPerson; } set { tempSkillPerson = value; TweenOutline tween = ResourceManager.Get(CanvasLabel.F_PersonLab).GetTweenOutline(); if (tempSkillPerson.Equal(0) && tempSkillPersonBuff.Equal(0)) { tween.Pause(); tween.Target.enabled = false; } else { if (tween.InPause) { tween.Resume(); tween.Target.enabled = true; } else { tween.StartForward(); } } Person = Person; } } public static float tempSkillPerson; public static float SkillPersonBuff { get { return skillPersonBuff; } set { skillPersonBuff = value; Person = Person; } } public static float skillPersonBuff; public static float TempSkillPersonBuff { get { return tempSkillPersonBuff; } set { tempSkillPersonBuff = value; TweenOutline tween = ResourceManager.Get(CanvasLabel.F_PersonLab).GetTweenOutline(); if (tempSkillPerson.Equal(0) && tempSkillPersonBuff.Equal(0)) { tween.Pause(); tween.Target.enabled = false; } else { if (tween.InPause) { tween.Resume(); tween.Target.enabled = true; } else { tween.StartForward(); } } Person = Person; } } public static float tempSkillPersonBuff; public static float SkillCoinPerson { get { return skillCoinPerson; } set { skillCoinPerson = value; CoinPerson = CoinPerson; } } public static float skillCoinPerson; public static float TempSkillCoinPerson { get { return tempSkillCoinPerson; } set { tempSkillCoinPerson = value; TweenOutline tween = ResourceManager.Get(CanvasLabel.F_CoinPersonLab).GetTweenOutline(); if (tempSkillCoinPerson.Equal(0) && tempSkillCoinPersonBuff.Equal(0)) { tween.Pause(); tween.Target.enabled = false; } else { if (tween.InPause) { tween.Resume(); tween.Target.enabled = true; } else { tween.StartForward(); } } CoinPerson = CoinPerson; } } public static float tempSkillCoinPerson; public static float SkillCoinPersonBuff { get { return skillCoinPersonBuff; } set { skillCoinPersonBuff = value; CoinPerson = CoinPerson; } } public static float skillCoinPersonBuff; public static float TempSkillCoinPersonBuff { get { return tempSkillCoinPersonBuff; } set { tempSkillCoinPersonBuff = value; TweenOutline tween = ResourceManager.Get(CanvasLabel.F_CoinPersonLab).GetTweenOutline(); if (tempSkillCoinPersonBuff.Equal(0) && tempSkillCoinPerson.Equal(0)) { tween.Pause(); tween.Target.enabled = false; } else { if (tween.InPause) { tween.Resume(); tween.Target.enabled = true; } else { tween.StartForward(); } } CoinPerson = CoinPerson; } } public static float tempSkillCoinPersonBuff; public static float IncomeBuff { get { return SkillCoinPersonBuff + FlowerPlus; } } public static float FlowerPlus { get { return flowerPlus; } set { flowerPlus = value; } } public static float flowerPlus; public static float CurrentPerson { get { //Debug.Log(Person * (1 + SkillPersonBuff + TempSkillPersonBuff) + SkillPerson + TempSkillPerson); return Person*(1 + SkillPersonBuff + TempSkillPersonBuff) + SkillPerson + TempSkillPerson; } } public static float CurrentCoinPerson { get { //Debug.Log(CoinPerson * (1 + SkillCoinPersonBuff + TempSkillCoinPersonBuff) + SkillCoinPerson + TempSkillCoinPerson); return CoinPerson*(1 + SkillCoinPersonBuff + TempSkillCoinPersonBuff) + SkillCoinPerson + TempSkillCoinPerson; } } public static double Coin { get { return coin; } set { coin = value; ResourceManager.SetText(CanvasLabel.F_CoinLab, Auxiliary.ShrinkBigNumberStr(coin)); ResourceManager.SetText(CanvasLabel.C_CoinLab, Auxiliary.ShrinkBigNumberStr(coin)); ResourceManager.SetText(CanvasLabel.P_CoinLab, Auxiliary.ShrinkBigNumberStr(coin)); AchieveManager.UpdateStatus(AchieveType.CurrentCoin, coin); OnCoinChange.SafeInvoke(coin); } } public static double coin; public static double Diamond { get { return diamond; } set { diamond = value; ResourceManager.SetText(CanvasLabel.F_DiamondLab, Auxiliary.ShrinkBigNumberStr(diamond)); ResourceManager.SetText(CanvasLabel.P_DiamondLab, Auxiliary.ShrinkBigNumberStr(diamond)); OnDiamondChange.SafeInvoke(diamond); } } public static double diamond; public static bool MinigameFlag; public static bool UploadConfigFlag; public static bool LoginFlag; public static bool ReactiveFlag; public static bool DownloadConfigFlag; public static bool SceneSwitchFlag; public static bool Inited; public static bool IsFirstFrame = true; public static bool InBackground; public static float IncomeDisplayTime = 60f; public static float IncomeCircleTime = 10; public static float IncomeCircleTimer; public static float CircleIncome { get { return CurrentPerson * IncomeCircleTime * CurrentCoinPerson * (1 + FlowerPlus); } } public static float GameBeginTime; public static bool AlreadyGetOfflineIncome; public static bool OfflineFlag; public static float OfflineTime; public static string OfflineIncomeFml; public static double OfflineMaxCoin; public static double OfflineMaxTime; public static double OfflineMinTime = 120; public static float InputDetectTime = 60f; public static float InputDetectTimer; public static float LoginTime = 10f; public static float LoginTimer; public static float MinigameCDTimer; public static float UploadConfigTime = 60f; public static float UploadConfigTimer; public static Manager Instance; public static DateTime LastQuitTime; public static List UsingSkillList = new List(); public static List CoolSkillList = new List(); public static List OfflineCoolSkillList = new List(); public static List> OfflineUsingSkillList = new List>(); public static List SkillList = new List(); public static Dictionary SkillDictionary = new Dictionary(); #endregion private void Update() { LoginThread(); if (TutorialManager.NewplayerTutorial) { return; } InputDetectThread(); ProcessSkillThread(); MinigameCDThread(); UploadConfigThread(); IncomeCircleThread(); } private void InputDetectThread() { //if (VisitManager.InVisit) //{ // return; //} if (Auxiliary.AnyKeyUp) { InputDetectTimer = 0; ResourceManager.Get(CanvasLabel.C_Group).TweenForCG(); } else { InputDetectTimer += Time.deltaTime; if (InputDetectTimer >= InputDetectTime) { InputDetectTimer = 0; ResourceManager.Get(CanvasLabel.C_Group).TweenBacCG(); } } } private void ProcessSkillThread() { for (int i = 0; i < UsingSkillList.Count; i++) { if (UsingSkillList[i].DoUpdate()) { UsingSkillList.RemoveAt(i--); } } for (int i = 0; i < CoolSkillList.Count; i++) { if (CoolSkillList[i].DoCD()) { CoolSkillList.RemoveAt(i--); } } } private void MinigameCDThread() { if (!MinigameFlag) { MinigameCDTimer -= Time.deltaTime; ResourceManager.SetText(CanvasLabel.C_MiniGameLab, Mathf.CeilToInt(MinigameCDTimer).ToString()); if (MinigameCDTimer < 0) { MinigameFlag = true; ResourceManager.Get(CanvasLabel.C_MiniGame).TweenBacRect(); ResourceManager.SetText(CanvasLabel.C_MiniGameLab, ""); StaticsManager.GetInstance().RewardItem(StaticsManager.ItemID.获得小游戏, StaticsManager.ItemType.小游戏, "1", StaticsManager.ConsumeModule.None); } } } private void UploadConfigThread() { if (DownloadConfigFlag) { return; } UploadConfigTimer += Time.deltaTime; if (UploadConfigTimer >= UploadConfigTime) { UploadConfigTimer = 0; if (!PlayerPrefManager.GetBool(PlayerPrefManager.INTERACT_CONFIG, false)) { HttpManager.GetSelfConfig(); } else { HttpManager.UploadConfig(); } } } private void LoginThread() { LoginTimer += Time.deltaTime; if (LoginTimer >= LoginTime) { LoginTimer = 0; HttpManager.Login(); StaticsManager.GetInstance().Online(); } } private void IncomeCircleThread() { IncomeCircleTimer -= Time.deltaTime; if (IncomeCircleTimer < 0) { IncomeCircleTimer = IncomeCircleTime; TotalVisitPerson += CurrentPerson * IncomeCircleTime; float circleIncome = CircleIncome; AddCoin(circleIncome, StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.Income); ResourceManager.Get(CanvasLabel.C_IncomeLab).TweenReForGra(); ResourceManager.Get(CanvasLabel.C_IncomeLab).TweenReForVec(); ResourceManager.SetText(CanvasLabel.C_IncomeLab, "+" + Auxiliary.ShrinkBigNumberStr(circleIncome, 0)); } } public static void AddCoin(double amt, StaticsManager.ItemID itemId, StaticsManager.ConsumeModule consumeModule) { Coin += amt; if (amt > 0) { TotalCoin += amt; StaticsManager.GetInstance().RewardItem(itemId, StaticsManager.ItemType.金币, amt.ToString("0"), consumeModule); } } public static void AddDiamond(double amt, StaticsManager.ItemID itemId, StaticsManager.ConsumeModule consumeModule) { Diamond += amt; if (amt > 0) { StaticsManager.GetInstance().RewardItem(itemId, StaticsManager.ItemType.钻石, amt.ToString("0"), consumeModule); } } public override void Reactive() { foreach (var kv in SkillDictionary) { kv.Value.Reactive(); } InitAllSkill(false); GetOfflineIncome(); SignManager.ShowPanels(); } public override void InstantiatePrefabs() { #region 生成技能条 #region 读技能配置 List attributeList = ConfigManager.GetSkillConfig(); for (int i = 0; i < attributeList.Count; i++) { SkillRoot skillRoot; #region MyRegion if (attributeList[i].Count == 18) { skillRoot = new Pack(attributeList[i]); } else if (attributeList[i].Count == 24) { skillRoot = new Ability(attributeList[i]); } else if (attributeList[i].Count == 34) { if (string.IsNullOrEmpty(attributeList[i][4].Value)) { skillRoot = new Skill(attributeList[i]); } else { skillRoot = new BigSkill(attributeList[i]); } } else { throw new Exception(attributeList[i].Count.ToString()); } #endregion SkillDictionary.Add(skillRoot.FullID, skillRoot); SkillList.Add(skillRoot); } SkillList.Sort(SkillRoot.Sort); #endregion for (int i = 0; i < SkillList.Count; i++) { if (SkillList[i].SkillTab != SkillTab.Null) { ResourceManager.GetSkillItem(SkillList[i]); } } #endregion } public override void FirstInit() { ResourceManager.Get(CanvasLabel.F_Elf).material = Lib.GrayMat; ResourceManager.Get(CanvasLabel.F_Store).material = Lib.GrayMat; ResourceManager.Get(CanvasLabel.F_Magic).material = Lib.GrayMat; ResourceManager.Get(CanvasLabel.F_ElfLab).material = Lib.GrayMat; ResourceManager.Get(CanvasLabel.F_StoreLab).material = Lib.GrayMat; ResourceManager.Get(CanvasLabel.F_MagicLab).material = Lib.GrayMat; ResourceManager.Get