1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513 |
- 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<int> OnLevelChange;
- public static Action<double> OnCoinChange;
- public static Action<double> OnDiamondChange;
- public static int GardenLevel
- {
- get { return gardenLevel; }
- set
- {
- gardenLevel = value;
- if (!Inited)
- {
- return;
- }
- LanguageManager.Add(ResourceManager.Get<Text>(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<Image>(CanvasLabel.C_DressRoom).material = Lib.GrayMat;
- }
- else
- {
- ResourceManager.Get<Image>(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<string> ExtraPersonSourceSpritesName = new List<string>();
- 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<string> ExtraCoinPersonSourceSpritesName = new List<string>();
- 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<Skill> UsingSkillList = new List<Skill>();
- public static List<Skill> CoolSkillList = new List<Skill>();
- public static List<Skill> OfflineCoolSkillList = new List<Skill>();
- public static List<List<Skill>> OfflineUsingSkillList = new List<List<Skill>>();
- public static List<SkillRoot> SkillList = new List<SkillRoot>();
- public static Dictionary<string, SkillRoot> SkillDictionary = new Dictionary<string, SkillRoot>();
- #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<XmlAttributeCollection> 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<Graphic>(CanvasLabel.F_Elf).material = Lib.GrayMat;
- ResourceManager.Get<Graphic>(CanvasLabel.F_Store).material = Lib.GrayMat;
- ResourceManager.Get<Graphic>(CanvasLabel.F_Magic).material = Lib.GrayMat;
- ResourceManager.Get<Graphic>(CanvasLabel.F_ElfLab).material = Lib.GrayMat;
- ResourceManager.Get<Graphic>(CanvasLabel.F_StoreLab).material = Lib.GrayMat;
- ResourceManager.Get<Graphic>(CanvasLabel.F_MagicLab).material = Lib.GrayMat;
- ResourceManager.Get<Button>(CanvasLabel.F_Elf).interactable = false;
- ResourceManager.Get<Button>(CanvasLabel.F_Store).interactable = false;
- ResourceManager.Get<Button>(CanvasLabel.F_Magic).interactable = false;
- List<XmlAttributeCollection> attributeList = ConfigManager.GetSkillList();
- for (int i = 0; i < attributeList.Count; i++)
- {
- SkillRoot skillRoot = SkillDictionary[attributeList[i][0].Value];
- if (!(skillRoot is Skill))
- {
- skillRoot.RegistReference();
- skillRoot.Init(true, OfflineTime, OfflineUsingSkillList, attributeList[i]);
- }
- }
- }
- public override void SecondInit()
- {
- Instance = this;
- Coin = ConfigManager.GetDoubleFormConfig(PlayerConfigLabel.Coin);
- Diamond = ConfigManager.GetDoubleFormConfig(PlayerConfigLabel.Diamond);
- MinigameCDTimer = ConfigManager.GetFloatFormConfig(PlayerConfigLabel.MiniTimer);
- IncomeCircleTimer = ConfigManager.GetFloatFormConfig(PlayerConfigLabel.CircleTimer);
- if (MinigameCDTimer > 0)
- {
- ResourceManager.Get(CanvasLabel.C_MiniGame).TweenForRect();
- }
- else
- {
- MinigameFlag = true;
- }
- HttpManager.ID = ConfigManager.GetStringFormConfig(PlayerConfigLabel.ID);
- HttpManager.SerialNumber = ConfigManager.GetStringFormConfig(PlayerConfigLabel.SerialNumber);
- List<string> offlineList = ConfigManager.GetOfflineConfig();
- OfflineMaxCoin = Auxiliary.StringToLong(offlineList[1], 999999999999999999);
- OfflineMaxTime = Auxiliary.StringToLong(offlineList[2], 999999999999999999);
- OfflineIncomeFml = offlineList[0];
- List<double> dataList = ConfigManager.GetAchieveValues();
- PlayADsAmt = dataList[0];
- AllElfLevel = dataList[4];
- UseSkillAmt = dataList[1];
- SignAmt = dataList[2];
- ShareAmt = dataList[3];
- TotalFlowerAwardCoin = dataList[6];
- TotalVisitPerson = dataList[7];
- TotalSpendDiamond = dataList[8];
- PlayMinigameAmt = dataList[5];
- CreateRoomAmt = dataList[9];
- CreateChestAmt = dataList[10];
- CreateLuckyChestAmt = dataList[11];
- CreateGuessColorChestAmt = dataList[12];
- CreateGuessNumberChestAmt = dataList[13];
- GetChestAwardAmt = dataList[14];
- }
- public static void InitAllSkill(bool firstRegist)
- {
- OfflineFlag = false;
- float realOfflineTime = 0;
- ResourceManager.SetActive(CanvasLabel.Ba_Lab2, false);
- if (HttpManager.IsConnect && ConfigManager.GetBoolFormConfig(PlayerConfigLabel.QuitFlag))
- {
- AlreadyGetOfflineIncome = true;
- LastQuitTime = DateTime.Parse(ConfigManager.GetStringFormConfig(PlayerConfigLabel.QuitTime));
- OfflineTime = (float)HttpManager.CurrentDateTime.Subtract(LastQuitTime).TotalSeconds;
- MinigameCDTimer -= OfflineTime;
- if (OfflineTime <= OfflineMinTime)
- {
- realOfflineTime = OfflineTime;
- OfflineTime = 0;
- }
- else
- {
- OfflineFlag = true;
- }
- if (OfflineTime > OfflineMaxTime)
- {
- OfflineTime = (long)OfflineMaxTime;
- ResourceManager.SetText(CanvasLabel.Ba_Lab2, Language.GetStr(LanguageLabel.UI__Ba_Lab2));
- ResourceManager.SetActive(CanvasLabel.Ba_Lab2, true);
- }
- }
- else
- {
- if (ConfigManager.GetBoolFormConfig(PlayerConfigLabel.QuitFlag))
- {
- AlreadyGetOfflineIncome = false;
- LastQuitTime = DateTime.Parse(ConfigManager.GetStringFormConfig(PlayerConfigLabel.QuitTime));
- GameBeginTime = Time.time;
- }
- }
- OfflineUsingSkillList = new List<List<Skill>>();
- OfflineCoolSkillList = new List<Skill>();
- if (OfflineTime > IncomeCircleTimer)
- {
- int circle = 1 + Mathf.FloorToInt((OfflineTime - IncomeCircleTimer) / IncomeCircleTime);
- for (int i = 0; i < circle; i++)
- {
- OfflineUsingSkillList.Add(new List<Skill>());
- }
- }
- List<XmlAttributeCollection> attributeList = ConfigManager.GetSkillList();
- for (int i = 0; i < attributeList.Count; i++)
- {
- SkillRoot skillRoot = SkillDictionary[attributeList[i][0].Value];
- if (skillRoot is Skill)
- {
- skillRoot.RegistReference();
- skillRoot.Init(firstRegist, OfflineTime, OfflineUsingSkillList, attributeList[i]);
- }
- }
- if (OfflineFlag == false)
- {
- foreach (var skill in CoolSkillList)
- {
- skill.CoolTimer -= realOfflineTime;
- }
- }
- }
-
- public static void GetOfflineIncome()
- {
- double coin = 0;
- for (int i = 0; i < OfflineUsingSkillList.Count; i++)
- {
- for (int j = 0; j < OfflineCoolSkillList.Count; j++)
- {
- OfflineCoolSkillList[j].CoolTimer -= IncomeCircleTime;
- }
- for (int j = 0; j < OfflineUsingSkillList[i].Count; j++)
- {
- OfflineUsingSkillList[i][j].AnnulEffect();
- OfflineCoolSkillList.Add(OfflineUsingSkillList[i][j]);
- }
- TotalVisitPerson += CurrentPerson*IncomeCircleTime;
- coin += CircleIncome;
- }
- IncomeCircleTimer = (OfflineTime - IncomeCircleTimer)%IncomeCircleTime;
- for (int j = 0; j < OfflineCoolSkillList.Count; j++)
- {
- OfflineCoolSkillList[j].CoolTimer -= IncomeCircleTime - IncomeCircleTimer;
- }
- coin = (long) AdjustOfflineIncome(coin);
- AddCoin(coin, StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.Income);
- ResourceManager.SetText(CanvasLabel.Ba_IconLab, Auxiliary.ShrinkBigNumberStr(coin));
- }
- public static double AdjustOfflineIncome(double offlineIncome)
- {
- offlineIncome = (long)Auxiliary.FmlParse(OfflineIncomeFml, "c", offlineIncome.ToString());
- if (offlineIncome > OfflineMaxCoin)
- {
- offlineIncome = OfflineMaxCoin;
- ResourceManager.SetText(CanvasLabel.Ba_Lab2, Language.GetStr(LanguageLabel.UI__Ba_Lab2));
- ResourceManager.SetActive(CanvasLabel.Ba_Lab2, true);
- }
- return offlineIncome;
- }
- public new static void SwitchLanguage()
- {
- Coin = Coin;
- AddDiamond(0, StaticsManager.ItemID.None, StaticsManager.ConsumeModule.None);
- }
- public static void Pay(string id, double amt, Current current, UnityAction succeedCallback, StaticsManager.ItemID itemId, StaticsManager.ConsumeModule consumeModule, bool navigate = true, bool useBubbleTweenNavigate = true, UnityAction navigateCall = null, int buyAmount = 1)
- {
- if (TutorialManager.PayExempt)
- {
- succeedCallback.Invoke();
- return;
- }
- amt = Auxiliary.ShrinkNumber(amt);
- if (current == Current.Free)
- {
- succeedCallback.Invoke();
- }
- else if (current == Current.AD)
- {
- IAPManager.PlayAD(succeedCallback);
- }
- else if (current == Current.Cash)
- {
- IAPManager.TryPurchase(id);
- }
- else if (current == Current.Coin)
- {
- #region MyRegion
- if (Coin >= amt)
- {
- Coin -= amt;
- succeedCallback.Invoke();
- StaticsManager.GetInstance().UseItem(itemId, StaticsManager.ItemType.金币, buyAmount.ToString(), consumeModule);
- }
- else
- {
- ResourceManager.Get(CanvasLabel.Fe_Info).TweenBacCG();
- if (navigate)
- {
- Bubble.Show
- (
- Language.GetStr(LanguageLabel.Common__ShortCoin),
- Language.GetStr(LanguageLabel.Common__NavigateCoin),
- null,
- Lib.GoldSprite,
- () =>
- {
- navigateCall.SafeInvoke();
- if (useBubbleTweenNavigate)
- {
- TweenRoot tween = ResourceManager.Get(CanvasLabel.K_Bubble0).GetTweenScale();
- tween.AddEventOnetime
- (
- EventType.BackwardFinish,
- () =>
- {
- UIManager.NavigateToBuyCoin();
- }
- );
- }
- else
- {
- TweenRoot tween = ResourceManager.Get(CanvasLabel.F_Manage0).GetTweenVec();
- tween.AddEventOnetime
- (
- EventType.ForwardFinish,
- () =>
- {
- UIManager.NavigateToBuyCoin();
- }
- );
- }
- }
- );
- }
- else
- {
- Bubble.Show
- (
- Language.GetStr(LanguageLabel.Common__ShortCoin),
- null,
- null,
- Lib.GoldSprite
- );
- }
- }
- #endregion
- }
- else if (current == Current.Diamond)
- {
- #region MyRegion
- if (Diamond >= amt)
- {
- Diamond -= amt;
- TotalSpendDiamond += amt;
- succeedCallback.Invoke();
- StaticsManager.GetInstance().PurchaseItem(itemId, StaticsManager.ItemType.钻石, buyAmount.ToString(), amt.ToString("0"), consumeModule);
- }
- else
- {
- ResourceManager.Get(CanvasLabel.Fe_Info).TweenBacCG();
- if (navigate)
- {
- Bubble.Show
- (
- Language.GetStr(LanguageLabel.Common__ShortDiamond),
- Language.GetStr(LanguageLabel.Common__NavigateDiamond),
- null,
- Lib.DiamondSprite,
- () =>
- {
- navigateCall.SafeInvoke();
- if (useBubbleTweenNavigate)
- {
- TweenRoot tween = ResourceManager.Get(CanvasLabel.K_Bubble0).GetTweenScale();
- tween.AddEventOnetime
- (
- EventType.BackwardFinish,
- () =>
- {
- UIManager.NavigateToBuyDiamond();
- }
- );
- }
- else
- {
- TweenRoot tween = ResourceManager.Get(CanvasLabel.F_Manage0).GetTweenVec();
- tween.AddEventOnetime
- (
- EventType.ForwardFinish,
- () =>
- {
- UIManager.NavigateToBuyDiamond();
- }
- );
- }
- }
- );
- }
- else
- {
- Bubble.Show
- (
- Language.GetStr(LanguageLabel.Common__ShortDiamond),
- null,
- null,
- Lib.DiamondSprite
- );
- }
- }
- #endregion
- }
- else
- {
- throw new Exception(current.ToString());
- }
- }
- public static void FirstTimeLoginCallback(JsonData jsonData)
- {
- if (!Initializer.Inited || !HttpManager.Inited || Inited)
- {
- return;
- }
- HttpManager.GetBuyPackLimitFlag();
- if (HttpManager.IsConnect)
- {
- if (ConfigManager.GetStringFormConfig(PlayerConfigLabel.ID) == PlayerConfigLabel.DefaultID)
- {
- HttpManager.ID = HttpManager.LoginCallbackData["o"].ToString();
- ResourceManager.SetText(CanvasLabel.L_UserLab, HttpManager.ID);
- }
- if (ConfigManager.GetStringFormConfig(PlayerConfigLabel.SerialNumber) == PlayerConfigLabel.DefaultSerialNumber)
- {
- HttpManager.SerialNumber = HttpManager.LoginCallbackData["i"].ToString();
- }
- }
- InitAllSkill(true);
- GetOfflineIncome();
- SignManager.ShowPanels();
- Analytics.SetUserId(HttpManager.ID);
- Inited = true;
-
- GardenLevel = GardenLevel;
- if (!PlayerPrefManager.GetBool(PlayerPrefManager.INTERACT_CONFIG, false))
- {
- HttpManager.GetSelfConfig();
- }
- else
- {
- HttpManager.UploadConfig();
- }
- ConfigManager.SaveConfigDocument();
- ConfigManager.SaveConfigDocumentToDisk();
- }
- public static void ReactiveLoginCallback(JsonData jsonData)
- {
- LoginFlag = false;
- for (int i = 0; i < Initializer.RegistList.Count; i++)
- {
- Initializer.RegistList[i].Reactive();
- }
- }
- public static void SwitchConfig(string id)
- {
- ResourceManager.SetText(CanvasLabel.La_Lab, Language.GetStr(LanguageLabel.UI__L_Downloading));
- ResourceManager.SetActive(CanvasLabel.La_Lab, true);
- ResourceManager.SetActive(CanvasLabel.La_Mask, true);
- HttpManager.GetConfigByID(id, SwitchConfigCallback);
- }
-
- public static void SwitchConfigCallback(JsonData jsonData)
- {
- if (jsonData.Inst_Object.Keys.Contains("l"))
- {
- ResourceManager.Get(CanvasLabel.La_Info).TweenBacCG();
- ResourceManager.SetText(CanvasLabel.La_Lab, Language.GetStr(LanguageLabel.UI__La_Lab0));
- ConfigManager.ConfigDocument.LoadXml(jsonData["l"].ToString());
- ConfigManager.ConfigRootNode = ConfigManager.ConfigDocument.SelectSingleNode(PlayerConfigLabel.RootNode);
- ResourceManager.SetText(CanvasLabel.L_UserLab, ConfigManager.GetStringFormConfig(PlayerConfigLabel.ID));
- HttpManager.ID = ConfigManager.GetStringFormConfig(PlayerConfigLabel.ID);
- HttpManager.SerialNumber = ConfigManager.GetStringFormConfig(PlayerConfigLabel.SerialNumber);
- Bubble.Show(null, Language.GetStr(LanguageLabel.UI__La_Lab0), null, null, () => { Application.Quit(); }, null, false);
- UploadConfigFlag = true;
- DownloadConfigFlag = true;
- ConfigManager.SaveConfigDocumentToDisk();
- PlayerPrefs.SetString(Lib.ConfigPrefs, "");
- }
- else
- {
- ResourceManager.SetText(CanvasLabel.La_Lab, Language.GetStr(LanguageLabel.UI__La_Lab1));
- ResourceManager.SetActive(CanvasLabel.La_Mask, false);
- }
- }
- public void OnApplicationQuit()
- {
- if (!UploadConfigFlag)
- {
- VisitManager.ReverseConfigData();
- ConfigManager.SaveConfigDocument();
- ConfigManager.SaveConfigDocumentToDisk();
- }
- }
- public void OnApplicationPause(bool pause)
- {
- if (pause)
- {
- InBackground = true;
- if (DownloadConfigFlag)
- {
- return;
- }
- VisitManager.ReverseConfigData();
- ConfigManager.SaveConfigDocument();
- ConfigManager.SaveConfigDocumentToDisk();
- }
- else
- {
- StaticsManager.GetInstance().StartSession();
- InBackground = false;
- if (IsFirstFrame)
- {
- IsFirstFrame = false;
- }
- else
- {
- if (TutorialManager.NewplayerTutorial)
- {
- return;
- }
- if (!Initializer.Inited)
- {
- return;
- }
- if (!Initializer.IsGameActivated)
- {
- return;
- }
- if (DownloadConfigFlag)
- {
- return;
- }
- VisitManager.RecoverConfigData();
- if (LoginFlag)
- {
- return;
- }
- if (ReactiveFlag)
- {
- ReactiveFlag = false;
- return;
- }
- LoginFlag = true;
- HttpManager.Login(ReactiveLoginCallback);
- HttpManager.GetMailAwardData();
- }
- }
- }
- }
|