Manager.cs 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486
  1. using LitJson;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. using UnityEngine.Events;
  5. using UnityEngine.Analytics;
  6. using UnityEngine.EventSystems;
  7. using System;
  8. using System.Xml;
  9. using System.Collections;
  10. using System.Collections.Generic;
  11. public class Manager : Regist
  12. {
  13. #region Config
  14. #region 成就
  15. public static double PlayADsAmt
  16. {
  17. get { return playADsAmt; }
  18. set
  19. {
  20. playADsAmt = value;
  21. AchieveManager.UpdateStatus(AchieveType.PlayADsAmt, playADsAmt);
  22. }
  23. }
  24. private static double playADsAmt;
  25. public static double UseSkillAmt
  26. {
  27. get { return useSkillAmt; }
  28. set
  29. {
  30. useSkillAmt = value;
  31. AchieveManager.UpdateStatus(AchieveType.UseSkillAmt, useSkillAmt);
  32. }
  33. }
  34. private static double useSkillAmt;
  35. public static double SignAmt
  36. {
  37. get { return signAmt; }
  38. set
  39. {
  40. signAmt = value;
  41. AchieveManager.UpdateStatus(AchieveType.SignAmt, signAmt);
  42. }
  43. }
  44. private static double signAmt;
  45. public static double CloseAmt
  46. {
  47. get { return closeAmt; }
  48. set
  49. {
  50. closeAmt = value;
  51. AchieveManager.UpdateStatus(AchieveType.CloseAmt, closeAmt);
  52. }
  53. }
  54. private static double closeAmt;
  55. public static double ShareAmt
  56. {
  57. get { return shareAmt; }
  58. set
  59. {
  60. shareAmt = value;
  61. AchieveManager.UpdateStatus(AchieveType.ShareAmt, shareAmt);
  62. }
  63. }
  64. private static double shareAmt;
  65. public static double PlayMinigameAmt
  66. {
  67. get { return playMinigameAmt; }
  68. set
  69. {
  70. playMinigameAmt = value;
  71. AchieveManager.UpdateStatus(AchieveType.PlayMinigameAmt, playMinigameAmt);
  72. }
  73. }
  74. private static double playMinigameAmt;
  75. public static double AllElfLevel
  76. {
  77. get { return allElfLevel; }
  78. set
  79. {
  80. allElfLevel = value;
  81. AchieveManager.UpdateStatus(AchieveType.AllElfLevel, allElfLevel);
  82. }
  83. }
  84. private static double allElfLevel;
  85. public static double TotalCoin
  86. {
  87. get { return totalCoin; }
  88. set
  89. {
  90. totalCoin = value;
  91. AchieveManager.UpdateStatus(AchieveType.TotalCoin, totalCoin);
  92. }
  93. }
  94. private static double totalCoin;
  95. public static double TotalFlowerAwardCoin
  96. {
  97. get { return totalFlowerAwardCoin; }
  98. set
  99. {
  100. totalFlowerAwardCoin = value;
  101. AchieveManager.UpdateStatus(AchieveType.TotalFlowerAwardCoin, totalFlowerAwardCoin);
  102. }
  103. }
  104. private static double totalFlowerAwardCoin;
  105. public static double TotalVisitPerson
  106. {
  107. get { return totalVisitPerson; }
  108. set
  109. {
  110. totalVisitPerson = value;
  111. AchieveManager.UpdateStatus(AchieveType.TotalVisitPerson, totalVisitPerson);
  112. }
  113. }
  114. private static double totalVisitPerson;
  115. public static double TotalSpendDiamond
  116. {
  117. get { return totalSpendDiamond; }
  118. set
  119. {
  120. totalSpendDiamond = value;
  121. AchieveManager.UpdateStatus(AchieveType.TotalSpendDiamond, totalSpendDiamond);
  122. }
  123. }
  124. private static double totalSpendDiamond;
  125. public static double CreateRoomAmt
  126. {
  127. get { return createRoomAmt; }
  128. set
  129. {
  130. createRoomAmt = value;
  131. AchieveManager.UpdateStatus(AchieveType.CreateRoomAmt, createRoomAmt);
  132. }
  133. }
  134. private static double createRoomAmt;
  135. public static double CreateChestAmt
  136. {
  137. get { return createChestAmt; }
  138. set
  139. {
  140. createChestAmt = value;
  141. AchieveManager.UpdateStatus(AchieveType.CreateChestAmt, createChestAmt);
  142. }
  143. }
  144. private static double createChestAmt;
  145. public static double CreateLuckyChestAmt
  146. {
  147. get { return createLuckyChestAmt; }
  148. set
  149. {
  150. createLuckyChestAmt = value;
  151. AchieveManager.UpdateStatus(AchieveType.CreateLuckyChestAmt, createLuckyChestAmt);
  152. }
  153. }
  154. private static double createLuckyChestAmt;
  155. public static double CreateGuessColorChestAmt
  156. {
  157. get { return createGuessColorChestAmt; }
  158. set
  159. {
  160. createGuessColorChestAmt = value;
  161. AchieveManager.UpdateStatus(AchieveType.CreateGuessColorChestAmt, createGuessColorChestAmt);
  162. }
  163. }
  164. private static double createGuessColorChestAmt;
  165. public static double CreateGuessNumberChestAmt
  166. {
  167. get { return createGuessNumberChestAmt; }
  168. set
  169. {
  170. createGuessNumberChestAmt = value;
  171. AchieveManager.UpdateStatus(AchieveType.CreateGuessNumberChestAmt, createGuessNumberChestAmt);
  172. }
  173. }
  174. private static double createGuessNumberChestAmt;
  175. public static double GetChestAwardAmt
  176. {
  177. get { return getChestAwardAmt; }
  178. set
  179. {
  180. getChestAwardAmt = value;
  181. AchieveManager.UpdateStatus(AchieveType.GetChestAwardAmt, getChestAwardAmt);
  182. }
  183. }
  184. private static double getChestAwardAmt;
  185. #endregion
  186. public static Action<int> OnLevelChange;
  187. public static Action<double> OnCoinChange;
  188. public static Action<double> OnDiamondChange;
  189. public static int GardenLevel
  190. {
  191. get { return gardenLevel; }
  192. set
  193. {
  194. gardenLevel = value;
  195. if (!Inited)
  196. {
  197. return;
  198. }
  199. LanguageManager.Add(ResourceManager.Get<Text>(CanvasLabel.C_LevelText), new MulLanStr(LanguageLabel.UI__C_Level), gardenLevel.ToString());
  200. VisitManager.UpdateVisitCost();
  201. AchieveManager.UpdateStatus(AchieveType.GardenLevel, gardenLevel);
  202. for (int i = 0; i < SkillList.Count; i++)
  203. {
  204. SkillList[i].UpdateStatus();
  205. }
  206. foreach (var kv in PlayerManager.CloseItemDictionary)
  207. {
  208. kv.Value.OnLevelChange();
  209. }
  210. if (OnLevelChange != null)
  211. {
  212. OnLevelChange.Invoke(gardenLevel);
  213. }
  214. if (gardenLevel >= TutorialManager.MemoryMinigameTutorialLevel)
  215. {
  216. if (TutorialManager.memoryMinigameTutorial)
  217. {
  218. TutorialManager.MemoryMinigameTutorial = true;
  219. }
  220. }
  221. if (GardenLevel < TutorialManager.DressroomTutorialLevel)
  222. {
  223. ResourceManager.Get<Image>(CanvasLabel.C_DressRoom).material = Lib.GrayMat;
  224. }
  225. else
  226. {
  227. ResourceManager.Get<Image>(CanvasLabel.C_DressRoom).material = null;
  228. }
  229. if (GardenManager.TotalUnlockFlower >= TutorialManager.MinFlowerForFindSoloGame && gardenLevel >= TutorialManager.FindSoloMinigameTutorialLevel)
  230. {
  231. if (TutorialManager.findSoloMinigameTutorial)
  232. {
  233. TutorialManager.PlayFindSoloGame();
  234. }
  235. }
  236. if (GardenManager.TotalUnlockFlower >= TutorialManager.MinFlowerForFindMissingGame && gardenLevel >= TutorialManager.FindMissingMinigameTutorialLevel)
  237. {
  238. if (TutorialManager.findMissingMinigameTutorial)
  239. {
  240. TutorialManager.PlayFindMissingGame();
  241. }
  242. }
  243. if (gardenLevel >= TutorialManager.CommentTutorialLevel)
  244. {
  245. ResourceManager.Get(CanvasLabel.C_CommentParent).TweenForCG();
  246. }
  247. if (gardenLevel >= TutorialManager.VisitTutorialLevel)
  248. {
  249. if (TutorialManager.visitTutorial)
  250. {
  251. TutorialManager.ClickVisitBtn();
  252. return;
  253. }
  254. else
  255. {
  256. ResourceManager.SetActive(CanvasLabel.C_Visit, true);
  257. }
  258. }
  259. if (gardenLevel >= TutorialManager.DressroomTutorialLevel)
  260. {
  261. if (TutorialManager.dressroomTutorial)
  262. {
  263. TutorialManager.ClickDressroomButton();
  264. return;
  265. }
  266. }
  267. if (gardenLevel >= TutorialManager.PlazaRoomTutorialLevel)
  268. {
  269. if (TutorialManager.plazaRoomTutorial)
  270. {
  271. TutorialManager.ClickPlazaRoomBtn();
  272. return;
  273. }
  274. else
  275. {
  276. ResourceManager.SetActive(CanvasLabel.C_EnterPlazaRoom, true);
  277. ResourceManager.SetActive(CanvasLabel.C_EnterPlazaRoom0, true);
  278. }
  279. }
  280. }
  281. }
  282. private static int gardenLevel;
  283. public static float Person
  284. {
  285. get { return person; }
  286. set
  287. {
  288. person = value;
  289. ResourceManager.SetText(CanvasLabel.F_PersonLab, Auxiliary.ShrinkAllNumberStr(CurrentPerson*60));
  290. }
  291. }
  292. private static float person;
  293. public static List<string> ExtraPersonSourceSpritesName = new List<string>();
  294. public static float CoinPerson
  295. {
  296. get { return coinPerson; }
  297. set
  298. {
  299. coinPerson = value;
  300. ResourceManager.SetText(CanvasLabel.F_CoinPersonLab, Auxiliary.ShrinkAllNumberStr(CurrentCoinPerson));
  301. }
  302. }
  303. private static float coinPerson;
  304. public static List<string> ExtraCoinPersonSourceSpritesName = new List<string>();
  305. public static float SkillPerson
  306. {
  307. get { return skillPerson; }
  308. set
  309. {
  310. skillPerson = value;
  311. //TweenOutline tween = ResourceManager.Get(CanvasLabel.F_PersonLab).GetTweenOutline();
  312. //if (skillPerson.Equal(0))
  313. //{
  314. // tween.Pause();
  315. // tween.Target.enabled = false;
  316. //}
  317. //else
  318. //{
  319. // if (tween.InPause)
  320. // {
  321. // tween.Resume();
  322. // tween.Target.enabled = true;
  323. // }
  324. // else
  325. // {
  326. // tween.StartForward();
  327. // }
  328. //}
  329. Person = Person;
  330. }
  331. }
  332. public static float skillPerson;
  333. public static float TempSkillPerson
  334. {
  335. get { return tempSkillPerson; }
  336. set
  337. {
  338. tempSkillPerson = value;
  339. TweenOutline tween = ResourceManager.Get(CanvasLabel.F_PersonLab).GetTweenOutline();
  340. if (tempSkillPerson.Equal(0) && tempSkillPersonBuff.Equal(0))
  341. {
  342. tween.Pause();
  343. tween.Target.enabled = false;
  344. }
  345. else
  346. {
  347. if (tween.InPause)
  348. {
  349. tween.Resume();
  350. tween.Target.enabled = true;
  351. }
  352. else
  353. {
  354. tween.StartForward();
  355. }
  356. }
  357. Person = Person;
  358. }
  359. }
  360. public static float tempSkillPerson;
  361. public static float SkillPersonBuff
  362. {
  363. get { return skillPersonBuff; }
  364. set
  365. {
  366. skillPersonBuff = value;
  367. Person = Person;
  368. }
  369. }
  370. public static float skillPersonBuff;
  371. public static float TempSkillPersonBuff
  372. {
  373. get { return tempSkillPersonBuff; }
  374. set
  375. {
  376. tempSkillPersonBuff = value;
  377. TweenOutline tween = ResourceManager.Get(CanvasLabel.F_PersonLab).GetTweenOutline();
  378. if (tempSkillPerson.Equal(0) && tempSkillPersonBuff.Equal(0))
  379. {
  380. tween.Pause();
  381. tween.Target.enabled = false;
  382. }
  383. else
  384. {
  385. if (tween.InPause)
  386. {
  387. tween.Resume();
  388. tween.Target.enabled = true;
  389. }
  390. else
  391. {
  392. tween.StartForward();
  393. }
  394. }
  395. Person = Person;
  396. }
  397. }
  398. public static float tempSkillPersonBuff;
  399. public static float SkillCoinPerson
  400. {
  401. get { return skillCoinPerson; }
  402. set
  403. {
  404. skillCoinPerson = value;
  405. CoinPerson = CoinPerson;
  406. }
  407. }
  408. public static float skillCoinPerson;
  409. public static float TempSkillCoinPerson
  410. {
  411. get { return tempSkillCoinPerson; }
  412. set
  413. {
  414. tempSkillCoinPerson = value;
  415. TweenOutline tween = ResourceManager.Get(CanvasLabel.F_CoinPersonLab).GetTweenOutline();
  416. if (tempSkillCoinPerson.Equal(0) && tempSkillCoinPersonBuff.Equal(0))
  417. {
  418. tween.Pause();
  419. tween.Target.enabled = false;
  420. }
  421. else
  422. {
  423. if (tween.InPause)
  424. {
  425. tween.Resume();
  426. tween.Target.enabled = true;
  427. }
  428. else
  429. {
  430. tween.StartForward();
  431. }
  432. }
  433. CoinPerson = CoinPerson;
  434. }
  435. }
  436. public static float tempSkillCoinPerson;
  437. public static float SkillCoinPersonBuff
  438. {
  439. get { return skillCoinPersonBuff; }
  440. set
  441. {
  442. skillCoinPersonBuff = value;
  443. CoinPerson = CoinPerson;
  444. }
  445. }
  446. public static float skillCoinPersonBuff;
  447. public static float TempSkillCoinPersonBuff
  448. {
  449. get { return tempSkillCoinPersonBuff; }
  450. set
  451. {
  452. tempSkillCoinPersonBuff = value;
  453. TweenOutline tween = ResourceManager.Get(CanvasLabel.F_CoinPersonLab).GetTweenOutline();
  454. if (tempSkillCoinPersonBuff.Equal(0) && tempSkillCoinPerson.Equal(0))
  455. {
  456. tween.Pause();
  457. tween.Target.enabled = false;
  458. }
  459. else
  460. {
  461. if (tween.InPause)
  462. {
  463. tween.Resume();
  464. tween.Target.enabled = true;
  465. }
  466. else
  467. {
  468. tween.StartForward();
  469. }
  470. }
  471. CoinPerson = CoinPerson;
  472. }
  473. }
  474. public static float tempSkillCoinPersonBuff;
  475. public static float IncomeBuff
  476. {
  477. get { return SkillCoinPersonBuff + FlowerPlus; }
  478. }
  479. public static float FlowerPlus
  480. {
  481. get { return flowerPlus; }
  482. set
  483. {
  484. flowerPlus = value;
  485. }
  486. }
  487. public static float flowerPlus;
  488. public static float CurrentPerson
  489. {
  490. get
  491. {
  492. //Debug.Log(Person * (1 + SkillPersonBuff + TempSkillPersonBuff) + SkillPerson + TempSkillPerson);
  493. return Person*(1 + SkillPersonBuff + TempSkillPersonBuff) + SkillPerson + TempSkillPerson;
  494. }
  495. }
  496. public static float CurrentCoinPerson
  497. {
  498. get
  499. {
  500. //Debug.Log(CoinPerson * (1 + SkillCoinPersonBuff + TempSkillCoinPersonBuff) + SkillCoinPerson + TempSkillCoinPerson);
  501. return CoinPerson*(1 + SkillCoinPersonBuff + TempSkillCoinPersonBuff) + SkillCoinPerson + TempSkillCoinPerson;
  502. }
  503. }
  504. public static double Coin
  505. {
  506. get { return coin; }
  507. set
  508. {
  509. coin = value;
  510. ResourceManager.SetText(CanvasLabel.F_CoinLab, Auxiliary.ShrinkBigNumberStr(coin));
  511. ResourceManager.SetText(CanvasLabel.C_CoinLab, Auxiliary.ShrinkBigNumberStr(coin));
  512. ResourceManager.SetText(CanvasLabel.P_CoinLab, Auxiliary.ShrinkBigNumberStr(coin));
  513. AchieveManager.UpdateStatus(AchieveType.CurrentCoin, coin);
  514. OnCoinChange.SafeInvoke(coin);
  515. }
  516. }
  517. public static double coin;
  518. public static double Diamond
  519. {
  520. get { return diamond; }
  521. set
  522. {
  523. diamond = value;
  524. ResourceManager.SetText(CanvasLabel.F_DiamondLab, Auxiliary.ShrinkBigNumberStr(diamond));
  525. ResourceManager.SetText(CanvasLabel.P_DiamondLab, Auxiliary.ShrinkBigNumberStr(diamond));
  526. OnDiamondChange.SafeInvoke(diamond);
  527. }
  528. }
  529. public static double diamond;
  530. public static bool MinigameFlag;
  531. public static bool UploadConfigFlag;
  532. public static bool LoginFlag;
  533. public static bool OfflineFlag;
  534. public static bool ReactiveFlag;
  535. public static bool DownloadConfigFlag;
  536. public static bool SceneSwitchFlag;
  537. public static bool Inited;
  538. public static bool IsFirstFrame = true;
  539. public static bool InBackground;
  540. public static float IncomeDisplayTime = 60f;
  541. public static float IncomeCircleTime = 10;
  542. public static float IncomeCircleTimer;
  543. public static float CircleIncome
  544. {
  545. get
  546. {
  547. return CurrentPerson * IncomeCircleTime * CurrentCoinPerson * (1 + FlowerPlus);
  548. }
  549. }
  550. public static float OfflineTime;
  551. public static string OfflineIncomeFml;
  552. public static double OfflineMaxCoin;
  553. public static double OfflineMaxTime;
  554. public static double OfflineMinTime = 120f;
  555. public static float InputDetectTime = 60f;
  556. public static float InputDetectTimer;
  557. public static float LoginTime = 10f;
  558. public static float LoginTimer;
  559. public static float MinigameCDTimer;
  560. public static float UploadConfigTime = 60f;
  561. public static float UploadConfigTimer;
  562. public static Manager Instance;
  563. public static DateTime LastQuitTime;
  564. public static List<Skill> UsingSkillList = new List<Skill>();
  565. public static List<Skill> CoolSkillList = new List<Skill>();
  566. public static List<Skill> OfflineCoolSkillList = new List<Skill>();
  567. public static List<List<Skill>> OfflineUsingSkillList = new List<List<Skill>>();
  568. public static List<SkillRoot> SkillList = new List<SkillRoot>();
  569. public static Dictionary<string, SkillRoot> SkillDictionary = new Dictionary<string, SkillRoot>();
  570. #endregion
  571. private void Update()
  572. {
  573. LoginThread();
  574. if (TutorialManager.NewplayerTutorial)
  575. {
  576. return;
  577. }
  578. InputDetectThread();
  579. ProcessSkillThread();
  580. MinigameCDThread();
  581. UploadConfigThread();
  582. IncomeCircleThread();
  583. }
  584. private void InputDetectThread()
  585. {
  586. if (Auxiliary.AnyKeyUp)
  587. {
  588. InputDetectTimer = 0;
  589. ResourceManager.Get(CanvasLabel.C_Group).TweenForCG();
  590. }
  591. else
  592. {
  593. InputDetectTimer += Time.deltaTime;
  594. if (InputDetectTimer >= InputDetectTime)
  595. {
  596. InputDetectTimer = 0;
  597. ResourceManager.Get(CanvasLabel.C_Group).TweenBacCG();
  598. }
  599. }
  600. }
  601. private void ProcessSkillThread()
  602. {
  603. for (int i = 0; i < UsingSkillList.Count; i++)
  604. {
  605. if (UsingSkillList[i].DoUpdate())
  606. {
  607. UsingSkillList.RemoveAt(i--);
  608. }
  609. }
  610. for (int i = 0; i < CoolSkillList.Count; i++)
  611. {
  612. if (CoolSkillList[i].DoCD())
  613. {
  614. CoolSkillList.RemoveAt(i--);
  615. }
  616. }
  617. }
  618. private void MinigameCDThread()
  619. {
  620. if (!MinigameFlag)
  621. {
  622. MinigameCDTimer -= Time.deltaTime;
  623. ResourceManager.SetText(CanvasLabel.C_MiniGameLab, Mathf.CeilToInt(MinigameCDTimer).ToString());
  624. if (MinigameCDTimer < 0)
  625. {
  626. MinigameFlag = true;
  627. ResourceManager.Get(CanvasLabel.C_MiniGame).TweenBacRect();
  628. ResourceManager.SetText(CanvasLabel.C_MiniGameLab, "");
  629. StaticsManager.GetInstance().RewardItem(StaticsManager.ItemID.获得小游戏, StaticsManager.ItemType.小游戏, "1", StaticsManager.ConsumeModule.None);
  630. }
  631. }
  632. }
  633. private void UploadConfigThread()
  634. {
  635. if (DownloadConfigFlag)
  636. {
  637. return;
  638. }
  639. UploadConfigTimer += Time.deltaTime;
  640. if (UploadConfigTimer >= UploadConfigTime)
  641. {
  642. UploadConfigTimer = 0;
  643. if (!PlayerPrefManager.GetBool(PlayerPrefManager.INTERACT_CONFIG, false))
  644. {
  645. HttpManager.GetSelfConfig();
  646. }
  647. else
  648. {
  649. HttpManager.UploadConfig();
  650. }
  651. }
  652. }
  653. private void LoginThread()
  654. {
  655. LoginTimer += Time.deltaTime;
  656. if (LoginTimer >= LoginTime)
  657. {
  658. LoginTimer = 0;
  659. HttpManager.Login();
  660. StaticsManager.GetInstance().Online();
  661. }
  662. }
  663. private void IncomeCircleThread()
  664. {
  665. IncomeCircleTimer -= Time.deltaTime;
  666. if (IncomeCircleTimer < 0)
  667. {
  668. IncomeCircleTimer = IncomeCircleTime;
  669. TotalVisitPerson += CurrentPerson * IncomeCircleTime;
  670. float circleIncome = CircleIncome;
  671. AddCoin(circleIncome, StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.Income);
  672. ResourceManager.Get(CanvasLabel.C_IncomeLab).TweenReForGra();
  673. ResourceManager.Get(CanvasLabel.C_IncomeLab).TweenReForVec();
  674. ResourceManager.SetText(CanvasLabel.C_IncomeLab, "+" + Auxiliary.ShrinkBigNumberStr(circleIncome, 0));
  675. }
  676. }
  677. public static void AddCoin(double amt, StaticsManager.ItemID itemId, StaticsManager.ConsumeModule consumeModule)
  678. {
  679. Coin += amt;
  680. if (amt > 0)
  681. {
  682. TotalCoin += amt;
  683. StaticsManager.GetInstance().RewardItem(itemId, StaticsManager.ItemType.金币, amt.ToString("0"), consumeModule);
  684. }
  685. }
  686. public static void AddDiamond(double amt, StaticsManager.ItemID itemId, StaticsManager.ConsumeModule consumeModule)
  687. {
  688. Diamond += amt;
  689. if (amt > 0)
  690. {
  691. StaticsManager.GetInstance().RewardItem(itemId, StaticsManager.ItemType.钻石, amt.ToString("0"), consumeModule);
  692. }
  693. }
  694. public override void Reactive()
  695. {
  696. foreach (var kv in SkillDictionary)
  697. {
  698. kv.Value.Reactive();
  699. }
  700. InitAllSkill(false);
  701. GetOfflineIncome();
  702. SignManager.ShowPanels();
  703. }
  704. public override void InstantiatePrefabs()
  705. {
  706. #region 生成技能条
  707. #region 读技能配置
  708. List<XmlAttributeCollection> attributeList = ConfigManager.GetSkillConfig();
  709. for (int i = 0; i < attributeList.Count; i++)
  710. {
  711. SkillRoot skillRoot;
  712. #region MyRegion
  713. if (attributeList[i].Count == 18)
  714. {
  715. skillRoot = new Pack(attributeList[i]);
  716. }
  717. else if (attributeList[i].Count == 24)
  718. {
  719. skillRoot = new Ability(attributeList[i]);
  720. }
  721. else if (attributeList[i].Count == 34)
  722. {
  723. if (string.IsNullOrEmpty(attributeList[i][4].Value))
  724. {
  725. skillRoot = new Skill(attributeList[i]);
  726. }
  727. else
  728. {
  729. skillRoot = new BigSkill(attributeList[i]);
  730. }
  731. }
  732. else
  733. {
  734. throw new Exception(attributeList[i].Count.ToString());
  735. }
  736. #endregion
  737. SkillDictionary.Add(skillRoot.FullID, skillRoot);
  738. SkillList.Add(skillRoot);
  739. }
  740. SkillList.Sort(SkillRoot.Sort);
  741. #endregion
  742. for (int i = 0; i < SkillList.Count; i++)
  743. {
  744. if (SkillList[i].SkillTab != SkillTab.Null)
  745. {
  746. ResourceManager.GetSkillItem(SkillList[i]);
  747. }
  748. }
  749. #endregion
  750. }
  751. public override void FirstInit()
  752. {
  753. ResourceManager.Get<Graphic>(CanvasLabel.F_Elf).material = Lib.GrayMat;
  754. ResourceManager.Get<Graphic>(CanvasLabel.F_Store).material = Lib.GrayMat;
  755. ResourceManager.Get<Graphic>(CanvasLabel.F_Magic).material = Lib.GrayMat;
  756. ResourceManager.Get<Graphic>(CanvasLabel.F_ElfLab).material = Lib.GrayMat;
  757. ResourceManager.Get<Graphic>(CanvasLabel.F_StoreLab).material = Lib.GrayMat;
  758. ResourceManager.Get<Graphic>(CanvasLabel.F_MagicLab).material = Lib.GrayMat;
  759. ResourceManager.Get<Button>(CanvasLabel.F_Elf).interactable = false;
  760. ResourceManager.Get<Button>(CanvasLabel.F_Store).interactable = false;
  761. ResourceManager.Get<Button>(CanvasLabel.F_Magic).interactable = false;
  762. List<XmlAttributeCollection> attributeList = ConfigManager.GetSkillList();
  763. for (int i = 0; i < attributeList.Count; i++)
  764. {
  765. SkillRoot skillRoot = SkillDictionary[attributeList[i][0].Value];
  766. if (!(skillRoot is Skill))
  767. {
  768. skillRoot.RegistReference();
  769. skillRoot.Init(true, OfflineTime, OfflineUsingSkillList, attributeList[i]);
  770. }
  771. }
  772. }
  773. public override void SecondInit()
  774. {
  775. Instance = this;
  776. Coin = ConfigManager.GetDoubleFormConfig(PlayerConfigLabel.Coin);
  777. Diamond = ConfigManager.GetDoubleFormConfig(PlayerConfigLabel.Diamond);
  778. MinigameCDTimer = ConfigManager.GetFloatFormConfig(PlayerConfigLabel.MiniTimer);
  779. IncomeCircleTimer = ConfigManager.GetFloatFormConfig(PlayerConfigLabel.CircleTimer);
  780. if (MinigameCDTimer > 0)
  781. {
  782. ResourceManager.Get(CanvasLabel.C_MiniGame).TweenForRect();
  783. }
  784. else
  785. {
  786. MinigameFlag = true;
  787. }
  788. HttpManager.ID = ConfigManager.GetStringFormConfig(PlayerConfigLabel.ID);
  789. HttpManager.SerialNumber = ConfigManager.GetStringFormConfig(PlayerConfigLabel.SerialNumber);
  790. List<string> offlineList = ConfigManager.GetOfflineConfig();
  791. OfflineMaxCoin = Auxiliary.StringToLong(offlineList[1], 999999999999999999);
  792. OfflineMaxTime = Auxiliary.StringToLong(offlineList[2], 999999999999999999);
  793. OfflineIncomeFml = offlineList[0];
  794. List<double> dataList = ConfigManager.GetAchieveValues();
  795. PlayADsAmt = dataList[0];
  796. AllElfLevel = dataList[4];
  797. UseSkillAmt = dataList[1];
  798. SignAmt = dataList[2];
  799. ShareAmt = dataList[3];
  800. TotalFlowerAwardCoin = dataList[6];
  801. TotalVisitPerson = dataList[7];
  802. TotalSpendDiamond = dataList[8];
  803. PlayMinigameAmt = dataList[5];
  804. CreateRoomAmt = dataList[9];
  805. CreateChestAmt = dataList[10];
  806. CreateLuckyChestAmt = dataList[11];
  807. CreateGuessColorChestAmt = dataList[12];
  808. CreateGuessNumberChestAmt = dataList[13];
  809. GetChestAwardAmt = dataList[14];
  810. }
  811. public static void InitAllSkill(bool firstRegist)
  812. {
  813. OfflineFlag = false;
  814. float realOfflineTime = 0;
  815. ResourceManager.SetActive(CanvasLabel.Ba_Lab2, false);
  816. if (HttpManager.IsConnect && ConfigManager.GetBoolFormConfig(PlayerConfigLabel.QuitFlag))
  817. {
  818. LastQuitTime = DateTime.Parse(ConfigManager.GetStringFormConfig(PlayerConfigLabel.QuitTime));
  819. OfflineTime = (float)HttpManager.CurrentDateTime.Subtract(LastQuitTime).TotalSeconds;
  820. MinigameCDTimer -= OfflineTime;
  821. if (OfflineTime <= OfflineMinTime)
  822. {
  823. realOfflineTime = OfflineTime;
  824. OfflineTime = 0;
  825. }
  826. else
  827. {
  828. OfflineFlag = true;
  829. }
  830. if (OfflineTime > OfflineMaxTime)
  831. {
  832. OfflineTime = (long)OfflineMaxTime;
  833. ResourceManager.SetText(CanvasLabel.Ba_Lab2, Language.GetStr(LanguageLabel.UI__Ba_Lab2));
  834. ResourceManager.SetActive(CanvasLabel.Ba_Lab2, true);
  835. }
  836. }
  837. OfflineUsingSkillList = new List<List<Skill>>();
  838. OfflineCoolSkillList = new List<Skill>();
  839. if (OfflineTime > IncomeCircleTimer)
  840. {
  841. int circle = 1 + Mathf.FloorToInt((OfflineTime - IncomeCircleTimer) / IncomeCircleTime);
  842. for (int i = 0; i < circle; i++)
  843. {
  844. OfflineUsingSkillList.Add(new List<Skill>());
  845. }
  846. }
  847. List<XmlAttributeCollection> attributeList = ConfigManager.GetSkillList();
  848. for (int i = 0; i < attributeList.Count; i++)
  849. {
  850. SkillRoot skillRoot = SkillDictionary[attributeList[i][0].Value];
  851. if (skillRoot is Skill)
  852. {
  853. skillRoot.RegistReference();
  854. skillRoot.Init(firstRegist, OfflineTime, OfflineUsingSkillList, attributeList[i]);
  855. }
  856. }
  857. if (OfflineFlag == false)
  858. {
  859. foreach (var skill in CoolSkillList)
  860. {
  861. skill.CoolTimer -= realOfflineTime;
  862. }
  863. }
  864. }
  865. public static void GetOfflineIncome()
  866. {
  867. double coin = 0;
  868. for (int i = 0; i < OfflineUsingSkillList.Count; i++)
  869. {
  870. for (int j = 0; j < OfflineCoolSkillList.Count; j++)
  871. {
  872. OfflineCoolSkillList[j].CoolTimer -= IncomeCircleTime;
  873. }
  874. for (int j = 0; j < OfflineUsingSkillList[i].Count; j++)
  875. {
  876. OfflineUsingSkillList[i][j].AnnulEffect();
  877. OfflineCoolSkillList.Add(OfflineUsingSkillList[i][j]);
  878. }
  879. TotalVisitPerson += CurrentPerson*IncomeCircleTime;
  880. coin += CircleIncome;
  881. }
  882. IncomeCircleTimer = (OfflineTime - IncomeCircleTimer)%IncomeCircleTime;
  883. for (int j = 0; j < OfflineCoolSkillList.Count; j++)
  884. {
  885. OfflineCoolSkillList[j].CoolTimer -= IncomeCircleTime - IncomeCircleTimer;
  886. }
  887. coin = (long) Auxiliary.FmlParse(OfflineIncomeFml, "c", coin.ToString());
  888. if (coin > OfflineMaxCoin)
  889. {
  890. coin = OfflineMaxCoin;
  891. ResourceManager.SetText(CanvasLabel.Ba_Lab2, Language.GetStr(LanguageLabel.UI__Ba_Lab2));
  892. ResourceManager.SetActive(CanvasLabel.Ba_Lab2, true);
  893. }
  894. AddCoin(coin, StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.Income);
  895. ResourceManager.SetText(CanvasLabel.Ba_IconLab, Auxiliary.ShrinkBigNumberStr(coin));
  896. }
  897. public new static void SwitchLanguage()
  898. {
  899. Coin = Coin;
  900. AddDiamond(0, StaticsManager.ItemID.None, StaticsManager.ConsumeModule.None);
  901. }
  902. 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)
  903. {
  904. if (TutorialManager.PayExempt)
  905. {
  906. succeedCallback.Invoke();
  907. return;
  908. }
  909. amt = Auxiliary.ShrinkNumber(amt);
  910. if (current == Current.Free)
  911. {
  912. succeedCallback.Invoke();
  913. }
  914. else if (current == Current.AD)
  915. {
  916. IAPManager.PlayAD(succeedCallback);
  917. }
  918. else if (current == Current.Cash)
  919. {
  920. IAPManager.TryPurchase(id);
  921. }
  922. else if (current == Current.Coin)
  923. {
  924. #region MyRegion
  925. if (Coin >= amt)
  926. {
  927. Coin -= amt;
  928. succeedCallback.Invoke();
  929. StaticsManager.GetInstance().UseItem(itemId, StaticsManager.ItemType.金币, buyAmount.ToString(), consumeModule);
  930. }
  931. else
  932. {
  933. ResourceManager.Get(CanvasLabel.Fe_Info).TweenBacCG();
  934. if (navigate)
  935. {
  936. Bubble.Show
  937. (
  938. Language.GetStr(LanguageLabel.Common__ShortCoin),
  939. Language.GetStr(LanguageLabel.Common__NavigateCoin),
  940. null,
  941. Lib.GoldSprite,
  942. () =>
  943. {
  944. navigateCall.SafeInvoke();
  945. if (useBubbleTweenNavigate)
  946. {
  947. TweenRoot tween = ResourceManager.Get(CanvasLabel.K_Bubble0).GetTweenScale();
  948. tween.AddEventOnetime
  949. (
  950. EventType.BackwardFinish,
  951. () =>
  952. {
  953. UIManager.NavigateToBuyCoin();
  954. }
  955. );
  956. }
  957. else
  958. {
  959. TweenRoot tween = ResourceManager.Get(CanvasLabel.F_Manage0).GetTweenVec();
  960. tween.AddEventOnetime
  961. (
  962. EventType.ForwardFinish,
  963. () =>
  964. {
  965. UIManager.NavigateToBuyCoin();
  966. }
  967. );
  968. }
  969. }
  970. );
  971. }
  972. else
  973. {
  974. Bubble.Show
  975. (
  976. Language.GetStr(LanguageLabel.Common__ShortCoin),
  977. null,
  978. null,
  979. Lib.GoldSprite
  980. );
  981. }
  982. }
  983. #endregion
  984. }
  985. else if (current == Current.Diamond)
  986. {
  987. #region MyRegion
  988. if (Diamond >= amt)
  989. {
  990. Diamond -= amt;
  991. TotalSpendDiamond += amt;
  992. succeedCallback.Invoke();
  993. StaticsManager.GetInstance().PurchaseItem(itemId, StaticsManager.ItemType.钻石, buyAmount.ToString(), amt.ToString("0"), consumeModule);
  994. }
  995. else
  996. {
  997. ResourceManager.Get(CanvasLabel.Fe_Info).TweenBacCG();
  998. if (navigate)
  999. {
  1000. Bubble.Show
  1001. (
  1002. Language.GetStr(LanguageLabel.Common__ShortDiamond),
  1003. Language.GetStr(LanguageLabel.Common__NavigateDiamond),
  1004. null,
  1005. Lib.DiamondSprite,
  1006. () =>
  1007. {
  1008. navigateCall.SafeInvoke();
  1009. if (useBubbleTweenNavigate)
  1010. {
  1011. TweenRoot tween = ResourceManager.Get(CanvasLabel.K_Bubble0).GetTweenScale();
  1012. tween.AddEventOnetime
  1013. (
  1014. EventType.BackwardFinish,
  1015. () =>
  1016. {
  1017. UIManager.NavigateToBuyDiamond();
  1018. }
  1019. );
  1020. }
  1021. else
  1022. {
  1023. TweenRoot tween = ResourceManager.Get(CanvasLabel.F_Manage0).GetTweenVec();
  1024. tween.AddEventOnetime
  1025. (
  1026. EventType.ForwardFinish,
  1027. () =>
  1028. {
  1029. UIManager.NavigateToBuyDiamond();
  1030. }
  1031. );
  1032. }
  1033. }
  1034. );
  1035. }
  1036. else
  1037. {
  1038. Bubble.Show
  1039. (
  1040. Language.GetStr(LanguageLabel.Common__ShortDiamond),
  1041. null,
  1042. null,
  1043. Lib.DiamondSprite
  1044. );
  1045. }
  1046. }
  1047. #endregion
  1048. }
  1049. else
  1050. {
  1051. throw new Exception(current.ToString());
  1052. }
  1053. }
  1054. public static void FirstTimeLoginCallback(JsonData jsonData)
  1055. {
  1056. if (!Initializer.Inited || !HttpManager.Inited || Inited)
  1057. {
  1058. return;
  1059. }
  1060. HttpManager.GetBuyPackLimitFlag();
  1061. if (HttpManager.IsConnect)
  1062. {
  1063. if (ConfigManager.GetStringFormConfig(PlayerConfigLabel.ID) == PlayerConfigLabel.DefaultID)
  1064. {
  1065. HttpManager.ID = HttpManager.LoginCallbackData["o"].ToString();
  1066. ResourceManager.SetText(CanvasLabel.L_UserLab, HttpManager.ID);
  1067. }
  1068. if (ConfigManager.GetStringFormConfig(PlayerConfigLabel.SerialNumber) == PlayerConfigLabel.DefaultSerialNumber)
  1069. {
  1070. HttpManager.SerialNumber = HttpManager.LoginCallbackData["i"].ToString();
  1071. }
  1072. }
  1073. InitAllSkill(true);
  1074. GetOfflineIncome();
  1075. SignManager.ShowPanels();
  1076. Analytics.SetUserId(HttpManager.ID);
  1077. Inited = true;
  1078. GardenLevel = GardenLevel;
  1079. if (!PlayerPrefManager.GetBool(PlayerPrefManager.INTERACT_CONFIG, false))
  1080. {
  1081. HttpManager.GetSelfConfig();
  1082. }
  1083. else
  1084. {
  1085. HttpManager.UploadConfig();
  1086. }
  1087. }
  1088. public static void ReactiveLoginCallback(JsonData jsonData)
  1089. {
  1090. LoginFlag = false;
  1091. for (int i = 0; i < Initializer.RegistList.Count; i++)
  1092. {
  1093. Initializer.RegistList[i].Reactive();
  1094. }
  1095. }
  1096. public static void SwitchConfig(string id)
  1097. {
  1098. ResourceManager.SetText(CanvasLabel.La_Lab, Language.GetStr(LanguageLabel.UI__L_Downloading));
  1099. ResourceManager.SetActive(CanvasLabel.La_Lab, true);
  1100. ResourceManager.SetActive(CanvasLabel.La_Mask, true);
  1101. HttpManager.GetConfigByID(id, SwitchConfigCallback);
  1102. }
  1103. public static void SwitchConfigCallback(JsonData jsonData)
  1104. {
  1105. if (jsonData.Inst_Object.Keys.Contains("l"))
  1106. {
  1107. ResourceManager.Get(CanvasLabel.La_Info).TweenBacCG();
  1108. ResourceManager.SetText(CanvasLabel.La_Lab, Language.GetStr(LanguageLabel.UI__La_Lab0));
  1109. ConfigManager.ConfigDocument.LoadXml(jsonData["l"].ToString());
  1110. ConfigManager.ConfigRootNode = ConfigManager.ConfigDocument.SelectSingleNode(PlayerConfigLabel.RootNode);
  1111. ResourceManager.SetText(CanvasLabel.L_UserLab, ConfigManager.GetStringFormConfig(PlayerConfigLabel.ID));
  1112. HttpManager.ID = ConfigManager.GetStringFormConfig(PlayerConfigLabel.ID);
  1113. HttpManager.SerialNumber = ConfigManager.GetStringFormConfig(PlayerConfigLabel.SerialNumber);
  1114. Bubble.Show(null, Language.GetStr(LanguageLabel.UI__La_Lab0), null, null, () => { Application.Quit(); }, null, false);
  1115. UploadConfigFlag = true;
  1116. DownloadConfigFlag = true;
  1117. ConfigManager.SaveConfigDocumentToDisk();
  1118. PlayerPrefs.SetString(Lib.ConfigPrefs, "");
  1119. }
  1120. else
  1121. {
  1122. ResourceManager.SetText(CanvasLabel.La_Lab, Language.GetStr(LanguageLabel.UI__La_Lab1));
  1123. ResourceManager.SetActive(CanvasLabel.La_Mask, false);
  1124. }
  1125. }
  1126. public void OnApplicationQuit()
  1127. {
  1128. if (!UploadConfigFlag)
  1129. {
  1130. VisitManager.ReverseConfigData();
  1131. ConfigManager.SaveConfigDocument();
  1132. ConfigManager.SaveConfigDocumentToDisk();
  1133. }
  1134. }
  1135. public void OnApplicationPause(bool pause)
  1136. {
  1137. if (pause)
  1138. {
  1139. InBackground = true;
  1140. if (DownloadConfigFlag)
  1141. {
  1142. return;
  1143. }
  1144. VisitManager.ReverseConfigData();
  1145. ConfigManager.SaveConfigDocument();
  1146. ConfigManager.SaveConfigDocumentToDisk();
  1147. }
  1148. else
  1149. {
  1150. StaticsManager.GetInstance().StartSession();
  1151. InBackground = false;
  1152. if (IsFirstFrame)
  1153. {
  1154. IsFirstFrame = false;
  1155. }
  1156. else
  1157. {
  1158. if (TutorialManager.NewplayerTutorial)
  1159. {
  1160. return;
  1161. }
  1162. if (!Initializer.Inited)
  1163. {
  1164. return;
  1165. }
  1166. if (!Initializer.IsGameActivated)
  1167. {
  1168. return;
  1169. }
  1170. if (DownloadConfigFlag)
  1171. {
  1172. return;
  1173. }
  1174. VisitManager.RecoverConfigData();
  1175. if (LoginFlag)
  1176. {
  1177. return;
  1178. }
  1179. if (ReactiveFlag)
  1180. {
  1181. ReactiveFlag = false;
  1182. return;
  1183. }
  1184. LoginFlag = true;
  1185. HttpManager.Login(ReactiveLoginCallback);
  1186. HttpManager.GetMailAwardData();
  1187. }
  1188. }
  1189. }
  1190. }