Manager.cs 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513
  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.ShrinkBigNumberStr(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.ShrinkBigNumberStr(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 ReactiveFlag;
  534. public static bool DownloadConfigFlag;
  535. public static bool SceneSwitchFlag;
  536. public static bool Inited;
  537. public static bool IsFirstFrame = true;
  538. public static bool InBackground;
  539. public static float IncomeDisplayTime = 60f;
  540. public static float IncomeCircleTime = 10;
  541. public static float IncomeCircleTimer;
  542. public static float CircleIncome
  543. {
  544. get
  545. {
  546. return CurrentPerson * IncomeCircleTime * CurrentCoinPerson * (1 + FlowerPlus);
  547. }
  548. }
  549. public static float GameBeginTime;
  550. public static bool AlreadyGetOfflineIncome;
  551. public static bool OfflineFlag;
  552. public static float OfflineTime;
  553. public static string OfflineIncomeFml;
  554. public static double OfflineMaxCoin;
  555. public static double OfflineMaxTime;
  556. public static double OfflineMinTime = 120;
  557. public static float InputDetectTime = 60f;
  558. public static float InputDetectTimer;
  559. public static float LoginTime = 10f;
  560. public static float LoginTimer;
  561. public static float MinigameCDTimer;
  562. public static float UploadConfigTime = 60f;
  563. public static float UploadConfigTimer;
  564. public static Manager Instance;
  565. public static DateTime LastQuitTime;
  566. public static List<Skill> UsingSkillList = new List<Skill>();
  567. public static List<Skill> CoolSkillList = new List<Skill>();
  568. public static List<Skill> OfflineCoolSkillList = new List<Skill>();
  569. public static List<List<Skill>> OfflineUsingSkillList = new List<List<Skill>>();
  570. public static List<SkillRoot> SkillList = new List<SkillRoot>();
  571. public static Dictionary<string, SkillRoot> SkillDictionary = new Dictionary<string, SkillRoot>();
  572. #endregion
  573. private void Update()
  574. {
  575. LoginThread();
  576. if (TutorialManager.NewplayerTutorial)
  577. {
  578. return;
  579. }
  580. InputDetectThread();
  581. ProcessSkillThread();
  582. MinigameCDThread();
  583. UploadConfigThread();
  584. IncomeCircleThread();
  585. }
  586. private void InputDetectThread()
  587. {
  588. //if (VisitManager.InVisit)
  589. //{
  590. // return;
  591. //}
  592. if (Auxiliary.AnyKeyUp)
  593. {
  594. InputDetectTimer = 0;
  595. ResourceManager.Get(CanvasLabel.C_Group).TweenForCG();
  596. }
  597. else
  598. {
  599. InputDetectTimer += Time.deltaTime;
  600. if (InputDetectTimer >= InputDetectTime)
  601. {
  602. InputDetectTimer = 0;
  603. ResourceManager.Get(CanvasLabel.C_Group).TweenBacCG();
  604. }
  605. }
  606. }
  607. private void ProcessSkillThread()
  608. {
  609. for (int i = 0; i < UsingSkillList.Count; i++)
  610. {
  611. if (UsingSkillList[i].DoUpdate())
  612. {
  613. UsingSkillList.RemoveAt(i--);
  614. }
  615. }
  616. for (int i = 0; i < CoolSkillList.Count; i++)
  617. {
  618. if (CoolSkillList[i].DoCD())
  619. {
  620. CoolSkillList.RemoveAt(i--);
  621. }
  622. }
  623. }
  624. private void MinigameCDThread()
  625. {
  626. if (!MinigameFlag)
  627. {
  628. MinigameCDTimer -= Time.deltaTime;
  629. ResourceManager.SetText(CanvasLabel.C_MiniGameLab, Mathf.CeilToInt(MinigameCDTimer).ToString());
  630. if (MinigameCDTimer < 0)
  631. {
  632. MinigameFlag = true;
  633. ResourceManager.Get(CanvasLabel.C_MiniGame).TweenBacRect();
  634. ResourceManager.SetText(CanvasLabel.C_MiniGameLab, "");
  635. StaticsManager.GetInstance().RewardItem(StaticsManager.ItemID.获得小游戏, StaticsManager.ItemType.小游戏, "1", StaticsManager.ConsumeModule.None);
  636. }
  637. }
  638. }
  639. private void UploadConfigThread()
  640. {
  641. if (DownloadConfigFlag)
  642. {
  643. return;
  644. }
  645. UploadConfigTimer += Time.deltaTime;
  646. if (UploadConfigTimer >= UploadConfigTime)
  647. {
  648. UploadConfigTimer = 0;
  649. if (!PlayerPrefManager.GetBool(PlayerPrefManager.INTERACT_CONFIG, false))
  650. {
  651. HttpManager.GetSelfConfig();
  652. }
  653. else
  654. {
  655. HttpManager.UploadConfig();
  656. }
  657. }
  658. }
  659. private void LoginThread()
  660. {
  661. LoginTimer += Time.deltaTime;
  662. if (LoginTimer >= LoginTime)
  663. {
  664. LoginTimer = 0;
  665. HttpManager.Login();
  666. StaticsManager.GetInstance().Online();
  667. }
  668. }
  669. private void IncomeCircleThread()
  670. {
  671. IncomeCircleTimer -= Time.deltaTime;
  672. if (IncomeCircleTimer < 0)
  673. {
  674. IncomeCircleTimer = IncomeCircleTime;
  675. TotalVisitPerson += CurrentPerson * IncomeCircleTime;
  676. float circleIncome = CircleIncome;
  677. AddCoin(circleIncome, StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.Income);
  678. ResourceManager.Get(CanvasLabel.C_IncomeLab).TweenReForGra();
  679. ResourceManager.Get(CanvasLabel.C_IncomeLab).TweenReForVec();
  680. ResourceManager.SetText(CanvasLabel.C_IncomeLab, "+" + Auxiliary.ShrinkBigNumberStr(circleIncome, 0));
  681. }
  682. }
  683. public static void AddCoin(double amt, StaticsManager.ItemID itemId, StaticsManager.ConsumeModule consumeModule)
  684. {
  685. Coin += amt;
  686. if (amt > 0)
  687. {
  688. TotalCoin += amt;
  689. StaticsManager.GetInstance().RewardItem(itemId, StaticsManager.ItemType.金币, amt.ToString("0"), consumeModule);
  690. }
  691. }
  692. public static void AddDiamond(double amt, StaticsManager.ItemID itemId, StaticsManager.ConsumeModule consumeModule)
  693. {
  694. Diamond += amt;
  695. if (amt > 0)
  696. {
  697. StaticsManager.GetInstance().RewardItem(itemId, StaticsManager.ItemType.钻石, amt.ToString("0"), consumeModule);
  698. }
  699. }
  700. public override void Reactive()
  701. {
  702. foreach (var kv in SkillDictionary)
  703. {
  704. kv.Value.Reactive();
  705. }
  706. InitAllSkill(false);
  707. GetOfflineIncome();
  708. SignManager.ShowPanels();
  709. }
  710. public override void InstantiatePrefabs()
  711. {
  712. #region 生成技能条
  713. #region 读技能配置
  714. List<XmlAttributeCollection> attributeList = ConfigManager.GetSkillConfig();
  715. for (int i = 0; i < attributeList.Count; i++)
  716. {
  717. SkillRoot skillRoot;
  718. #region MyRegion
  719. if (attributeList[i].Count == 18)
  720. {
  721. skillRoot = new Pack(attributeList[i]);
  722. }
  723. else if (attributeList[i].Count == 24)
  724. {
  725. skillRoot = new Ability(attributeList[i]);
  726. }
  727. else if (attributeList[i].Count == 34)
  728. {
  729. if (string.IsNullOrEmpty(attributeList[i][4].Value))
  730. {
  731. skillRoot = new Skill(attributeList[i]);
  732. }
  733. else
  734. {
  735. skillRoot = new BigSkill(attributeList[i]);
  736. }
  737. }
  738. else
  739. {
  740. throw new Exception(attributeList[i].Count.ToString());
  741. }
  742. #endregion
  743. SkillDictionary.Add(skillRoot.FullID, skillRoot);
  744. SkillList.Add(skillRoot);
  745. }
  746. SkillList.Sort(SkillRoot.Sort);
  747. #endregion
  748. for (int i = 0; i < SkillList.Count; i++)
  749. {
  750. if (SkillList[i].SkillTab != SkillTab.Null)
  751. {
  752. ResourceManager.GetSkillItem(SkillList[i]);
  753. }
  754. }
  755. #endregion
  756. }
  757. public override void FirstInit()
  758. {
  759. ResourceManager.Get<Graphic>(CanvasLabel.F_Elf).material = Lib.GrayMat;
  760. ResourceManager.Get<Graphic>(CanvasLabel.F_Store).material = Lib.GrayMat;
  761. ResourceManager.Get<Graphic>(CanvasLabel.F_Magic).material = Lib.GrayMat;
  762. ResourceManager.Get<Graphic>(CanvasLabel.F_ElfLab).material = Lib.GrayMat;
  763. ResourceManager.Get<Graphic>(CanvasLabel.F_StoreLab).material = Lib.GrayMat;
  764. ResourceManager.Get<Graphic>(CanvasLabel.F_MagicLab).material = Lib.GrayMat;
  765. ResourceManager.Get<Button>(CanvasLabel.F_Elf).interactable = false;
  766. ResourceManager.Get<Button>(CanvasLabel.F_Store).interactable = false;
  767. ResourceManager.Get<Button>(CanvasLabel.F_Magic).interactable = false;
  768. List<XmlAttributeCollection> attributeList = ConfigManager.GetSkillList();
  769. for (int i = 0; i < attributeList.Count; i++)
  770. {
  771. SkillRoot skillRoot = SkillDictionary[attributeList[i][0].Value];
  772. if (!(skillRoot is Skill))
  773. {
  774. skillRoot.RegistReference();
  775. skillRoot.Init(true, OfflineTime, OfflineUsingSkillList, attributeList[i]);
  776. }
  777. }
  778. }
  779. public override void SecondInit()
  780. {
  781. Instance = this;
  782. Coin = ConfigManager.GetDoubleFormConfig(PlayerConfigLabel.Coin);
  783. Diamond = ConfigManager.GetDoubleFormConfig(PlayerConfigLabel.Diamond);
  784. MinigameCDTimer = ConfigManager.GetFloatFormConfig(PlayerConfigLabel.MiniTimer);
  785. IncomeCircleTimer = ConfigManager.GetFloatFormConfig(PlayerConfigLabel.CircleTimer);
  786. if (MinigameCDTimer > 0)
  787. {
  788. ResourceManager.Get(CanvasLabel.C_MiniGame).TweenForRect();
  789. }
  790. else
  791. {
  792. MinigameFlag = true;
  793. }
  794. HttpManager.ID = ConfigManager.GetStringFormConfig(PlayerConfigLabel.ID);
  795. HttpManager.SerialNumber = ConfigManager.GetStringFormConfig(PlayerConfigLabel.SerialNumber);
  796. List<string> offlineList = ConfigManager.GetOfflineConfig();
  797. OfflineMaxCoin = Auxiliary.StringToLong(offlineList[1], 999999999999999999);
  798. OfflineMaxTime = Auxiliary.StringToLong(offlineList[2], 999999999999999999);
  799. OfflineIncomeFml = offlineList[0];
  800. List<double> dataList = ConfigManager.GetAchieveValues();
  801. PlayADsAmt = dataList[0];
  802. AllElfLevel = dataList[4];
  803. UseSkillAmt = dataList[1];
  804. SignAmt = dataList[2];
  805. ShareAmt = dataList[3];
  806. TotalFlowerAwardCoin = dataList[6];
  807. TotalVisitPerson = dataList[7];
  808. TotalSpendDiamond = dataList[8];
  809. PlayMinigameAmt = dataList[5];
  810. CreateRoomAmt = dataList[9];
  811. CreateChestAmt = dataList[10];
  812. CreateLuckyChestAmt = dataList[11];
  813. CreateGuessColorChestAmt = dataList[12];
  814. CreateGuessNumberChestAmt = dataList[13];
  815. GetChestAwardAmt = dataList[14];
  816. }
  817. public static void InitAllSkill(bool firstRegist)
  818. {
  819. OfflineFlag = false;
  820. float realOfflineTime = 0;
  821. ResourceManager.SetActive(CanvasLabel.Ba_Lab2, false);
  822. if (HttpManager.IsConnect && ConfigManager.GetBoolFormConfig(PlayerConfigLabel.QuitFlag))
  823. {
  824. AlreadyGetOfflineIncome = true;
  825. LastQuitTime = DateTime.Parse(ConfigManager.GetStringFormConfig(PlayerConfigLabel.QuitTime));
  826. OfflineTime = (float)HttpManager.CurrentDateTime.Subtract(LastQuitTime).TotalSeconds;
  827. MinigameCDTimer -= OfflineTime;
  828. if (OfflineTime <= OfflineMinTime)
  829. {
  830. realOfflineTime = OfflineTime;
  831. OfflineTime = 0;
  832. }
  833. else
  834. {
  835. OfflineFlag = true;
  836. }
  837. if (OfflineTime > OfflineMaxTime)
  838. {
  839. OfflineTime = (long)OfflineMaxTime;
  840. ResourceManager.SetText(CanvasLabel.Ba_Lab2, Language.GetStr(LanguageLabel.UI__Ba_Lab2));
  841. ResourceManager.SetActive(CanvasLabel.Ba_Lab2, true);
  842. }
  843. }
  844. else
  845. {
  846. if (ConfigManager.GetBoolFormConfig(PlayerConfigLabel.QuitFlag))
  847. {
  848. AlreadyGetOfflineIncome = false;
  849. LastQuitTime = DateTime.Parse(ConfigManager.GetStringFormConfig(PlayerConfigLabel.QuitTime));
  850. GameBeginTime = Time.time;
  851. }
  852. }
  853. OfflineUsingSkillList = new List<List<Skill>>();
  854. OfflineCoolSkillList = new List<Skill>();
  855. if (OfflineTime > IncomeCircleTimer)
  856. {
  857. int circle = 1 + Mathf.FloorToInt((OfflineTime - IncomeCircleTimer) / IncomeCircleTime);
  858. for (int i = 0; i < circle; i++)
  859. {
  860. OfflineUsingSkillList.Add(new List<Skill>());
  861. }
  862. }
  863. List<XmlAttributeCollection> attributeList = ConfigManager.GetSkillList();
  864. for (int i = 0; i < attributeList.Count; i++)
  865. {
  866. SkillRoot skillRoot = SkillDictionary[attributeList[i][0].Value];
  867. if (skillRoot is Skill)
  868. {
  869. skillRoot.RegistReference();
  870. skillRoot.Init(firstRegist, OfflineTime, OfflineUsingSkillList, attributeList[i]);
  871. }
  872. }
  873. if (OfflineFlag == false)
  874. {
  875. foreach (var skill in CoolSkillList)
  876. {
  877. skill.CoolTimer -= realOfflineTime;
  878. }
  879. }
  880. }
  881. public static void GetOfflineIncome()
  882. {
  883. double coin = 0;
  884. for (int i = 0; i < OfflineUsingSkillList.Count; i++)
  885. {
  886. for (int j = 0; j < OfflineCoolSkillList.Count; j++)
  887. {
  888. OfflineCoolSkillList[j].CoolTimer -= IncomeCircleTime;
  889. }
  890. for (int j = 0; j < OfflineUsingSkillList[i].Count; j++)
  891. {
  892. OfflineUsingSkillList[i][j].AnnulEffect();
  893. OfflineCoolSkillList.Add(OfflineUsingSkillList[i][j]);
  894. }
  895. TotalVisitPerson += CurrentPerson*IncomeCircleTime;
  896. coin += CircleIncome;
  897. }
  898. IncomeCircleTimer = (OfflineTime - IncomeCircleTimer)%IncomeCircleTime;
  899. for (int j = 0; j < OfflineCoolSkillList.Count; j++)
  900. {
  901. OfflineCoolSkillList[j].CoolTimer -= IncomeCircleTime - IncomeCircleTimer;
  902. }
  903. coin = (long) AdjustOfflineIncome(coin);
  904. AddCoin(coin, StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.Income);
  905. ResourceManager.SetText(CanvasLabel.Ba_IconLab, Auxiliary.ShrinkBigNumberStr(coin));
  906. }
  907. public static double AdjustOfflineIncome(double offlineIncome)
  908. {
  909. offlineIncome = (long)Auxiliary.FmlParse(OfflineIncomeFml, "c", offlineIncome.ToString());
  910. if (offlineIncome > OfflineMaxCoin)
  911. {
  912. offlineIncome = OfflineMaxCoin;
  913. ResourceManager.SetText(CanvasLabel.Ba_Lab2, Language.GetStr(LanguageLabel.UI__Ba_Lab2));
  914. ResourceManager.SetActive(CanvasLabel.Ba_Lab2, true);
  915. }
  916. return offlineIncome;
  917. }
  918. public new static void SwitchLanguage()
  919. {
  920. Coin = Coin;
  921. AddDiamond(0, StaticsManager.ItemID.None, StaticsManager.ConsumeModule.None);
  922. }
  923. 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)
  924. {
  925. if (TutorialManager.PayExempt)
  926. {
  927. succeedCallback.Invoke();
  928. return;
  929. }
  930. amt = Auxiliary.ShrinkNumber(amt);
  931. if (current == Current.Free)
  932. {
  933. succeedCallback.Invoke();
  934. }
  935. else if (current == Current.AD)
  936. {
  937. IAPManager.PlayAD(succeedCallback);
  938. }
  939. else if (current == Current.Cash)
  940. {
  941. IAPManager.TryPurchase(id);
  942. }
  943. else if (current == Current.Coin)
  944. {
  945. #region MyRegion
  946. if (Coin >= amt)
  947. {
  948. Coin -= amt;
  949. succeedCallback.Invoke();
  950. StaticsManager.GetInstance().UseItem(itemId, StaticsManager.ItemType.金币, buyAmount.ToString(), consumeModule);
  951. }
  952. else
  953. {
  954. ResourceManager.Get(CanvasLabel.Fe_Info).TweenBacCG();
  955. if (navigate)
  956. {
  957. Bubble.Show
  958. (
  959. Language.GetStr(LanguageLabel.Common__ShortCoin),
  960. Language.GetStr(LanguageLabel.Common__NavigateCoin),
  961. null,
  962. Lib.GoldSprite,
  963. () =>
  964. {
  965. navigateCall.SafeInvoke();
  966. if (useBubbleTweenNavigate)
  967. {
  968. TweenRoot tween = ResourceManager.Get(CanvasLabel.K_Bubble0).GetTweenScale();
  969. tween.AddEventOnetime
  970. (
  971. EventType.BackwardFinish,
  972. () =>
  973. {
  974. UIManager.NavigateToBuyCoin();
  975. }
  976. );
  977. }
  978. else
  979. {
  980. TweenRoot tween = ResourceManager.Get(CanvasLabel.F_Manage0).GetTweenVec();
  981. tween.AddEventOnetime
  982. (
  983. EventType.ForwardFinish,
  984. () =>
  985. {
  986. UIManager.NavigateToBuyCoin();
  987. }
  988. );
  989. }
  990. }
  991. );
  992. }
  993. else
  994. {
  995. Bubble.Show
  996. (
  997. Language.GetStr(LanguageLabel.Common__ShortCoin),
  998. null,
  999. null,
  1000. Lib.GoldSprite
  1001. );
  1002. }
  1003. }
  1004. #endregion
  1005. }
  1006. else if (current == Current.Diamond)
  1007. {
  1008. #region MyRegion
  1009. if (Diamond >= amt)
  1010. {
  1011. Diamond -= amt;
  1012. TotalSpendDiamond += amt;
  1013. succeedCallback.Invoke();
  1014. StaticsManager.GetInstance().PurchaseItem(itemId, StaticsManager.ItemType.钻石, buyAmount.ToString(), amt.ToString("0"), consumeModule);
  1015. }
  1016. else
  1017. {
  1018. ResourceManager.Get(CanvasLabel.Fe_Info).TweenBacCG();
  1019. if (navigate)
  1020. {
  1021. Bubble.Show
  1022. (
  1023. Language.GetStr(LanguageLabel.Common__ShortDiamond),
  1024. Language.GetStr(LanguageLabel.Common__NavigateDiamond),
  1025. null,
  1026. Lib.DiamondSprite,
  1027. () =>
  1028. {
  1029. navigateCall.SafeInvoke();
  1030. if (useBubbleTweenNavigate)
  1031. {
  1032. TweenRoot tween = ResourceManager.Get(CanvasLabel.K_Bubble0).GetTweenScale();
  1033. tween.AddEventOnetime
  1034. (
  1035. EventType.BackwardFinish,
  1036. () =>
  1037. {
  1038. UIManager.NavigateToBuyDiamond();
  1039. }
  1040. );
  1041. }
  1042. else
  1043. {
  1044. TweenRoot tween = ResourceManager.Get(CanvasLabel.F_Manage0).GetTweenVec();
  1045. tween.AddEventOnetime
  1046. (
  1047. EventType.ForwardFinish,
  1048. () =>
  1049. {
  1050. UIManager.NavigateToBuyDiamond();
  1051. }
  1052. );
  1053. }
  1054. }
  1055. );
  1056. }
  1057. else
  1058. {
  1059. Bubble.Show
  1060. (
  1061. Language.GetStr(LanguageLabel.Common__ShortDiamond),
  1062. null,
  1063. null,
  1064. Lib.DiamondSprite
  1065. );
  1066. }
  1067. }
  1068. #endregion
  1069. }
  1070. else
  1071. {
  1072. throw new Exception(current.ToString());
  1073. }
  1074. }
  1075. public static void FirstTimeLoginCallback(JsonData jsonData)
  1076. {
  1077. if (!Initializer.Inited || !HttpManager.Inited || Inited)
  1078. {
  1079. return;
  1080. }
  1081. HttpManager.GetBuyPackLimitFlag();
  1082. if (HttpManager.IsConnect)
  1083. {
  1084. if (ConfigManager.GetStringFormConfig(PlayerConfigLabel.ID) == PlayerConfigLabel.DefaultID)
  1085. {
  1086. HttpManager.ID = HttpManager.LoginCallbackData["o"].ToString();
  1087. ResourceManager.SetText(CanvasLabel.L_UserLab, HttpManager.ID);
  1088. }
  1089. if (ConfigManager.GetStringFormConfig(PlayerConfigLabel.SerialNumber) == PlayerConfigLabel.DefaultSerialNumber)
  1090. {
  1091. HttpManager.SerialNumber = HttpManager.LoginCallbackData["i"].ToString();
  1092. }
  1093. }
  1094. InitAllSkill(true);
  1095. GetOfflineIncome();
  1096. SignManager.ShowPanels();
  1097. Analytics.SetUserId(HttpManager.ID);
  1098. Inited = true;
  1099. GardenLevel = GardenLevel;
  1100. if (!PlayerPrefManager.GetBool(PlayerPrefManager.INTERACT_CONFIG, false))
  1101. {
  1102. HttpManager.GetSelfConfig();
  1103. }
  1104. else
  1105. {
  1106. HttpManager.UploadConfig();
  1107. }
  1108. ConfigManager.SaveConfigDocument();
  1109. ConfigManager.SaveConfigDocumentToDisk();
  1110. }
  1111. public static void ReactiveLoginCallback(JsonData jsonData)
  1112. {
  1113. LoginFlag = false;
  1114. for (int i = 0; i < Initializer.RegistList.Count; i++)
  1115. {
  1116. Initializer.RegistList[i].Reactive();
  1117. }
  1118. }
  1119. public static void SwitchConfig(string id)
  1120. {
  1121. ResourceManager.SetText(CanvasLabel.La_Lab, Language.GetStr(LanguageLabel.UI__L_Downloading));
  1122. ResourceManager.SetActive(CanvasLabel.La_Lab, true);
  1123. ResourceManager.SetActive(CanvasLabel.La_Mask, true);
  1124. HttpManager.GetConfigByID(id, SwitchConfigCallback);
  1125. }
  1126. public static void SwitchConfigCallback(JsonData jsonData)
  1127. {
  1128. if (jsonData.Inst_Object.Keys.Contains("l"))
  1129. {
  1130. ResourceManager.Get(CanvasLabel.La_Info).TweenBacCG();
  1131. ResourceManager.SetText(CanvasLabel.La_Lab, Language.GetStr(LanguageLabel.UI__La_Lab0));
  1132. ConfigManager.ConfigDocument.LoadXml(jsonData["l"].ToString());
  1133. ConfigManager.ConfigRootNode = ConfigManager.ConfigDocument.SelectSingleNode(PlayerConfigLabel.RootNode);
  1134. ResourceManager.SetText(CanvasLabel.L_UserLab, ConfigManager.GetStringFormConfig(PlayerConfigLabel.ID));
  1135. HttpManager.ID = ConfigManager.GetStringFormConfig(PlayerConfigLabel.ID);
  1136. HttpManager.SerialNumber = ConfigManager.GetStringFormConfig(PlayerConfigLabel.SerialNumber);
  1137. Bubble.Show(null, Language.GetStr(LanguageLabel.UI__La_Lab0), null, null, () => { Application.Quit(); }, null, false);
  1138. UploadConfigFlag = true;
  1139. DownloadConfigFlag = true;
  1140. ConfigManager.SaveConfigDocumentToDisk();
  1141. PlayerPrefs.SetString(Lib.ConfigPrefs, "");
  1142. }
  1143. else
  1144. {
  1145. ResourceManager.SetText(CanvasLabel.La_Lab, Language.GetStr(LanguageLabel.UI__La_Lab1));
  1146. ResourceManager.SetActive(CanvasLabel.La_Mask, false);
  1147. }
  1148. }
  1149. public void OnApplicationQuit()
  1150. {
  1151. if (!UploadConfigFlag)
  1152. {
  1153. VisitManager.ReverseConfigData();
  1154. ConfigManager.SaveConfigDocument();
  1155. ConfigManager.SaveConfigDocumentToDisk();
  1156. }
  1157. }
  1158. public void OnApplicationPause(bool pause)
  1159. {
  1160. if (pause)
  1161. {
  1162. InBackground = true;
  1163. if (DownloadConfigFlag)
  1164. {
  1165. return;
  1166. }
  1167. VisitManager.ReverseConfigData();
  1168. ConfigManager.SaveConfigDocument();
  1169. ConfigManager.SaveConfigDocumentToDisk();
  1170. }
  1171. else
  1172. {
  1173. StaticsManager.GetInstance().StartSession();
  1174. InBackground = false;
  1175. if (IsFirstFrame)
  1176. {
  1177. IsFirstFrame = false;
  1178. }
  1179. else
  1180. {
  1181. if (TutorialManager.NewplayerTutorial)
  1182. {
  1183. return;
  1184. }
  1185. if (!Initializer.Inited)
  1186. {
  1187. return;
  1188. }
  1189. if (!Initializer.IsGameActivated)
  1190. {
  1191. return;
  1192. }
  1193. if (DownloadConfigFlag)
  1194. {
  1195. return;
  1196. }
  1197. VisitManager.RecoverConfigData();
  1198. if (LoginFlag)
  1199. {
  1200. return;
  1201. }
  1202. if (ReactiveFlag)
  1203. {
  1204. ReactiveFlag = false;
  1205. return;
  1206. }
  1207. LoginFlag = true;
  1208. HttpManager.Login(ReactiveLoginCallback);
  1209. HttpManager.GetMailAwardData();
  1210. }
  1211. }
  1212. }
  1213. }